// start the resource adapter
try {
logger.debug("createResource.startingResourceAdapter", serviceInfo.id, service.getClass().getName());
resourceAdapter.start(bootstrapContext);
} catch (ResourceAdapterInternalException e) {
throw new OpenEJBException(e);
}
Map<String, Object> unset = serviceRecipe.getUnsetProperties();
unset.remove("threadPoolSize");
logUnusedProperties(unset, serviceInfo);
} else if (service instanceof ManagedConnectionFactory) {
ManagedConnectionFactory managedConnectionFactory = (ManagedConnectionFactory) service;
// connection manager is constructed via a recipe so we automatically expose all cmf properties
ObjectRecipe connectionManagerRecipe = new ObjectRecipe(GeronimoConnectionManagerFactory.class, "create");
connectionManagerRecipe.allow(Option.CASE_INSENSITIVE_PROPERTIES);
connectionManagerRecipe.allow(Option.IGNORE_MISSING_PROPERTIES);
connectionManagerRecipe.setAllProperties(serviceInfo.properties);
connectionManagerRecipe.setProperty("name", serviceInfo.id);
// standard properties
connectionManagerRecipe.setProperty("transactionManager", transactionManager);
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
if (classLoader == null) classLoader = getClass().getClassLoader();
if (classLoader == null) classLoader = ClassLoader.getSystemClassLoader();
connectionManagerRecipe.setProperty("classLoader", classLoader);
logger.getChildLogger("service").info("createResource.createConnectionManager", serviceInfo.id, service.getClass().getName());
// create the connection manager
ConnectionManager connectionManager = (ConnectionManager) connectionManagerRecipe.create();
if (connectionManager == null) {
throw new RuntimeException(messages.format("assembler.invalidConnectionManager", serviceInfo.id));
}
Map<String, Object> unsetA = serviceRecipe.getUnsetProperties();
Map<String, Object> unsetB = connectionManagerRecipe.getUnsetProperties();
Map<String, Object> unset = new HashMap<String, Object>();
for (Map.Entry<String, Object> entry : unsetA.entrySet()) {
if (unsetB.containsKey(entry.getKey())) unset.put(entry.getKey(),entry.getValue());
}
logUnusedProperties(unset, serviceInfo);
// service becomes a ConnectorReference which merges connection manager and mcf
service = new ConnectorReference(connectionManager, managedConnectionFactory);
} else {
logUnusedProperties(serviceRecipe, serviceInfo);
}
try {
containerSystem.getJNDIContext().bind("java:openejb/Resource/" + serviceInfo.id, service);
} catch (NamingException e) {
throw new OpenEJBException("Cannot bind resource adapter with id " + serviceInfo.id, e);
}
// Update the config tree
config.facilities.resources.add(serviceInfo);