Skip to content

Commit

Permalink
Cleaning of connectors code
Browse files Browse the repository at this point in the history
Mainly formatting and renaming of variables

Signed-off-by: Arjan Tijms <arjan.tijms@gmail.com>
  • Loading branch information
arjantijms committed Oct 4, 2022
1 parent 4143d1a commit 74f033c
Show file tree
Hide file tree
Showing 135 changed files with 3,563 additions and 3,027 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/*
* Copyright (c) 2022 Contributors to the Eclipse Foundation
* Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
Expand All @@ -21,6 +22,8 @@
*/
public class PoolingException extends Exception {

private static final long serialVersionUID = 1L;

public PoolingException() {
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,23 @@

package com.sun.enterprise.connectors;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Properties;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;

import javax.naming.NamingException;
import javax.naming.Reference;

import org.glassfish.connectors.config.ResourceAdapterConfig;
import org.glassfish.hk2.api.PerLookup;
import org.glassfish.resourcebase.resources.api.ResourceInfo;
import org.jvnet.hk2.annotations.Service;
import org.jvnet.hk2.config.types.Property;

import com.sun.appserv.connectors.internal.api.ConnectorConstants;
import com.sun.appserv.connectors.internal.api.ConnectorRuntimeException;
import com.sun.appserv.connectors.internal.api.WorkContextHandler;
Expand All @@ -38,23 +55,6 @@
import jakarta.resource.spi.ResourceAdapterAssociation;
import jakarta.resource.spi.ResourceAdapterInternalException;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Properties;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;

import javax.naming.NamingException;
import javax.naming.Reference;

import org.glassfish.connectors.config.ResourceAdapterConfig;
import org.glassfish.hk2.api.PerLookup;
import org.glassfish.resourcebase.resources.api.ResourceInfo;
import org.jvnet.hk2.annotations.Service;
import org.jvnet.hk2.config.types.Property;

/**
* This class represents a live outbound resource adapter (1.5 compliant) i.e.
* <p/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@

package com.sun.enterprise.connectors;

import java.util.Collection;
import java.util.logging.Level;
import java.util.logging.Logger;

import org.glassfish.api.admin.ProcessEnvironment;
import org.glassfish.hk2.api.ServiceLocator;
import org.jvnet.hk2.annotations.Service;

import com.sun.appserv.connectors.internal.api.ConnectorConstants;
import com.sun.appserv.connectors.internal.api.ConnectorRuntimeException;
import com.sun.enterprise.deployment.ConnectorDescriptor;
Expand All @@ -27,14 +35,6 @@
import jakarta.inject.Singleton;
import jakarta.resource.spi.ResourceAdapter;

import java.util.Collection;
import java.util.logging.Level;
import java.util.logging.Logger;

import org.glassfish.api.admin.ProcessEnvironment;
import org.glassfish.hk2.api.ServiceLocator;
import org.jvnet.hk2.annotations.Service;

/**
* Factory creating Active Resource adapters.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/*
* Copyright (c) 2022 Contributors to the Eclipse Foundation
* Copyright (c) 1997, 2020 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
Expand All @@ -16,14 +17,14 @@

package com.sun.enterprise.connectors;

import org.jvnet.hk2.annotations.Contract;

import com.sun.appserv.connectors.internal.api.ConnectorRuntimeException;
import com.sun.enterprise.deployment.ConnectorDescriptor;

import jakarta.resource.spi.ManagedConnectionFactory;
import jakarta.resource.spi.ResourceAdapter;

import org.jvnet.hk2.annotations.Contract;


/**
* Interface class for different types (1.0 and 1.5 complient) resource
Expand All @@ -44,7 +45,7 @@ public interface ActiveResourceAdapter {
* @param loader classloader for the RAR
* @throws ConnectorRuntimeException when unable to initialize the runtime RA
*/
public void init(ResourceAdapter ra, ConnectorDescriptor cd, String moduleName, ClassLoader loader)
void init(ResourceAdapter ra, ConnectorDescriptor cd, String moduleName, ClassLoader loader)
throws ConnectorRuntimeException;

/**
Expand All @@ -53,27 +54,27 @@ public void init(ResourceAdapter ra, ConnectorDescriptor cd, String moduleName,
* @throws ConnectorRuntimeException This exception is thrown if the
* setup/initialization fails.
*/
public void setup() throws ConnectorRuntimeException;
void setup() throws ConnectorRuntimeException;

/**
* uninitializes the resource adapter.
*/
public void destroy();
void destroy();

/**
* Returns the Connector descriptor which represents/holds ra.xml
*
* @return ConnectorDescriptor Representation of ra.xml.
*/
public ConnectorDescriptor getDescriptor();
ConnectorDescriptor getDescriptor();

/**
* Indicates whether a particular implementation of ActiveRA can handle the RAR in question.
* @param desc ConnectorDescriptor
* @param moduleName resource adapter name
* @return boolean indiating whether a ActiveRA can handle the RAR
*/
public boolean handles(ConnectorDescriptor desc, String moduleName);
boolean handles(ConnectorDescriptor desc, String moduleName);

/**
* Creates managed Connection factories corresponding to one pool.
Expand All @@ -87,7 +88,7 @@ public void init(ResourceAdapter ra, ConnectorDescriptor cd, String moduleName,
* @param loader Classloader used to managed connection factory class.
* @return ManagedConnectionFactory created managed connection factories
*/
public ManagedConnectionFactory[] createManagedConnectionFactories
ManagedConnectionFactory[] createManagedConnectionFactories
(ConnectorConnectionPool ccp, ClassLoader loader);

/**
Expand All @@ -100,23 +101,23 @@ public void init(ResourceAdapter ra, ConnectorDescriptor cd, String moduleName,
* @return ManagedConnectionFactory created managed connection factory
* instance
*/
public ManagedConnectionFactory createManagedConnectionFactory
ManagedConnectionFactory createManagedConnectionFactory
(ConnectorConnectionPool ccp, ClassLoader loader);

/**
* Returns the class loader that is used to load the RAR.
*
* @return <code>ClassLoader</code> object.
*/
public ClassLoader getClassLoader();
ClassLoader getClassLoader();

/**
* Returns the module Name of the RAR
*
* @return A <code>String</code> representing the name of the
* connector module
*/
public String getModuleName();
String getModuleName();

/**
* returns the resource-adapter bean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@

package com.sun.enterprise.connectors;

import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;

import org.glassfish.hk2.api.PerLookup;
import org.glassfish.resourcebase.resources.api.PoolInfo;
import org.glassfish.resourcebase.resources.api.ResourceInfo;
import org.jvnet.hk2.annotations.Service;

import com.sun.appserv.connectors.internal.api.ConnectorConstants;
import com.sun.appserv.connectors.internal.api.ConnectorRuntimeException;
import com.sun.appserv.connectors.internal.api.ConnectorsUtil;
Expand All @@ -35,15 +44,6 @@

import jakarta.resource.spi.ManagedConnectionFactory;

import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;

import org.glassfish.hk2.api.PerLookup;
import org.glassfish.resourcebase.resources.api.PoolInfo;
import org.glassfish.resourcebase.resources.api.ResourceInfo;
import org.jvnet.hk2.annotations.Service;


/**
* This class represents the abstraction of a 1.0 compliant rar.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/*
* Copyright (c) 2022 Contributors to the Eclipse Foundation
* Copyright (c) 1997, 2020 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
Expand All @@ -16,21 +17,22 @@

package com.sun.enterprise.connectors;

import java.io.Serializable;
import java.util.Timer;
import java.util.logging.Level;
import java.util.logging.Logger;

import javax.naming.InitialContext;

import com.sun.appserv.connectors.internal.api.ConnectorRuntimeException;
import com.sun.appserv.connectors.internal.api.WorkContextHandler;
import com.sun.logging.LogDomains;

import jakarta.resource.spi.BootstrapContext;
import jakarta.resource.spi.XATerminator;
import jakarta.resource.spi.work.WorkManager;
import jakarta.resource.spi.work.WorkContext;
import jakarta.resource.spi.work.WorkManager;
import jakarta.transaction.TransactionSynchronizationRegistry;
import javax.naming.InitialContext;

import java.io.Serializable;
import java.util.Timer;
import java.util.logging.Logger;
import java.util.logging.Level;


/**
Expand Down Expand Up @@ -88,6 +90,7 @@ public BootstrapContextImpl (String poolId, String moduleName, ClassLoader rarCL
*
* @return <code>java.util.Timer</code> object.
*/
@Override
public Timer createTimer() {
// set the timer as 'daemon' such that RAs that do not cancel the timer during
// ra.stop() will not block (eg : server shutdown)
Expand All @@ -97,6 +100,7 @@ public Timer createTimer() {
/**
* {@inheritDoc}
*/
@Override
public boolean isContextSupported(Class<? extends WorkContext> aClass) {
WorkContextHandler wch = ConnectorRuntime.getRuntime().getWorkContextHandler();
wch.init(moduleName, rarCL);
Expand All @@ -106,6 +110,7 @@ public boolean isContextSupported(Class<? extends WorkContext> aClass) {
/**
* {@inheritDoc}
*/
@Override
public TransactionSynchronizationRegistry getTransactionSynchronizationRegistry() {
try{
InitialContext ic = new InitialContext();
Expand All @@ -125,6 +130,7 @@ public TransactionSynchronizationRegistry getTransactionSynchronizationRegistry(
* @see com.sun.enterprise.connectors.work.CommonWorkManager
* @see com.sun.enterprise.connectors.work.WorkManagerFactoryImpl
*/
@Override
public WorkManager getWorkManager() {
initializeWorkManager();
return wm;
Expand All @@ -147,6 +153,7 @@ private void initializeWorkManager() {
/**
* Retrieves the <code>XATerminator</code> object.
*/
@Override
public XATerminator getXATerminator() {
initializeXATerminator();
return xa;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/*
* Copyright (c) 2022 Contributors to the Eclipse Foundation
* Copyright (c) 1997, 2020 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
Expand All @@ -16,14 +17,16 @@

package com.sun.enterprise.connectors;

import com.sun.appserv.connectors.internal.api.ConnectorRuntimeException;
import com.sun.logging.LogDomains;
import java.util.logging.Level;
import java.util.logging.Logger;

import org.glassfish.resourcebase.resources.api.PoolInfo;
import org.glassfish.resourcebase.resources.api.ResourceInfo;

import com.sun.appserv.connectors.internal.api.ConnectorRuntimeException;
import com.sun.logging.LogDomains;

import jakarta.resource.spi.ConnectionManager;
import java.util.logging.Level;
import java.util.logging.Logger;

/* Authors : Binod P G, Aditya Gore
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,18 @@

package com.sun.enterprise.connectors;

import java.io.Serializable;
import java.security.Principal;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;

import javax.security.auth.Subject;

import org.glassfish.resourcebase.resources.api.PoolInfo;
import org.glassfish.resourcebase.resources.api.ResourceConstants;
import org.glassfish.resourcebase.resources.api.ResourceInfo;

import com.sun.appserv.connectors.internal.api.ConnectorConstants;
import com.sun.appserv.connectors.internal.api.ConnectorRuntimeException;
import com.sun.appserv.connectors.internal.api.ConnectorsUtil;
Expand All @@ -39,20 +51,14 @@
import com.sun.enterprise.security.SecurityContext;
import com.sun.enterprise.util.i18n.StringManager;
import com.sun.logging.LogDomains;
import org.glassfish.resourcebase.resources.api.PoolInfo;
import org.glassfish.resourcebase.resources.api.ResourceConstants;
import org.glassfish.resourcebase.resources.api.ResourceInfo;

import jakarta.resource.ResourceException;
import jakarta.resource.spi.*;
import jakarta.resource.spi.ConnectionRequestInfo;
import jakarta.resource.spi.IllegalStateException;
import jakarta.resource.spi.ManagedConnectionFactory;
import jakarta.resource.spi.ResourceAllocationException;
import jakarta.resource.spi.RetryableUnavailableException;
import jakarta.resource.spi.SecurityException;
import javax.security.auth.Subject;
import java.io.Serializable;
import java.security.Principal;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;


/**
Expand Down Expand Up @@ -252,16 +258,14 @@ protected Object internalGetConnection(ManagedConnectionFactory mcf,
//create non-null Subject associated with no credentials
//System.out.println("RAR name "+ rarName);
subject = ConnectionPoolObjectsUtils.createSubject(mcf, null);
} else if (prin == null) {
info = new ClientSecurityInfo(cxRequestInfo);
} else {
if (prin == null) {
info = new ClientSecurityInfo(cxRequestInfo);
info = new ClientSecurityInfo(prin);
if (prin.equals(defaultPrin)) {
subject = pmd.getSubject();
} else {
info = new ClientSecurityInfo(prin);
if (prin.equals(defaultPrin)) {
subject = pmd.getSubject();
} else {
subject = ConnectionPoolObjectsUtils.createSubject(mcf, prin);
}
subject = ConnectionPoolObjectsUtils.createSubject(mcf, prin);
}
}

Expand Down

0 comments on commit 74f033c

Please sign in to comment.