use of com.sun.enterprise.connectors.ConnectorDescriptorInfo in project Payara by payara.
the class JdbcConnectionPoolDeployer method createConnectorDescriptorInfo.
private ConnectorDescriptorInfo createConnectorDescriptorInfo(ConnectorDescriptor connDesc, String moduleName) {
ConnectorDescriptorInfo connDescInfo = new ConnectorDescriptorInfo();
connDescInfo.setManagedConnectionFactoryClass(connDesc.getOutboundResourceAdapter().getManagedConnectionFactoryImpl());
connDescInfo.setRarName(moduleName);
connDescInfo.setResourceAdapterClassName(connDesc.getResourceAdapterClass());
connDescInfo.setConnectionDefinitionName(connDesc.getOutboundResourceAdapter().getConnectionFactoryIntf());
connDescInfo.setConnectionFactoryClass(connDesc.getOutboundResourceAdapter().getConnectionFactoryImpl());
connDescInfo.setConnectionFactoryInterface(connDesc.getOutboundResourceAdapter().getConnectionFactoryIntf());
connDescInfo.setConnectionClass(connDesc.getOutboundResourceAdapter().getConnectionImpl());
connDescInfo.setConnectionInterface(connDesc.getOutboundResourceAdapter().getConnectionIntf());
return connDescInfo;
}
use of com.sun.enterprise.connectors.ConnectorDescriptorInfo in project Payara by payara.
the class ConnectionPoolReconfigHelper method isEqualConnectorConnectionPool.
/*
* Compare the Original ConnectorConnectionPool with the passed one
* If MCF properties are changed, indicate that pool recreation is
* required
* We only check the MCF properties since a pool restart is required
* for changes in MCF props. For pool specific properties we can get
* away without restart
* If the new pool and old pool have identical MCF properties returns
* true
*/
private static ReconfigAction isEqualConnectorConnectionPool(ConnectorConnectionPool oldCcp, ConnectorConnectionPool newCcp, Set excludedProps) {
boolean poolsEqual = true;
// have changed
if (newCcp.isPoolingOn() != oldCcp.isPoolingOn()) {
return ReconfigAction.RECREATE_POOL;
}
if (newCcp.getTransactionSupport() != oldCcp.getTransactionSupport()) {
return ReconfigAction.RECREATE_POOL;
}
if (newCcp.isAssociateWithThread() != oldCcp.isAssociateWithThread()) {
return ReconfigAction.RECREATE_POOL;
}
if (newCcp.isLazyConnectionAssoc() != oldCcp.isLazyConnectionAssoc()) {
return ReconfigAction.RECREATE_POOL;
}
if (newCcp.isPartitionedPool() != oldCcp.isPartitionedPool()) {
return ReconfigAction.RECREATE_POOL;
}
if (newCcp.getPoolDataStructureType() == null && oldCcp.getPoolDataStructureType() != null) {
return ReconfigAction.RECREATE_POOL;
}
if (newCcp.getPoolDataStructureType() != null && oldCcp.getPoolDataStructureType() == null) {
return ReconfigAction.RECREATE_POOL;
}
if (((newCcp.getPoolDataStructureType() != null) && (oldCcp.getPoolDataStructureType() != null) && !(newCcp.getPoolDataStructureType().equals(oldCcp.getPoolDataStructureType())))) {
return ReconfigAction.RECREATE_POOL;
}
if ((newCcp.getPoolWaitQueue() != null) && (oldCcp.getPoolWaitQueue() == null)) {
return ReconfigAction.RECREATE_POOL;
}
if ((newCcp.getPoolWaitQueue() == null) && (oldCcp.getPoolWaitQueue() != null)) {
return ReconfigAction.RECREATE_POOL;
}
if ((newCcp.getPoolWaitQueue() != null) && (oldCcp.getPoolWaitQueue() != null) && (!newCcp.getPoolWaitQueue().equals(oldCcp.getPoolWaitQueue()))) {
return ReconfigAction.RECREATE_POOL;
}
if ((newCcp.getDataStructureParameters() != null) && (oldCcp.getDataStructureParameters() == null)) {
return ReconfigAction.RECREATE_POOL;
}
if ((newCcp.getDataStructureParameters() == null) && (oldCcp.getDataStructureParameters() != null)) {
return ReconfigAction.RECREATE_POOL;
}
if ((newCcp.getDataStructureParameters() != null) && (oldCcp.getDataStructureParameters() != null) && !(newCcp.getDataStructureParameters().equals(oldCcp.getDataStructureParameters()))) {
return ReconfigAction.RECREATE_POOL;
}
ConnectorDescriptorInfo oldCdi = oldCcp.getConnectorDescriptorInfo();
ConnectorDescriptorInfo newCdi = newCcp.getConnectorDescriptorInfo();
if (!oldCdi.getResourceAdapterClassName().equals(newCdi.getResourceAdapterClassName())) {
logFine("isEqualConnectorConnectionPool: getResourceAdapterClassName:: " + oldCdi.getResourceAdapterClassName() + " -- " + newCdi.getResourceAdapterClassName());
return ReconfigAction.RECREATE_POOL;
}
if (!oldCdi.getConnectionDefinitionName().equals(newCdi.getConnectionDefinitionName())) {
logFine("isEqualConnectorConnectionPool: getConnectionDefinitionName:: " + oldCdi.getConnectionDefinitionName() + " -- " + newCdi.getConnectionDefinitionName());
return ReconfigAction.RECREATE_POOL;
}
ConnectorSecurityMap[] newSecurityMaps = newCcp.getSecurityMaps();
RuntimeSecurityMap newRuntimeSecurityMap = SecurityMapUtils.processSecurityMaps(newSecurityMaps);
ConnectorSecurityMap[] oldSecurityMaps = oldCcp.getSecurityMaps();
RuntimeSecurityMap oldRuntimeSecurityMap = SecurityMapUtils.processSecurityMaps(oldSecurityMaps);
if (!(oldRuntimeSecurityMap.equals(newRuntimeSecurityMap))) {
logFine("isEqualConnectorConnectionPool: CCP.getSecurityMaps:: " + "New set of Security Maps is not equal to the existing" + " set of security Maps.");
return ReconfigAction.RECREATE_POOL;
}
return oldCdi.compareMCFConfigProperties(newCdi, excludedProps);
}
use of com.sun.enterprise.connectors.ConnectorDescriptorInfo 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.ConnectorDescriptorInfo 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.ConnectorDescriptorInfo in project Payara by payara.
the class ConnectorDDTransformUtils method getConnectorDescriptorInfo.
/**
* Constructs ConnectorDescriptorInfo object from the
* ConnectionDefDescriptor object (deployment descriptor of connector
* module)
*
* @param connectionDefDescriptor ConnectionDefDescriptor object which
* represents the ra.xml and sun-ra.xml
* @return Transformed ConnectorDescriptorInfo object
*/
public static ConnectorDescriptorInfo getConnectorDescriptorInfo(ConnectionDefDescriptor connectionDefDescriptor) {
ConnectorDescriptorInfo connectorDescInfo = new ConnectorDescriptorInfo();
connectorDescInfo.setConnectionDefinitionName(connectionDefDescriptor.getConnectionFactoryIntf());
connectorDescInfo.setManagedConnectionFactoryClass(connectionDefDescriptor.getManagedConnectionFactoryImpl());
connectorDescInfo.setConnectionFactoryClass(connectionDefDescriptor.getConnectionFactoryImpl());
connectorDescInfo.setConnectionFactoryInterface(connectionDefDescriptor.getConnectionFactoryIntf());
connectorDescInfo.setConnectionInterface(connectionDefDescriptor.getConnectionIntf());
connectorDescInfo.setConnectionClass(connectionDefDescriptor.getConnectionImpl());
connectorDescInfo.setMCFConfigProperties(connectionDefDescriptor.getConfigProperties());
return connectorDescInfo;
}
Aggregations