}
}
private void addResourceAdapter(ResourceAdapterWrapper resourceAdapterWrapper) {
ResourceAdapter resourceAdapter = resourceAdapterWrapper.getResourceAdapter();
if (resourceAdapter == null) {
return;
}
if (registeredResouceAdapters.contains(resourceAdapterWrapper.getName())) {
// already registered
return;
}
registeredResouceAdapters.add(resourceAdapterWrapper.getName());
Map<String, String> listenerToActivationSpecMap = resourceAdapterWrapper.getMessageListenerToActivationSpecMap();
if (listenerToActivationSpecMap == null) {
return;
}
ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(classLoader);
try {
for (Map.Entry<String, String> entry : listenerToActivationSpecMap.entrySet()) {
String messageListenerInterface = entry.getKey();
String activationSpecClass = entry.getValue();
// only process RA if not previously processed
String containerName = getResourceAdapterId(resourceAdapterWrapper) + "-" + messageListenerInterface;
if (processedResourceAdapterWrappers.putIfAbsent(containerName, resourceAdapterWrapper) == null) {
try {
// get default mdb config
ContainerInfo containerInfo = configurationFactory.configureService(MdbContainerInfo.class, containerName, null, null, "Container");
containerInfo.id = containerName;
containerInfo.displayName = containerName;
properties = (properties == null)?new Properties():properties;
String instanceLimit = (String)properties.get(containerName + "." + "InstanceLimit");
if(instanceLimit != null){
containerInfo.properties.put("InstanceLimit", instanceLimit);
}
// set ra specific properties
containerInfo.properties.put("MessageListenerInterface",
resourceAdapter.getClass().getClassLoader().loadClass(messageListenerInterface));
containerInfo.properties.put("ActivationSpecClass",
resourceAdapter.getClass().getClassLoader().loadClass(activationSpecClass));
containerInfo.properties.put("ResourceAdapter", resourceAdapter);
// containerInfo.properties.put("TxRecovery", true);
// create the container
assembler.createContainer(containerInfo);