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(env);
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);
}
use of com.sun.appserv.connectors.internal.api.ConnectorRuntimeException in project Payara by payara.
the class JdbcConnectionPoolDeployer method redeployResource.
/**
* {@inheritDoc}
*/
@Override
public synchronized void redeployResource(Object resource) throws Exception {
final JdbcConnectionPool adminPool = (JdbcConnectionPool) resource;
PoolInfo poolInfo = ConnectorsUtil.getPoolInfo(adminPool);
if (!runtime.isConnectorConnectionPoolDeployed(poolInfo)) {
if (_logger.isLoggable(Level.FINE)) {
_logger.fine("The JDBC connection pool " + poolInfo + " is not referred or not yet created in this server " + "instance and hence pool redeployment is ignored");
}
return;
}
final ConnectorConnectionPool connConnPool = createConnectorConnectionPool(adminPool, poolInfo);
if (connConnPool == null) {
throw new ConnectorRuntimeException("Unable to create ConnectorConnectionPool" + "from JDBC connection pool");
}
// now do internal book keeping
HashSet excludes = new HashSet();
// add MCF config props to the set that need to be excluded
// in checking for the equality of the props with old pool
excludes.add("TransactionIsolation");
excludes.add("GuaranteeIsolationLevel");
excludes.add("ValidationTableName");
excludes.add("ConnectionValidationRequired");
excludes.add("ValidationMethod");
excludes.add("StatementWrapping");
excludes.add("StatementTimeout");
excludes.add("ValidationClassName");
excludes.add("StatementCacheSize");
excludes.add("StatementCacheType");
excludes.add("StatementLeakTimeoutInSeconds");
excludes.add("StatementLeakReclaim");
try {
if (_logger.isLoggable(Level.FINEST)) {
_logger.finest("Calling reconfigure pool");
}
boolean requirePoolRecreation = runtime.reconfigureConnectorConnectionPool(connConnPool, excludes);
if (requirePoolRecreation) {
if (runtime.isServer() || runtime.isEmbedded()) {
handlePoolRecreation(connConnPool);
} else {
recreatePool(connConnPool);
}
}
} catch (ConnectorRuntimeException cre) {
Object[] params = new Object[] { poolInfo, cre };
_logger.log(Level.WARNING, "error.redeploying.jdbc.pool", params);
throw cre;
}
}
use of com.sun.appserv.connectors.internal.api.ConnectorRuntimeException in project Payara by payara.
the class ActiveResourceAdapterImpl method deleteSunRAConnectionPool.
/**
* Added to clean up the connector connection pool pertaining to sun-ra.xml. This is
* only for 1.0 complient rars.
*/
private void deleteSunRAConnectionPool() {
String defaultPoolName = connectorRuntime_.getDefaultPoolName(moduleName_, connectionDefs_[0].getConnectionFactoryIntf());
String sunRAPoolName = defaultPoolName + ConnectorConstants.SUN_RA_POOL;
PoolInfo poolInfo = new PoolInfo(sunRAPoolName);
try {
connectorRuntime_.deleteConnectorConnectionPool(poolInfo);
} catch (ConnectorRuntimeException cre) {
_logger.log(Level.WARNING, "rar.undeployment.sun_ra_pool_delete_fail", poolInfo);
}
}
use of com.sun.appserv.connectors.internal.api.ConnectorRuntimeException in project Payara by payara.
the class ConnectorService method loadResourcesAndItsRar.
/* public boolean checkAndLoadResource(Object resource, Object pool, String resourceType, String resourceName,
String raName)
throws ConnectorRuntimeException {
String resname = ConnectorAdminServiceUtils.getOriginalResourceName(resourceName);
if(_logger.isLoggable(Level.FINE)) {
_logger.fine("ConnectorService :: checkAndLoadResource resolved to load " + resname);
}
DeferredResourceConfig defResConfig = getResourcesUtil().getDeferredResourceConfig(resource, pool, resourceType, raName);
//DeferredResourceConfig defResConfig = resUtil.getDeferredResourceConfig(resname);
return loadResourcesAndItsRar(defResConfig);
}
*/
public boolean loadResourcesAndItsRar(DeferredResourceConfig defResConfig) {
if (defResConfig != null) {
try {
loadDeferredResources(defResConfig.getResourceAdapterConfig());
final String rarName = defResConfig.getRarName();
loadDeferredResourceAdapter(rarName);
final Resource[] resToLoad = defResConfig.getResourcesToLoad();
AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
try {
loadDeferredResources(resToLoad);
} catch (Exception ex) {
Object[] params = new Object[] { rarName, ex };
_logger.log(Level.SEVERE, "failed.to.load.deferred.resources", params);
}
return null;
}
});
} catch (Exception ex) {
Object[] params = new Object[] { defResConfig.getRarName(), ex };
_logger.log(Level.SEVERE, "failed.to.load.deferred.ra", params);
return false;
}
return true;
}
return false;
}
use of com.sun.appserv.connectors.internal.api.ConnectorRuntimeException in project Payara by payara.
the class ConnectorService method getConnectorDescriptor.
/**
* Obtains the connector Descriptor pertaining to rar.
* If ConnectorDescriptor is present in registry, it is obtained from
* registry and returned. Else it is explicitly read from directory
* where rar is exploded.
*
* @param rarName Name of the rar
* @return ConnectorDescriptor pertaining to rar.
* @throws ConnectorRuntimeException when unable to get descriptor
*/
public ConnectorDescriptor getConnectorDescriptor(String rarName) throws ConnectorRuntimeException {
if (rarName == null) {
return null;
}
ConnectorDescriptor desc = null;
desc = _registry.getDescriptor(rarName);
if (desc != null) {
return desc;
}
String moduleDir;
// using the applicationarchivist
if (rarName.indexOf(ConnectorConstants.EMBEDDEDRAR_NAME_DELIMITER) != -1) {
try {
desc = loadConnectorDescriptorForEmbeddedRAR(rarName);
if (desc != null)
return desc;
} catch (ConnectorRuntimeException e) {
throw e;
}
}
if (ConnectorsUtil.belongsToSystemRA(rarName)) {
moduleDir = ConnectorsUtil.getSystemModuleLocation(rarName);
} else {
moduleDir = ConnectorsUtil.getLocation(rarName);
}
if (moduleDir != null) {
desc = ConnectorDDTransformUtils.getConnectorDescriptor(moduleDir, rarName);
} else {
_logger.log(Level.SEVERE, "rardeployment.no_module_deployed", rarName);
}
return desc;
}
Aggregations