use of com.sun.appserv.connectors.internal.api.ConnectorRuntimeException in project Payara by payara.
the class ConnectorDDTransformUtils method getConnectorDescriptor.
/**
* Get the ConnectorDescriptor object which represents the ra.xml and
* sun-ra.xml from an exploded rar module.
*
* @param moduleDir Directory where rar is exploded.
* @return ConnectorDescriptor object which
* represents the ra.xml and sun-ra.xml
* @throws ConnectorRuntimeException if ra.xml could not be located or
* invalid. For 1.0 type rar if sun-ra.xml is not present or
* invalid this exception is thrown. For 1.5 type rar sun-ra.xml
* should not be present.
*/
public static ConnectorDescriptor getConnectorDescriptor(String moduleDir, String rarModuleName) throws ConnectorRuntimeException {
ClassLoader cl = Thread.currentThread().getContextClassLoader();
try {
File module = new File(moduleDir);
FileArchive fileArchive = new FileArchive();
// directory where rar is exploded
fileArchive.open(module.toURI());
ConnectorRuntime runtime = ConnectorRuntime.getRuntime();
ClassLoader loader;
if (ConnectorsUtil.belongsToSystemRA(rarModuleName)) {
loader = ConnectorRuntime.getRuntime().getSystemRARClassLoader(rarModuleName);
Thread.currentThread().setContextClassLoader(loader);
} else {
loader = runtime.createConnectorClassLoader(moduleDir, null, rarModuleName);
}
ConnectorArchivist connectorArchivist = runtime.getConnectorArchvist();
// TODO V3 what happens to embedded .rar ? as its parent classloader should be application CL
// setting the classloader so that annotation processor can make use of it.
connectorArchivist.setClassLoader(loader);
// fileArchive.entries("META-INF/ra.xml");
// TODO V3 need to check whether ra.xml is present, if so, check the version. process annotations
// only if its 1.6 or above ?
connectorArchivist.setAnnotationProcessingRequested(true);
return connectorArchivist.open(fileArchive);
} catch (IOException ex) {
ConnectorRuntimeException cre = new ConnectorRuntimeException("Failed to read the connector deployment descriptors");
cre.initCause(ex);
_logger.log(Level.SEVERE, "rardeployment.connector_descriptor_read_error", moduleDir);
_logger.log(Level.SEVERE, "", cre);
throw cre;
} catch (SAXParseException ex) {
ConnectorRuntimeException cre = new ConnectorRuntimeException("Failed to parse the connector deployment descriptors");
cre.initCause(ex);
_logger.log(Level.SEVERE, "rardeployment.connector_descriptor_parse_error", moduleDir);
_logger.log(Level.SEVERE, "", cre);
throw cre;
} finally {
Thread.currentThread().setContextClassLoader(cl);
}
}
use of com.sun.appserv.connectors.internal.api.ConnectorRuntimeException in project Payara by payara.
the class ConnectorConnectionPoolDeployer method redeployResource.
/**
* {@inheritDoc}
*/
public synchronized void redeployResource(Object resource) throws Exception {
// Connector connection pool reconfiguration or
// change in security maps
org.glassfish.connectors.config.ConnectorConnectionPool domainCcp = (org.glassfish.connectors.config.ConnectorConnectionPool) resource;
List<SecurityMap> securityMaps = domainCcp.getSecurityMap();
// Since 8.1 PE/SE/EE, only if pool has already been deployed in this
// server-instance earlier, reconfig this pool
PoolInfo poolInfo = ConnectorsUtil.getPoolInfo(domainCcp);
if (!runtime.isConnectorConnectionPoolDeployed(poolInfo)) {
if (_logger.isLoggable(Level.FINE)) {
_logger.fine("The connector connection pool " + poolInfo + " is either not referred or not yet created in " + "this server instance and pool and hence " + "redeployment is ignored");
}
return;
}
String rarName = domainCcp.getResourceAdapterName();
String connDefName = domainCcp.getConnectionDefinitionName();
List<Property> props = domainCcp.getProperty();
ConnectorConnectionPool ccp = getConnectorConnectionPool(domainCcp, poolInfo);
populateConnectorConnectionPool(ccp, connDefName, rarName, props, securityMaps);
boolean poolRecreateRequired = false;
try {
if (_logger.isLoggable(Level.FINE)) {
_logger.fine("Calling reconfigure pool");
}
poolRecreateRequired = runtime.reconfigureConnectorConnectionPool(ccp, new HashSet());
} catch (ConnectorRuntimeException cre) {
Object[] params = new Object[] { poolInfo, cre };
_logger.log(Level.WARNING, "error.reconfiguring.pool", params);
}
if (poolRecreateRequired) {
if (_logger.isLoggable(Level.FINE)) {
_logger.fine("Pool recreation required");
}
runtime.recreateConnectorConnectionPool(ccp);
if (_logger.isLoggable(Level.FINE)) {
_logger.fine("Pool recreation done");
}
}
}
use of com.sun.appserv.connectors.internal.api.ConnectorRuntimeException in project Payara by payara.
the class ConnectorConnectionPoolDeployer method getConnectorConnectionPool.
private ConnectorConnectionPool getConnectorConnectionPool(org.glassfish.connectors.config.ConnectorConnectionPool domainCcp, PoolInfo poolInfo) throws Exception {
ConnectorConnectionPool ccp;
ccp = new ConnectorConnectionPool(poolInfo);
ccp.setSteadyPoolSize(domainCcp.getSteadyPoolSize());
ccp.setMaxPoolSize(domainCcp.getMaxPoolSize());
ccp.setMaxWaitTimeInMillis(domainCcp.getMaxWaitTimeInMillis());
ccp.setPoolResizeQuantity(domainCcp.getPoolResizeQuantity());
ccp.setIdleTimeoutInSeconds(domainCcp.getIdleTimeoutInSeconds());
ccp.setFailAllConnections(Boolean.valueOf(domainCcp.getFailAllConnections()));
ccp.setAuthCredentialsDefinedInPool(isAuthCredentialsDefinedInPool(domainCcp));
// The line below will change for 9.0. We will get this from
// the domain.xml
ccp.setConnectionValidationRequired(Boolean.valueOf(domainCcp.getIsConnectionValidationRequired()));
String txSupport = domainCcp.getTransactionSupport();
int txSupportIntVal = parseTransactionSupportString(txSupport);
if (txSupportIntVal == -1) {
// from the ra.xml
if (_logger.isLoggable(Level.FINE)) {
_logger.fine("Got transaction-support attr null from domain.xml");
}
txSupportIntVal = ConnectionPoolObjectsUtils.getTransactionSupportFromRaXml(domainCcp.getResourceAdapterName());
} else {
// the value specified in the ra.xml
if (!ConnectionPoolObjectsUtils.isTxSupportConfigurationSane(txSupportIntVal, domainCcp.getResourceAdapterName())) {
String i18nMsg = localStrings.getString("ccp_deployer.incorrect_tx_support");
ConnectorRuntimeException cre = new ConnectorRuntimeException(i18nMsg);
_logger.log(Level.SEVERE, "rardeployment.incorrect_tx_support", ccp.getName());
throw cre;
}
}
if (_logger.isLoggable(Level.FINE)) {
_logger.fine("setting txSupportVal to " + txSupportIntVal + " in pool " + domainCcp.getName());
}
ccp.setTransactionSupport(txSupportIntVal);
// Always for ccp
ccp.setNonComponent(false);
ccp.setNonTransactional(false);
ccp.setConnectionLeakTracingTimeout(domainCcp.getConnectionLeakTimeoutInSeconds());
ccp.setConnectionReclaim(Boolean.valueOf(domainCcp.getConnectionLeakReclaim()));
ccp.setMatchConnections(Boolean.valueOf(domainCcp.getMatchConnections()));
ccp.setAssociateWithThread(Boolean.valueOf(domainCcp.getAssociateWithThread()));
ccp.setPooling(Boolean.valueOf(domainCcp.getPooling()));
ccp.setPingDuringPoolCreation(Boolean.valueOf(domainCcp.getPing()));
boolean lazyConnectionEnlistment = Boolean.valueOf(domainCcp.getLazyConnectionEnlistment());
boolean lazyConnectionAssociation = Boolean.valueOf(domainCcp.getLazyConnectionAssociation());
if (lazyConnectionAssociation) {
if (lazyConnectionEnlistment) {
ccp.setLazyConnectionAssoc(true);
ccp.setLazyConnectionEnlist(true);
} else {
_logger.log(Level.SEVERE, "conn_pool_obj_utils.lazy_enlist-lazy_assoc-invalid-combination", domainCcp.getName());
String i18nMsg = localStrings.getString("cpou.lazy_enlist-lazy_assoc-invalid-combination", domainCcp.getName());
throw new RuntimeException(i18nMsg);
}
} else {
ccp.setLazyConnectionAssoc(lazyConnectionAssociation);
ccp.setLazyConnectionEnlist(lazyConnectionEnlistment);
}
boolean pooling = Boolean.valueOf(domainCcp.getPooling());
// TODO: should this be added to the beginning of this method?
if (!pooling) {
// Throw exception if assoc with thread is set to true.
if (Boolean.valueOf(domainCcp.getAssociateWithThread())) {
_logger.log(Level.SEVERE, "conn_pool_obj_utils.pooling_disabled_assocwiththread_invalid_combination", domainCcp.getName());
String i18nMsg = localStrings.getString("cpou.pooling_disabled_assocwiththread_invalid_combination", domainCcp.getName());
throw new RuntimeException(i18nMsg);
}
// match-connections/max-connection-usage-count/idele-timeout
if (Boolean.valueOf(domainCcp.getIsConnectionValidationRequired())) {
_logger.log(Level.WARNING, "conn_pool_obj_utils.pooling_disabled_conn_validation_invalid_combination", domainCcp.getName());
}
if (Integer.parseInt(domainCcp.getValidateAtmostOncePeriodInSeconds()) > 0) {
_logger.log(Level.WARNING, "conn_pool_obj_utils.pooling_disabled_validate_atmost_once_invalid_combination", domainCcp.getName());
}
if (Boolean.valueOf(domainCcp.getMatchConnections())) {
_logger.log(Level.WARNING, "conn_pool_obj_utils.pooling_disabled_match_connections_invalid_combination", domainCcp.getName());
}
if (Integer.parseInt(domainCcp.getMaxConnectionUsageCount()) > 0) {
_logger.log(Level.WARNING, "conn_pool_obj_utils.pooling_disabled_max_conn_usage_invalid_combination", domainCcp.getName());
}
if (Integer.parseInt(domainCcp.getIdleTimeoutInSeconds()) > 0) {
_logger.log(Level.WARNING, "conn_pool_obj_utils.pooling_disabled_idle_timeout_invalid_combination", domainCcp.getName());
}
}
ccp.setPooling(pooling);
ccp.setMaxConnectionUsage(domainCcp.getMaxConnectionUsageCount());
ccp.setValidateAtmostOncePeriod(domainCcp.getValidateAtmostOncePeriodInSeconds());
ccp.setConCreationRetryAttempts(domainCcp.getConnectionCreationRetryAttempts());
ccp.setConCreationRetryInterval(domainCcp.getConnectionCreationRetryIntervalInSeconds());
// IMPORTANT
// Here all properties that will be checked by the
// convertElementPropertyToPoolProperty method need to be set to
// their default values
convertElementPropertyToPoolProperty(ccp, domainCcp);
return ccp;
}
use of com.sun.appserv.connectors.internal.api.ConnectorRuntimeException in project Payara by payara.
the class ConnectorConnectionPoolDeployer method populateConnectorConnectionPool.
private void populateConnectorConnectionPool(ConnectorConnectionPool ccp, String connectionDefinitionName, String rarName, List<Property> props, List<SecurityMap> securityMaps) throws ConnectorRuntimeException {
ConnectorDescriptor connectorDescriptor = runtime.getConnectorDescriptor(rarName);
if (connectorDescriptor == null) {
ConnectorRuntimeException cre = new ConnectorRuntimeException("Failed to get connection pool object");
_logger.log(Level.SEVERE, "rardeployment.connector_descriptor_notfound_registry", rarName);
_logger.log(Level.SEVERE, "", cre);
throw cre;
}
Set connectionDefs = connectorDescriptor.getOutboundResourceAdapter().getConnectionDefs();
ConnectionDefDescriptor cdd = null;
Iterator it = connectionDefs.iterator();
while (it.hasNext()) {
cdd = (ConnectionDefDescriptor) it.next();
if (connectionDefinitionName.equals(cdd.getConnectionFactoryIntf()))
break;
}
ConnectorDescriptorInfo cdi = new ConnectorDescriptorInfo();
cdi.setRarName(rarName);
cdi.setResourceAdapterClassName(connectorDescriptor.getResourceAdapterClass());
cdi.setConnectionDefinitionName(cdd.getConnectionFactoryIntf());
cdi.setManagedConnectionFactoryClass(cdd.getManagedConnectionFactoryImpl());
cdi.setConnectionFactoryClass(cdd.getConnectionFactoryImpl());
cdi.setConnectionFactoryInterface(cdd.getConnectionFactoryIntf());
cdi.setConnectionClass(cdd.getConnectionImpl());
cdi.setConnectionInterface(cdd.getConnectionIntf());
Properties properties = new Properties();
// Refer Sun Bug :6579154 - Equivalent Oracle Bug :12206278
if (rarName.trim().equals(ConnectorRuntime.DEFAULT_JMS_ADAPTER)) {
properties.put("AddressList", "localhost");
}
Set mergedProps = ConnectorDDTransformUtils.mergeProps(props, cdd.getConfigProperties(), properties);
cdi.setMCFConfigProperties(mergedProps);
cdi.setResourceAdapterConfigProperties(connectorDescriptor.getConfigProperties());
ccp.setConnectorDescriptorInfo(cdi);
ccp.setSecurityMaps(SecurityMapUtils.getConnectorSecurityMaps(securityMaps));
}
use of com.sun.appserv.connectors.internal.api.ConnectorRuntimeException in project Payara by payara.
the class AdministeredObjectFactory method getObjectInstance.
public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable env) throws Exception {
Reference ref = (Reference) obj;
if (logger.isLoggable(Level.FINE)) {
logger.fine("AdministeredObjectFactory: " + ref + " Name:" + name);
}
AdministeredObjectResource aor = (AdministeredObjectResource) ref.get(0).getContent();
String moduleName = aor.getResourceAdapter();
// If call fom application client, start resource adapter lazily.
// todo: Similar code in ConnectorObjectFactory - to refactor.
ConnectorRuntime runtime = ConnectorNamingUtils.getRuntime();
if (runtime.isACCRuntime() || runtime.isNonACCRuntime()) {
ConnectorDescriptor connectorDescriptor = null;
try {
Context ic = new InitialContext();
String descriptorJNDIName = ConnectorAdminServiceUtils.getReservePrefixedJNDINameForDescriptor(moduleName);
connectorDescriptor = (ConnectorDescriptor) ic.lookup(descriptorJNDIName);
} catch (NamingException ne) {
if (logger.isLoggable(Level.FINE)) {
logger.log(Level.FINE, "Failed to look up ConnectorDescriptor " + "from JNDI", moduleName);
}
throw new ConnectorRuntimeException("Failed to look up " + "ConnectorDescriptor from JNDI");
}
runtime.createActiveResourceAdapter(connectorDescriptor, moduleName, null);
}
ClassLoader loader = Thread.currentThread().getContextClassLoader();
if (runtime.checkAccessibility(moduleName, loader) == false) {
throw new NamingException("Only the application that has the embedded resource" + "adapter can access the resource adapter");
}
if (logger.isLoggable(Level.FINE)) {
logger.fine("[AdministeredObjectFactory] ==> Got AdministeredObjectResource = " + aor);
}
// all RARs except system RARs should have been available now.
if (ConnectorsUtil.belongsToSystemRA(moduleName)) {
// make sure that system rar is started and hence added to connector classloader chain
if (ConnectorRegistry.getInstance().getActiveResourceAdapter(moduleName) == null) {
String moduleLocation = ConnectorsUtil.getSystemModuleLocation(moduleName);
runtime.createActiveResourceAdapter(moduleLocation, moduleName, null);
}
loader = ConnectorRegistry.getInstance().getActiveResourceAdapter(moduleName).getClassLoader();
} else if (runtime.isServer()) {
if (ConnectorsUtil.isStandAloneRA(moduleName)) {
loader = ConnectorRegistry.getInstance().getActiveResourceAdapter(moduleName).getClassLoader();
}
}
return aor.createAdministeredObject(loader);
}
Aggregations