geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: r525251 - /geronimo/server/trunk/modules/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/OpenEjbSystemGBean.java
Date Tue, 03 Apr 2007 19:30:17 GMT
Author: dain
Date: Tue Apr  3 12:30:16 2007
New Revision: 525251

URL: http://svn.apache.org/viewvc?view=rev&rev=525251
Log:
make sure all resource adapters are registered before starting an ejb module

Modified:
    geronimo/server/trunk/modules/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/OpenEjbSystemGBean.java

Modified: geronimo/server/trunk/modules/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/OpenEjbSystemGBean.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/OpenEjbSystemGBean.java?view=diff&rev=525251&r1=525250&r2=525251
==============================================================================
--- geronimo/server/trunk/modules/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/OpenEjbSystemGBean.java
(original)
+++ geronimo/server/trunk/modules/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/OpenEjbSystemGBean.java
Tue Apr  3 12:30:16 2007
@@ -20,6 +20,9 @@
 import java.util.Collection;
 import java.util.Map;
 import java.util.Properties;
+import java.util.Set;
+import java.util.TreeSet;
+import java.util.Iterator;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 
@@ -38,6 +41,7 @@
 import org.apache.geronimo.gbean.ReferenceCollection;
 import org.apache.geronimo.gbean.ReferenceCollectionEvent;
 import org.apache.geronimo.gbean.ReferenceCollectionListener;
+import org.apache.geronimo.gbean.AbstractNameQuery;
 import org.apache.geronimo.kernel.GBeanNotFoundException;
 import org.apache.geronimo.kernel.Kernel;
 import org.apache.openejb.Container;
@@ -75,7 +79,9 @@
     private static final Log log = LogFactory.getLog(OpenEjbSystemGBean.class);
     private final ConfigurationFactory configurationFactory;
     private final Assembler assembler;
+    private final Set<String> registeredResouceAdapters = new TreeSet<String>();
     private final ConcurrentMap<String,ResourceAdapterWrapper> processedResourceAdapterWrappers
=  new ConcurrentHashMap<String,ResourceAdapterWrapper>() ;
+    private final Kernel kernel;
     private final ClassLoader classLoader;
     // These are provided by the corba subsystem when it first initializes.  
     // Once we have a set, we ignore any additional notifications. 
@@ -85,6 +91,7 @@
         this(transactionManager, null, null, OpenEjbSystemGBean.class.getClassLoader());
     }
     public OpenEjbSystemGBean(TransactionManager transactionManager, Collection<ResourceAdapterWrapper>
resourceAdapters, Kernel kernel, ClassLoader classLoader) throws Exception {
+        this.kernel = kernel;
         this.classLoader = classLoader;
         
         System.setProperty("duct tape","");
@@ -183,6 +190,11 @@
         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) {
@@ -230,6 +242,8 @@
             processedResourceAdapterWrappers.remove(containerName);
             assembler.removeContainer(containerName);
         }
+
+        registeredResouceAdapters.remove(resourceAdapterWrapper.getName());
     }
 
     private String getResourceAdapterId(ResourceAdapterWrapper resourceAdapterWrapper) {
@@ -299,6 +313,16 @@
     }
 
     public void createEjbJar(EjbJarInfo ejbJarInfo, ClassLoader classLoader) throws NamingException,
IOException, OpenEJBException {
+        Set names = kernel.listGBeans(new AbstractNameQuery(ResourceAdapterWrapper.class.getName()));
+        for (Iterator iterator = names.iterator(); iterator.hasNext();) {
+            try {
+                AbstractName name = (AbstractName) iterator.next();
+                ResourceAdapterWrapper resourceAdapterWrapper = (ResourceAdapterWrapper)
kernel.getGBean(name);
+                addResourceAdapter(resourceAdapterWrapper);
+            } catch (GBeanNotFoundException ignored) {
+            }
+        }
+        
         ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
         Thread.currentThread().setContextClassLoader(classLoader);
         try {



Mime
View raw message