use of com.sun.enterprise.connectors.ConnectorConnectionPool in project Payara by payara.
the class JdbcConnectionPoolDeployer method actualDeployResource.
/**
* Deploy the resource into the server's runtime naming context
*
* @param resource a resource object
* @throws Exception thrown if fail
*/
public void actualDeployResource(Object resource, PoolInfo poolInfo) {
if (_logger.isLoggable(Level.FINE)) {
_logger.fine(" JdbcConnectionPoolDeployer - actualDeployResource : " + poolInfo);
}
JdbcConnectionPool adminPool = (JdbcConnectionPool) resource;
try {
ConnectorConnectionPool connConnPool = createConnectorConnectionPool(adminPool, poolInfo);
registerTransparentDynamicReconfigPool(poolInfo, adminPool);
// now do internal book keeping
runtime.createConnectorConnectionPool(connConnPool);
} catch (Exception e) {
Object[] params = new Object[] { poolInfo, e };
_logger.log(Level.WARNING, "error.creating.jdbc.pool", params);
}
}
use of com.sun.enterprise.connectors.ConnectorConnectionPool in project Payara by payara.
the class ConnectionPool method setPoolConfiguration.
private void setPoolConfiguration(Hashtable env) throws PoolingException {
ConnectorConnectionPool poolResource = getPoolConfigurationFromJndi(env);
idletime = Integer.parseInt(poolResource.getIdleTimeoutInSeconds()) * 1000L;
maxPoolSize = Integer.parseInt(poolResource.getMaxPoolSize());
steadyPoolSize = Integer.parseInt(poolResource.getSteadyPoolSize());
if (maxPoolSize < steadyPoolSize) {
maxPoolSize = steadyPoolSize;
}
resizeQuantity = Integer.parseInt(poolResource.getPoolResizeQuantity());
maxWaitTime = Integer.parseInt(poolResource.getMaxWaitTimeInMillis());
// Make sure it's not negative.
if (maxWaitTime < 0) {
maxWaitTime = 0;
}
failAllConnections = poolResource.isFailAllConnections();
validation = poolResource.isIsConnectionValidationRequired();
validateAtmostEveryIdleSecs = poolResource.isValidateAtmostEveryIdleSecs();
dataStructureType = poolResource.getPoolDataStructureType();
dataStructureParameters = poolResource.getDataStructureParameters();
poolWaitQueueClass = poolResource.getPoolWaitQueue();
resourceSelectionStrategyClass = poolResource.getResourceSelectionStrategyClass();
resourceGatewayClass = poolResource.getResourceGatewayClass();
reconfigWaitTime = poolResource.getDynamicReconfigWaitTimeout();
setAdvancedPoolConfiguration(poolResource);
}
use of com.sun.enterprise.connectors.ConnectorConnectionPool in project Payara by payara.
the class ConnectorAdminServiceUtils method getDefaultResourcePrincipal.
/*
* Returns a ResourcePrincipal object populated with a pool's
* default USERNAME and PASSWORD
*
* @throws NamingException if poolname lookup fails
*/
public static ResourcePrincipal getDefaultResourcePrincipal(PoolInfo poolInfo) throws NamingException {
// All this to get the default user name and principal
ConnectorConnectionPool connectorConnectionPool = null;
try {
String jndiNameForPool = getReservePrefixedJNDINameForPool(poolInfo);
Context ic = ConnectorRuntime.getRuntime().getNamingManager().getInitialContext();
connectorConnectionPool = (ConnectorConnectionPool) ic.lookup(jndiNameForPool);
} catch (NamingException ne) {
throw ne;
}
ConnectorDescriptorInfo cdi = connectorConnectionPool.getConnectorDescriptorInfo();
Set mcfConfigProperties = cdi.getMCFConfigProperties();
Iterator mcfConfPropsIter = mcfConfigProperties.iterator();
String userName = "";
String password = "";
while (mcfConfPropsIter.hasNext()) {
ConnectorConfigProperty prop = (ConnectorConfigProperty) mcfConfPropsIter.next();
if (prop.getName().toUpperCase(Locale.getDefault()).equals("USERNAME") || prop.getName().toUpperCase(Locale.getDefault()).equals("USER")) {
userName = prop.getValue();
} else if (prop.getName().toUpperCase(Locale.getDefault()).equals("PASSWORD")) {
password = prop.getValue();
}
}
// Now return the ResourcePrincipal
return new ResourcePrincipal(userName, password);
}
use of com.sun.enterprise.connectors.ConnectorConnectionPool in project Payara by payara.
the class ConnectorResourceAdminServiceImpl method createConnectorResource.
/**
* Creates the connector resource on a given connection pool
*
* @param resourceInfo JNDI name of the resource to be created
* @param poolInfo PoolName to which the connector resource belongs.
* @param resourceType Resource type Unused.
* @throws ConnectorRuntimeException If the resouce creation fails.
*/
public void createConnectorResource(ResourceInfo resourceInfo, PoolInfo poolInfo, String resourceType) throws ConnectorRuntimeException {
try {
ConnectorConnectionPool ccp = null;
String jndiNameForPool = ConnectorAdminServiceUtils.getReservePrefixedJNDINameForPool(poolInfo);
try {
ccp = (ConnectorConnectionPool) namingService.lookup(poolInfo, jndiNameForPool);
} catch (NamingException ne) {
// Probably the pool is not yet initialized (lazy-loading), try doing a lookup
try {
checkAndLoadPool(poolInfo);
ccp = (ConnectorConnectionPool) namingService.lookup(poolInfo, jndiNameForPool);
} catch (NamingException e) {
Object[] params = new Object[] { poolInfo, e };
_logger.log(Level.SEVERE, "unable.to.lookup.pool", params);
}
}
if (ccp == null) {
ccp = (ConnectorConnectionPool) namingService.lookup(poolInfo, jndiNameForPool);
}
ConnectorDescriptorInfo cdi = ccp.getConnectorDescriptorInfo();
javax.naming.Reference ref = new javax.naming.Reference(cdi.getConnectionFactoryClass(), "com.sun.enterprise.resource.naming.ConnectorObjectFactory", null);
RefAddr addr = new SerializableObjectRefAddr(PoolInfo.class.getName(), poolInfo);
ref.add(addr);
addr = new StringRefAddr("rarName", cdi.getRarName());
ref.add(addr);
RefAddr resAddr = new SerializableObjectRefAddr(ResourceInfo.class.getName(), resourceInfo);
ref.add(resAddr);
try {
namingService.publishObject(resourceInfo, ref, true);
_registry.addResourceInfo(resourceInfo);
} catch (NamingException ne) {
ConnectorRuntimeException cre = new ConnectorRuntimeException(ne.getMessage());
cre.initCause(ne);
Object[] params = new Object[] { resourceInfo, cre };
_logger.log(Level.SEVERE, "rardeployment.resource_jndi_bind_failure", params);
throw cre;
}
/*
ConnectorObjectFactory cof = new ConnectorObjectFactory(jndiName, ccp.getConnectorDescriptorInfo().
getConnectionFactoryClass(), cdi.getRarName(), poolName);
_runtime.getNamingManager().publishObject(jndiName, cof, true);
*/
// To notify that a connector resource rebind has happened.
ConnectorResourceNamingEventNotifier.getInstance().notifyListeners(new ConnectorNamingEvent(resourceInfo.toString(), ConnectorNamingEvent.EVENT_OBJECT_REBIND));
} catch (NamingException ne) {
ConnectorRuntimeException cre = new ConnectorRuntimeException(ne.getMessage());
cre.initCause(ne);
Object[] params = new Object[] { resourceInfo, cre };
_logger.log(Level.SEVERE, "rardeployment.jndi_lookup_failed", params);
throw cre;
}
}
use of com.sun.enterprise.connectors.ConnectorConnectionPool in project Payara by payara.
the class ConnectionPoolObjectsUtils method createSunRaConnectorPoolObject.
/**
* Creates ConnectorConnectionPool object pertaining to the pool props
* mentioned in the sun-ra/xml i.e it represents the pool mentioned in the
* sun-ra.xm.
*
* @param poolInfo Name of the pool
* @param desc ConnectorDescriptor which represent ra.xml and sun-ra.xml.
* @return ConnectorConnectionPool created ConnectorConnectionPool instance
*/
public static ConnectorConnectionPool createSunRaConnectorPoolObject(PoolInfo poolInfo, ConnectorDescriptor desc, String rarName) {
ConnectorConnectionPool connectorPoolObj = new ConnectorConnectionPool(poolInfo);
SunConnector sundesc = desc.getSunDescriptor();
ResourceAdapter sunRAXML = sundesc.getResourceAdapter();
connectorPoolObj.setMaxPoolSize((String) sunRAXML.getValue(ResourceAdapter.MAX_POOL_SIZE));
connectorPoolObj.setSteadyPoolSize((String) sunRAXML.getValue(ResourceAdapter.STEADY_POOL_SIZE));
connectorPoolObj.setMaxWaitTimeInMillis((String) sunRAXML.getValue(ResourceAdapter.MAX_WAIT_TIME_IN_MILLIS));
connectorPoolObj.setIdleTimeoutInSeconds((String) sunRAXML.getValue(ResourceAdapter.IDLE_TIMEOUT_IN_SECONDS));
connectorPoolObj.setPoolResizeQuantity((String) "2");
connectorPoolObj.setFailAllConnections(false);
// always
connectorPoolObj.setMatchConnections(true);
setDefaultAdvancedPoolAttributes(connectorPoolObj);
try {
connectorPoolObj.setTransactionSupport(getTransactionSupportFromRaXml(rarName));
} catch (Exception ex) {
if (_logger.isLoggable(Level.FINE)) {
_logger.fine("error in setting txSupport");
}
}
boolean validateAtmostEveryIdleSecs = false;
// For SunRAPool, get the value of system property VALIDATE_ATMOST_EVERY_IDLE_SECS.
if (validateAtmostEveryIdleSecsProperty != null && validateAtmostEveryIdleSecsProperty.equalsIgnoreCase("TRUE")) {
validateAtmostEveryIdleSecs = true;
if (_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, "CCP.ValidateAtmostEveryIdleSecs.Set", poolInfo);
}
}
connectorPoolObj.setValidateAtmostEveryIdleSecs(validateAtmostEveryIdleSecs);
return connectorPoolObj;
}
Aggregations