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);
}