Class ConnectorConnectionPoolAdminServiceImpl
- java.lang.Object
-
- com.sun.enterprise.connectors.service.ConnectorService
-
- com.sun.enterprise.connectors.service.ConnectorConnectionPoolAdminServiceImpl
-
- All Implemented Interfaces:
ConnectorConstants
,ResourceConstants
public class ConnectorConnectionPoolAdminServiceImpl extends ConnectorService
Connector connection pool admin service performs the functionality of creation, deletion, recreation, testing of the pools.- Author:
- Srikanth P and Aditya Gore
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.sun.appserv.connectors.internal.api.ConnectorConstants
ConnectorConstants.PoolType
-
Nested classes/interfaces inherited from interface org.glassfish.resourcebase.resources.api.ResourceConstants
ResourceConstants.TriState
-
-
Field Summary
-
Fields inherited from class com.sun.enterprise.connectors.service.ConnectorService
_logger, _registry, _runtime
-
Fields inherited from interface com.sun.appserv.connectors.internal.api.ConnectorConstants
ACCESS_ALL_RARS, ADMINISTERED_OBJECT_FACTORY, AIRA, AO, AOR, AORA, CAUTION_MESSAGE, CCP, CLASSLOADING_POLICY_DERIVED_ACCESS, CLASSLOADING_POLICY_GLOBAL_ACCESS, CONNECTOR_MESSAGE_BEAN_CLIENT_FACTORY, CONNECTOR_MODULE, CR, DD_PREFIX, DEFAULT_JMS_ADAPTER, DEFAULT_RESOURCE_ADAPTER_SHUTDOWN_TIMEOUT, DYNAMIC_RECONFIGURATION_FLAG, DYNAMIC_RECONFIGURATION_PROXY_CALL, EXPLODED_EMBEDDED_RAR_EXTENSION, HIDDEN_CLI_NAME_VALUE_PAIR_DELIMITER, INSTALL_ROOT, JAVA_BEAN_FACTORY_CLASS, JAVA_SQL_DRIVER, JAVAX_SQL_CONNECTION_POOL_DATASOURCE, JAVAX_SQL_DATASOURCE, JAVAX_SQL_XA_DATASOURCE, JAXR_RA_NAME, JDBC, JDBCCONNECTIONPOOLDATASOURCE_RA_NAME, JDBCDATASOURCE_RA_NAME, JDBCDRIVER_RA_NAME, jdbcSystemRarNames, JDBCXA_RA_NAME, JMS_POOL_MAXSIZE, JMS_POOL_MINSIZE, JNDI_SUFFIX_PROPERTY, JNDI_SUFFIX_VALUES, LOCAL_TRANSACTION_INT, LOCAL_TRANSACTION_TX_SUPPORT_STRING, MCF, MONITORING_CONNECTION_FACTORIES, MONITORING_CONNECTOR_SERVICE, MONITORING_CONNECTOR_SERVICE_MODULE_NAME, MONITORING_JMS_SERVICE, MONITORING_JMS_SERVICE_MODULE_NAME, MONITORING_SEPARATOR, MONITORING_WORK_MANAGEMENT, MSL, NO_TRANSACTION_INT, NO_TRANSACTION_TX_SUPPORT_STRING, NON_TX_JNDI_SUFFIX, PM_JNDI_SUFFIX, POOLNAME_APPENDER, POOLS_JNDINAME_PREFIX, PRIMITIVES_AND_STRING_FACTORY_CLASS, PROPERTIES_FACTORY, RA, RAR, RAR_EXTENSION, RAR_VISIBILITY, RAR_VISIBILITY_GLOBAL_ACCESS, REQUIRED_RARS_FOR_APP_PREFIX, RESERVE_PREFIX, RESOURCE_JNDINAME_PREFIX, RESOURCENAME_APPENDER, SEC, SECURITYMAPMETACHAR, SUN_RA_POOL, systemRarNames, systemRarsAllowingPoolCreation, sysThrowExcp, THROW_TRANSACTED_EXCEPTIONS, THROW_TRANSACTED_EXCEPTIONS_PROP, UNDEFINED_TRANSACTION_INT, URL_OBJECTS_FACTORY, USERGROUPDISTINGUISHER, XA_TRANSACTION_INT, XA_TRANSACTION_TX_SUPPORT_STRING
-
Fields inherited from interface org.glassfish.resourcebase.resources.api.ResourceConstants
ADMINISTERED_OBJECT_DEFINITION_JNDINAME_PREFIX, APP_META_DATA_RESOURCES, APP_SCOPED_RESOURCES_JNDI_NAMES, APP_SCOPED_RESOURCES_MAP, APP_SCOPED_RESOURCES_RA_NAMES, CONNECTION_FACTORY_DEFINITION_JNDINAME_PREFIX, CONNECTOR_RESOURCES, DATASOURCE_DEFINITION_JNDINAME_PREFIX, EMBEDDEDRAR_NAME_DELIMITER, EXT_JNDI_RES_TYPE, GF_RESOURCES_LOCATION, GF_RESOURCES_MODULE, GF_RESOURCES_MODULE_EAR, JAVA_APP_SCOPE_PREFIX, JAVA_COMP_ENV_SCOPE_PREFIX, JAVA_COMP_SCOPE_PREFIX, JAVA_GLOBAL_SCOPE_PREFIX, JAVA_MODULE_SCOPE_PREFIX, JAVA_SCOPE_PREFIX, JMS_CONNECTION_FACTORY_DEFINITION_JNDINAME_PREFIX, JMS_DESTINATION_DEFINITION_JNDINAME_PREFIX, JMS_MESSAGE_LISTENER, JMS_QUEUE, JMS_QUEUE_CONNECTION_FACTORY, JMS_TOPIC, JMS_TOPIC_CONNECTION_FACTORY, MAILSESSION_DEFINITION_JNDINAME_PREFIX, NON_CONNECTOR_RESOURCES, PAYARA_RESOURCES_LOCATION, PY_RESOURCES_MODULE, PY_RESOURCES_MODULE_EAR, RES_TYPE_AOR, RES_TYPE_CCP, RES_TYPE_CR, RES_TYPE_CUSTOM, RES_TYPE_CWSM, RES_TYPE_EXTERNAL_JNDI, RES_TYPE_JCP, RES_TYPE_JDBC, RES_TYPE_MAIL, RES_TYPE_RAC
-
-
Constructor Summary
Constructors Constructor Description ConnectorConnectionPoolAdminServiceImpl()
Default constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
createConnectorConnectionPool(ConnectorConnectionPool connectorPoolObj)
Creates connector connection pool in the connector container.void
createConnectorConnectionPool(ConnectorConnectionPool ccp, String connectionDefinitionName, String rarName, List<Property> props, List<SecurityMap> securityMaps)
Creates connector connection pool in the connector container.void
deleteConnectorConnectionPool(PoolInfo poolInfo)
Deletes connector Connection poolvoid
deleteConnectorConnectionPool(PoolInfo poolInfo, boolean cascade)
Deletes connector Connection pool.boolean
flushConnectionPool(PoolInfo poolInfo)
Flush Connection pool by reinitializing the connections established in the pool.Connection
getConnection(ResourceInfo resourceInfo)
Get a sql connection from the DataSource specified by the jdbcJndiName.Connection
getConnection(ResourceInfo resourceInfo, String user, String password)
Get a sql connection from the DataSource specified by the jdbcJndiName.static Map<String,Object>
getConnectionDefinitionPropertiesAndDefaults(String connectionDefinitionClassName, String resType)
Gets the properties of the Java bean connection definition class that have setter methods defined and the default values as provided by the Connection Definition java bean developer.protected Subject
getDefaultSubject(PoolInfo poolInfo, jakarta.resource.spi.ManagedConnectionFactory mcf, ResourcePrincipal prin)
Utility method that is used to get the default subject for the specified mcf and resource principal.protected jakarta.resource.spi.ManagedConnection
getManagedConnection(jakarta.resource.spi.ManagedConnectionFactory mcf, Subject defaultSubject, jakarta.resource.spi.ConnectionRequestInfo cReqInfo)
Utility method to get Managed connection from the supplied mcf and default subject.ConnectorConstants.PoolType
getPoolType(PoolInfo poolInfo)
String
getPropertyValue(String prop, ConnectorConnectionPool connectorConnectionPool)
Utility method to get property value from ConnectorDescriptorInfo.Object
getUnpooledConnection(PoolInfo poolInfo, ResourcePrincipal principal, boolean returnConnectionHandle)
This method is used to provide backend functionality for the ping-connection-pool asadmin command.boolean
isConnectorConnectionPoolDeployed(PoolInfo poolInfo)
Checks if a conncetor connection pool has been deployed to this server instancevoid
killPool(PoolInfo poolInfo)
Kills a specific pooljakarta.resource.spi.ManagedConnectionFactory[]
obtainManagedConnectionFactories(PoolInfo poolInfo)
Returns the MCF instances.jakarta.resource.spi.ManagedConnectionFactory
obtainManagedConnectionFactory(PoolInfo poolInfo)
jakarta.resource.spi.ManagedConnectionFactory
obtainManagedConnectionFactory(PoolInfo poolInfo, Hashtable env)
Returns the MCF instance.boolean
reconfigureConnectorConnectionPool(ConnectorConnectionPool ccp, Set excludedProps)
Reconfigure a connection pool.void
recreateConnectorConnectionPool(ConnectorConnectionPool ccp)
Recreate a connector connection pool.void
switchOnMatching(PoolInfo poolInfo)
Rebinds the connection pool with matchning flag set.boolean
testConnectionPool(PoolInfo poolInfo)
asadmin test-connection-pool This method is used to provide backend functionality for the test-connection-pool asadmin command.-
Methods inherited from class com.sun.enterprise.connectors.service.ConnectorService
checkAccessibility, checkAndLoadPool, createActiveResourceAdapterForEmbeddedRar, getConnectorDescriptor, getDefaultPoolName, getDefaultResourceName, getResourcesUtil, ifSystemRarLoad, loadDeferredResourceAdapter, loadDeferredResources, loadResourcesAndItsRar, switchOnMatching
-
-
-
-
Method Detail
-
createConnectorConnectionPool
public void createConnectorConnectionPool(ConnectorConnectionPool connectorPoolObj) throws ConnectorRuntimeException
Creates connector connection pool in the connector container.- Parameters:
connectorPoolObj
- ConnectorConnectionPool instance to be bound to JNDI. This object contains the pool properties.- Throws:
ConnectorRuntimeException
- When creation of pool fails.
-
deleteConnectorConnectionPool
public void deleteConnectorConnectionPool(PoolInfo poolInfo) throws ConnectorRuntimeException
Deletes connector Connection pool- Parameters:
poolInfo
- Name of the pool to delete- Throws:
ConnectorRuntimeException
- if pool deletion operation fails
-
deleteConnectorConnectionPool
public void deleteConnectorConnectionPool(PoolInfo poolInfo, boolean cascade) throws ConnectorRuntimeException
Deletes connector Connection pool. Here check in made whether resources pertaining to pool are present in domain.xml.- Parameters:
poolInfo
- Name of the pool to deletecascade
- If true all the resources associed with that are also deleted from connector container If false and if some resources pertaining to pool are present deletion operation fails . If no resources are present pool is deleted.- Throws:
ConnectorRuntimeException
- if pool deletion operation fails
-
killPool
public void killPool(PoolInfo poolInfo)
Kills a specific pool- Parameters:
poolInfo
- poolName to kill
-
getConnectionDefinitionPropertiesAndDefaults
public static Map<String,Object> getConnectionDefinitionPropertiesAndDefaults(String connectionDefinitionClassName, String resType)
Gets the properties of the Java bean connection definition class that have setter methods defined and the default values as provided by the Connection Definition java bean developer.- Parameters:
connectionDefinitionClassName
- The Connection Definition Java bean class for which overrideable properties are required.- Returns:
- Map
String represents property name and Object is the defaultValue that is a primitive type or String
-
testConnectionPool
public boolean testConnectionPool(PoolInfo poolInfo) throws jakarta.resource.ResourceException
asadmin test-connection-pool This method is used to provide backend functionality for the test-connection-pool asadmin command. Briefly the design is as follows:
1. obtainManagedConnection for the poolname
2. lookup ConnectorDescriptorInfo from InitialContext using poolname
3. from cdi get username and password
4. create ResourcePrincipal using default username and password
5. create a Subject from this (doPriveleged)
6. createManagedConnection using above subject
7. getConnection from the ManagedConnection with above subject- Parameters:
poolInfo
- connection-pool name- Returns:
- true if the connection pool is healthy. false otherwise
- Throws:
jakarta.resource.ResourceException
- if pool is not usable
-
getDefaultSubject
protected Subject getDefaultSubject(PoolInfo poolInfo, jakarta.resource.spi.ManagedConnectionFactory mcf, ResourcePrincipal prin) throws jakarta.resource.ResourceException
Utility method that is used to get the default subject for the specified mcf and resource principal.- Parameters:
poolInfo
-mcf
-prin
-- Returns:
- Throws:
jakarta.resource.ResourceException
-
getManagedConnection
protected jakarta.resource.spi.ManagedConnection getManagedConnection(jakarta.resource.spi.ManagedConnectionFactory mcf, Subject defaultSubject, jakarta.resource.spi.ConnectionRequestInfo cReqInfo) throws jakarta.resource.ResourceException
Utility method to get Managed connection from the supplied mcf and default subject.- Parameters:
mcf
-defaultSubject
-- Returns:
- Throws:
jakarta.resource.ResourceException
-
getUnpooledConnection
public Object getUnpooledConnection(PoolInfo poolInfo, ResourcePrincipal principal, boolean returnConnectionHandle) throws jakarta.resource.ResourceException
This method is used to provide backend functionality for the ping-connection-pool asadmin command. Briefly the design is as follows:
1. obtainManagedConnectionFactory for the poolname
2. lookup ConnectorDescriptorInfo from InitialContext using poolname
3. from cdi get username and password
4. create ResourcePrincipal using default username and password
5. create a Subject from this (doPriveleged)
6. createManagedConnection using above subject
7. add a dummy ConnectionEventListener to the mc that simply handles connectionClosed 8. getConnection from the ManagedConnection with above subject- Parameters:
poolInfo
- The poolname from whose MCF to obtain the unpooled mcprincipal
- The ResourcePrincipal to use for authenticating the request if not null. If null, the pool's default authentication mechanism is usedreturnConnectionHandle
- If true will return the logical connection handle derived from the Managed Connection, else will only return mc- Returns:
- an unPooled connection
- Throws:
jakarta.resource.ResourceException
- for various error conditions
-
getPropertyValue
public String getPropertyValue(String prop, ConnectorConnectionPool connectorConnectionPool)
Utility method to get property value from ConnectorDescriptorInfo.- Parameters:
prop
-- Returns:
-
switchOnMatching
public void switchOnMatching(PoolInfo poolInfo) throws ConnectorRuntimeException
Rebinds the connection pool with matchning flag set.- Parameters:
poolInfo
- pool for which matching need to be switched on- Throws:
ConnectorRuntimeException
- , if a Naming error occurs.
-
obtainManagedConnectionFactories
public jakarta.resource.spi.ManagedConnectionFactory[] obtainManagedConnectionFactories(PoolInfo poolInfo) throws ConnectorRuntimeException
Returns the MCF instances.- Parameters:
poolInfo
- Name of the pool.MCF pertaining to this pool is created/returned.- Returns:
- created/already present MCF instance
- Throws:
ConnectorRuntimeException
- if creation/retrieval of MCF fails
-
obtainManagedConnectionFactory
public jakarta.resource.spi.ManagedConnectionFactory obtainManagedConnectionFactory(PoolInfo poolInfo) throws ConnectorRuntimeException
- Throws:
ConnectorRuntimeException
-
obtainManagedConnectionFactory
public jakarta.resource.spi.ManagedConnectionFactory obtainManagedConnectionFactory(PoolInfo poolInfo, Hashtable env) throws ConnectorRuntimeException
Returns the MCF instance. If the MCF is already created and present in connectorRegistry that instance is returned. Otherwise it is created explicitly and added to ConnectorRegistry.- Parameters:
poolInfo
- Name of the pool.MCF pertaining to this pool is created/returned.- Returns:
- created/already present MCF instance
- Throws:
ConnectorRuntimeException
- if creation/retrieval of MCF fails
-
getPoolType
public ConnectorConstants.PoolType getPoolType(PoolInfo poolInfo) throws ConnectorRuntimeException
- Throws:
ConnectorRuntimeException
-
isConnectorConnectionPoolDeployed
public boolean isConnectorConnectionPoolDeployed(PoolInfo poolInfo)
Checks if a conncetor connection pool has been deployed to this server instance- Parameters:
poolInfo
-- Returns:
-
reconfigureConnectorConnectionPool
public boolean reconfigureConnectorConnectionPool(ConnectorConnectionPool ccp, Set excludedProps) throws ConnectorRuntimeException
Reconfigure a connection pool. This method compares the passed connector connection pool with the one in memory. If the pools are unequal and the MCF properties are changed a pool recreate is required. However if the pools are unequal and the MCF properties are not changed a recreate is not required- Parameters:
ccp
- - the Updated connector connection pool object that admin hands overexcludedProps
- - A set of excluded property names that we want to be excluded in the comparison check while comparing MCF properties- Returns:
- true - if a pool restart is required, false otherwise
- Throws:
ConnectorRuntimeException
-
recreateConnectorConnectionPool
public void recreateConnectorConnectionPool(ConnectorConnectionPool ccp) throws ConnectorRuntimeException
Recreate a connector connection pool. This method essentially does the following things: 1. Delete the said connector connection pool
2. Bind the pool to JNDI
3. Create an MCF for this pool and register with the connector registry- Parameters:
ccp
- - the ConnectorConnectionPool to publish- Throws:
ConnectorRuntimeException
-
createConnectorConnectionPool
public void createConnectorConnectionPool(ConnectorConnectionPool ccp, String connectionDefinitionName, String rarName, List<Property> props, List<SecurityMap> securityMaps) throws ConnectorRuntimeException
Creates connector connection pool in the connector container.- Parameters:
ccp
- ConnectorConnectionPool instance to be bound to JNDI. This object contains the pool properties.connectionDefinitionName
- Connection definition name against which connection pool is being createdrarName
- Name of the resource adapterprops
- Properties of MCF which are present in domain.xml These properties override the ones present in ra.xmlsecurityMaps
- Array fo security maps.- Throws:
ConnectorRuntimeException
- When creation of pool fails.
-
flushConnectionPool
public boolean flushConnectionPool(PoolInfo poolInfo) throws ConnectorRuntimeException
Flush Connection pool by reinitializing the connections established in the pool.- Parameters:
poolInfo
-- Throws:
ConnectorRuntimeException
-
getConnection
public Connection getConnection(ResourceInfo resourceInfo, String user, String password) throws SQLException
Get a sql connection from the DataSource specified by the jdbcJndiName. This API is intended to be used in the DAS. The motivation for having this API is to provide the CMP backend a means of acquiring a connection during the codegen phase. If a user is trying to deploy an app on a remote server, without this API, a resource reference has to be present both in the DAS and the server instance. This makes the deployment more complex for the user since a resource needs to be forcibly created in the DAS Too. This API will mitigate this need.- Parameters:
resourceInfo
- the jndi name of the resource being used to get Connection from This resource can either be a pmf resource or a jdbc resourceuser
- the user used to authenticate this requestpassword
- the password used to authenticate this request- Returns:
- a java.sql.Connection
- Throws:
SQLException
- in case of errors
-
getConnection
public Connection getConnection(ResourceInfo resourceInfo) throws SQLException
Get a sql connection from the DataSource specified by the jdbcJndiName. This API is intended to be used in the DAS. The motivation for having this API is to provide the CMP backend a means of acquiring a connection during the codegen phase. If a user is trying to deploy an app on a remote server, without this API, a resource reference has to be present both in the DAS and the server instance. This makes the deployment more complex for the user since a resource needs to be forcibly created in the DAS Too. This API will mitigate this need.- Parameters:
resourceInfo
- the jndi name of the resource being used to get Connection from This resource can either be a pmf resource or a jdbc resource- Returns:
- a java.sql.Connection
- Throws:
SQLException
- in case of errors
-
-