Reference ref = (Reference) obj;
logger.fine("AdministeredObjectFactory: " + ref +
" Name:" + name);
//String jndiName = (String) ref.get(0).getContent();
AdministeredObjectResource aor =
(AdministeredObjectResource) ref.get(0).getContent();
String jndiName = aor.getName();
String moduleName = aor.getResourceAdapter();
ConnectorRuntime runtime = ConnectorRuntime.getRuntime();
//If call fom application client, start resource adapter lazily.
//todo: Similar code in ConnectorObjectFactory - to refactor.
if(runtime.getEnviron() == ConnectorRuntime.CLIENT) {
ConnectorDescriptor connectorDescriptor = null;
try {
Context ic = new InitialContext();
String descriptorJNDIName = ConnectorAdminServiceUtils.
getReservePrefixedJNDINameForDescriptor(moduleName);
connectorDescriptor = (ConnectorDescriptor)ic.lookup(descriptorJNDIName);
} catch(NamingException ne) {
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");
}
logger.fine("[AdministeredObjectFactory] ==> Got AdministeredObjectResource = " + aor);
return aor.createAdministeredObject(null);