geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r579069 - in /geronimo/server/trunk: configs/openejb-deployer/ configs/openejb-deployer/src/main/plan/ configs/openejb/ configs/openejb/src/main/plan/ modules/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/ mo...
Date Tue, 25 Sep 2007 04:44:34 GMT
Author: djencks
Date: Mon Sep 24 21:44:32 2007
New Revision: 579069

URL: http://svn.apache.org/viewvc?rev=579069&view=rev
Log:
GERONIMO-3484 make openejb-deployer work when openejb is loaded but not started

Modified:
    geronimo/server/trunk/configs/openejb-deployer/pom.xml
    geronimo/server/trunk/configs/openejb-deployer/src/main/plan/plan.xml
    geronimo/server/trunk/configs/openejb/pom.xml
    geronimo/server/trunk/configs/openejb/src/main/plan/plan.xml
    geronimo/server/trunk/modules/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbModuleBuilder.java
    geronimo/server/trunk/modules/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/EjbContainer.java

Modified: geronimo/server/trunk/configs/openejb-deployer/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/configs/openejb-deployer/pom.xml?rev=579069&r1=579068&r2=579069&view=diff
==============================================================================
--- geronimo/server/trunk/configs/openejb-deployer/pom.xml (original)
+++ geronimo/server/trunk/configs/openejb-deployer/pom.xml Mon Sep 24 21:44:32 2007
@@ -120,6 +120,7 @@
                             <groupId>org.apache.geronimo.configs</groupId>
                             <artifactId>openejb</artifactId>
                             <type>car</type>
+                            <import>classes</import>
                         </dependency>
                     </dependencies>
                     <instance>

Modified: geronimo/server/trunk/configs/openejb-deployer/src/main/plan/plan.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/configs/openejb-deployer/src/main/plan/plan.xml?rev=579069&r1=579068&r2=579069&view=diff
==============================================================================
--- geronimo/server/trunk/configs/openejb-deployer/src/main/plan/plan.xml (original)
+++ geronimo/server/trunk/configs/openejb-deployer/src/main/plan/plan.xml Mon Sep 24 21:44:32
2007
@@ -23,9 +23,6 @@
     <gbean name="EJBBuilder" class="org.apache.geronimo.openejb.deployment.EjbModuleBuilder">
         <attribute name="defaultCmpJTADataSource">SystemDatasource</attribute>
         <attribute name="defaultCmpNonJTADataSource">NoTxDatasource</attribute>
-        <reference name="OpenEjbSystem">
-            <name>OpenEjbSystem</name>
-        </reference>
         <references name="ModuleBuilderExtensions">
             <pattern>
                 <name>PersistenceUnitBuilder</name>
@@ -72,7 +69,6 @@
             </environment>
         </xml-attribute>
     </gbean>
-
 
     <gbean name="EjbRefBuilder" class="org.apache.geronimo.openejb.deployment.EjbRefBuilder">
         <attribute name="eeNamespaces">http://java.sun.com/xml/ns/j2ee,http://java.sun.com/xml/ns/javaee</attribute>

Modified: geronimo/server/trunk/configs/openejb/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/configs/openejb/pom.xml?rev=579069&r1=579068&r2=579069&view=diff
==============================================================================
--- geronimo/server/trunk/configs/openejb/pom.xml (original)
+++ geronimo/server/trunk/configs/openejb/pom.xml Mon Sep 24 21:44:32 2007
@@ -67,7 +67,7 @@
         
         <dependency>
             <groupId>org.apache.geronimo.configs</groupId>
-            <artifactId>activemq-ra</artifactId>
+            <artifactId>activemq-broker</artifactId>
             <version>${version}</version>
             <type>car</type>
         </dependency>

Modified: geronimo/server/trunk/configs/openejb/src/main/plan/plan.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/configs/openejb/src/main/plan/plan.xml?rev=579069&r1=579068&r2=579069&view=diff
==============================================================================
--- geronimo/server/trunk/configs/openejb/src/main/plan/plan.xml (original)
+++ geronimo/server/trunk/configs/openejb/src/main/plan/plan.xml Mon Sep 24 21:44:32 2007
@@ -1,5 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!--Licensed to the Apache Software Foundation (ASF) under one or more
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one or more
     contributor license agreements.  See the NOTICE file distributed with
     this work for additional information regarding copyright ownership.
     The ASF licenses this file to You under the Apache License, Version 2.0
@@ -12,143 +13,78 @@
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
-    limitations under the License.-->
-<!--$Rev$ $Date$-->
-<module xmlns="http://geronimo.apache.org/xml/ns/deployment-1.2">
-  <environment>
-    <moduleId>
-      <groupId>org.apache.geronimo.configs</groupId>
-      <artifactId>openejb</artifactId>
-      <version>2.1-SNAPSHOT</version>
-      <type>car</type>
-    </moduleId>
-    <dependencies>
-      <dependency>
-        <groupId>org.apache.geronimo.configs</groupId>
-        <artifactId>server-security-config</artifactId>
-        <type>car</type>
-      </dependency>
-      <dependency>
-        <groupId>org.apache.geronimo.configs</groupId>
-        <artifactId>activemq-ra</artifactId>
-        <type>car</type>
-      </dependency>
-      <dependency>
-        <groupId>org.apache.geronimo.configs</groupId>
-        <artifactId>j2ee-server</artifactId>
-        <type>car</type>
-      </dependency>
-      <dependency>
-        <groupId>org.apache.geronimo.configs</groupId>
-        <artifactId>system-database</artifactId>
-        <type>car</type>
-      </dependency>
-      <dependency>
-        <groupId>org.apache.openejb</groupId>
-        <artifactId>openejb-core</artifactId>
-        <version>3.0.0-SNAPSHOT</version>
-        <type>jar</type>
-        <import>classes</import>
-      </dependency>
-      <dependency>
-        <groupId>org.apache.geronimo.configs</groupId>
-        <artifactId>openjpa</artifactId>
-        <type>car</type>
-      </dependency>
-      <dependency>
-        <groupId>org.apache.geronimo.configs</groupId>
-        <artifactId>webservices-common</artifactId>
-        <type>car</type>
-      </dependency>
-      <dependency>
-        <groupId>org.apache.geronimo.configs</groupId>
-        <artifactId>transaction</artifactId>
-        <type>car</type>
-      </dependency>
-      <dependency>
-        <groupId>org.apache.geronimo.modules</groupId>
-        <artifactId>geronimo-openejb</artifactId>
-        <version>2.1-SNAPSHOT</version>
-        <type>jar</type>
-        <import>classes</import>
-      </dependency>
-      <dependency>
-        <groupId>org.apache.yoko</groupId>
-        <artifactId>yoko-spec-corba</artifactId>
-        <version>1.0-incubating-SNAPSHOT</version>
-        <type>jar</type>
-        <import>classes</import>
-      </dependency>
-      <dependency>
-        <groupId>org.apache.xbean</groupId>
-        <artifactId>xbean-finder</artifactId>
-        <version>3.0.1</version>
-        <type>jar</type>
-        <import>classes</import>
-      </dependency>
-    </dependencies>
-    <hidden-classes/>
-    <non-overridable-classes/>
-  </environment>
-  <gbean name="OpenEjbSystem" class="org.apache.geronimo.openejb.OpenEjbSystemGBean">
-    <reference name="TransactionManager">
-      <name>TransactionManager</name>
-    </reference>
-    <reference name="ResourceAdapterWrappers"/>
-    <reference name="PersistenceUnitGBeans"/>
-  </gbean>
-  <gbean name="ExtendedEntityManagerRegistry" class="org.apache.geronimo.openejb.EntityManagerRegistryImpl">
-    <dependency>
-      <name>OpenEjbSystem</name>
-    </dependency>
-  </gbean>
-  <gbean name="DefaultStatelessContainer" class="org.apache.geronimo.openejb.EjbContainer">
-    <attribute name="id">Default Stateless Container</attribute>
-    <attribute name="type">STATELESS</attribute>
-    <reference name="OpenEjbSystem">
-      <name>OpenEjbSystem</name>
-    </reference>
-  </gbean>
-  <gbean name="DefaultStatefulContainer" class="org.apache.geronimo.openejb.EjbContainer">
-    <attribute name="id">Default Stateful Container</attribute>
-    <attribute name="type">STATEFUL</attribute>
-    <attribute name="properties">PoolSize=1000</attribute>
-    <reference name="OpenEjbSystem">
-      <name>OpenEjbSystem</name>
-    </reference>
-  </gbean>
-  <gbean name="DefaultBMPContainer" class="org.apache.geronimo.openejb.EjbContainer">
-    <attribute name="id">Default BMP Container</attribute>
-    <attribute name="type">BMP_ENTITY</attribute>
-    <reference name="OpenEjbSystem">
-      <name>OpenEjbSystem</name>
-    </reference>
-  </gbean>
-  <gbean name="DefaultCMPContainer" class="org.apache.geronimo.openejb.EjbContainer">
-    <attribute name="id">Default CMP Container</attribute>
-    <attribute name="type">CMP_ENTITY</attribute>
-    <reference name="OpenEjbSystem">
-      <name>OpenEjbSystem</name>
-    </reference>
-  </gbean>
-  <!--<gbean name="DefaultMDBContainer" class="org.apache.geronimo.openejb.EjbContainer">-->
-  <!--<attribute name="id">Default MDB Container</attribute>-->
-  <!--<attribute name="type">MESSAGE</attribute>-->
-  <!--<reference name="OpenEjbSystem">-->
-  <!--<name>OpenEjbSystem</name>-->
-  <!--</reference>-->
-  <!--</gbean>-->
-  <gbean name="EJBNetworkService" class="org.apache.geronimo.openejb.EjbDaemonGBean">
-    <attribute name="port">4201</attribute>
-    <attribute name="host">0.0.0.0</attribute>
-    <attribute name="threads">20</attribute>
-    <dependency>
-      <name>OpenEjbSystem</name>
-    </dependency>
-  </gbean>
-  <gbean name="ejb/mgmt/MEJB" class="org.apache.geronimo.openejb.MEJBGBean">
-    <reference name="StatelessContainer">
-      <name>DefaultStatelessContainer</name>
-    </reference>
-  </gbean>
-</module>
\ No newline at end of file
+    limitations under the License.
+-->
+
+<!-- $Rev$ $Date$ -->
+
+<module xmlns="http://geronimo.apache.org/xml/ns/deployment-${geronimoSchemaVersion}">
+
+    <gbean name="OpenEjbSystem" class="org.apache.geronimo.openejb.OpenEjbSystemGBean">
+        <reference name="TransactionManager">
+            <name>TransactionManager</name>
+        </reference>
+        <reference name="ResourceAdapterWrappers"/>
+        <reference name="PersistenceUnitGBeans"/>
+    </gbean>
+
+    <gbean name="ExtendedEntityManagerRegistry" class="org.apache.geronimo.openejb.EntityManagerRegistryImpl">
+    	<dependency>
+    		<name>OpenEjbSystem</name>
+    	</dependency>
+    </gbean>
+
+    <gbean name="DefaultStatelessContainer" class="org.apache.geronimo.openejb.EjbContainer">
+        <attribute name="id">Default Stateless Container</attribute>
+        <attribute name="type">STATELESS</attribute>
+        <reference name="OpenEjbSystem">
+            <name>OpenEjbSystem</name>
+        </reference>
+    </gbean>
+    <gbean name="DefaultStatefulContainer" class="org.apache.geronimo.openejb.EjbContainer">
+        <attribute name="id">Default Stateful Container</attribute>
+        <attribute name="type">STATEFUL</attribute>
+        <attribute name="properties">PoolSize=1000</attribute>
+        <reference name="OpenEjbSystem">
+            <name>OpenEjbSystem</name>
+        </reference>
+    </gbean>
+    <gbean name="DefaultBMPContainer" class="org.apache.geronimo.openejb.EjbContainer">
+        <attribute name="id">Default BMP Container</attribute>
+        <attribute name="type">BMP_ENTITY</attribute>
+        <reference name="OpenEjbSystem">
+            <name>OpenEjbSystem</name>
+        </reference>
+    </gbean>
+    <gbean name="DefaultCMPContainer" class="org.apache.geronimo.openejb.EjbContainer">
+        <attribute name="id">Default CMP Container</attribute>
+        <attribute name="type">CMP_ENTITY</attribute>
+        <reference name="OpenEjbSystem">
+            <name>OpenEjbSystem</name>
+        </reference>
+    </gbean>
+
+    <!--<gbean name="DefaultMDBContainer" class="org.apache.geronimo.openejb.EjbContainer">-->
+        <!--<attribute name="id">Default MDB Container</attribute>-->
+        <!--<attribute name="type">MESSAGE</attribute>-->
+        <!--<reference name="OpenEjbSystem">-->
+            <!--<name>OpenEjbSystem</name>-->
+        <!--</reference>-->
+    <!--</gbean>-->
+
+    <gbean name="EJBNetworkService" class="org.apache.geronimo.openejb.EjbDaemonGBean">
+        <attribute name="port">${PlanOpenEJBPort}</attribute>
+        <attribute name="host">${PlanServerHostname}</attribute>
+        <attribute name="threads">20</attribute>
+        <dependency>
+            <name>OpenEjbSystem</name>
+        </dependency>
+    </gbean>
+
+    <gbean name="ejb/mgmt/MEJB" class="org.apache.geronimo.openejb.MEJBGBean">
+        <reference name="StatelessContainer">
+            <name>DefaultStatelessContainer</name>
+        </reference>
+    </gbean>
+
+</module>

Modified: geronimo/server/trunk/modules/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbModuleBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbModuleBuilder.java?rev=579069&r1=579068&r2=579069&view=diff
==============================================================================
--- geronimo/server/trunk/modules/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbModuleBuilder.java
(original)
+++ geronimo/server/trunk/modules/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbModuleBuilder.java
Mon Sep 24 21:44:32 2007
@@ -24,22 +24,27 @@
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Iterator;
+import java.util.LinkedHashSet;
 import java.util.LinkedList;
 import java.util.Map;
+import java.util.Properties;
 import java.util.Set;
 import java.util.TreeMap;
 import java.util.TreeSet;
 import java.util.jar.JarFile;
 
 import javax.ejb.EntityContext;
-import javax.ejb.SessionContext;
 import javax.ejb.MessageDrivenContext;
+import javax.ejb.SessionContext;
 import javax.xml.namespace.QName;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.geronimo.common.DeploymentException;
+import org.apache.geronimo.connector.ResourceAdapterWrapperGBean;
+import org.apache.geronimo.deployment.ClassPathList;
 import org.apache.geronimo.deployment.ModuleIDBuilder;
+import org.apache.geronimo.deployment.ModuleList;
 import org.apache.geronimo.deployment.NamespaceDrivenBuilder;
 import org.apache.geronimo.deployment.NamespaceDrivenBuilderCollection;
 import org.apache.geronimo.deployment.service.EnvironmentBuilder;
@@ -57,18 +62,18 @@
 import org.apache.geronimo.j2ee.deployment.ModuleBuilder;
 import org.apache.geronimo.j2ee.deployment.ModuleBuilderExtension;
 import org.apache.geronimo.j2ee.deployment.NamingBuilder;
-import org.apache.geronimo.deployment.ModuleList;
-import org.apache.geronimo.deployment.ClassPathList;
 import org.apache.geronimo.j2ee.deployment.annotation.AnnotatedEjbJar;
 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
-import org.apache.geronimo.kernel.classloader.TemporaryClassLoader;
-import org.apache.geronimo.kernel.Naming;
 import org.apache.geronimo.kernel.GBeanNotFoundException;
+import org.apache.geronimo.kernel.Naming;
+import org.apache.geronimo.kernel.classloader.TemporaryClassLoader;
+import org.apache.geronimo.kernel.config.Configuration;
 import org.apache.geronimo.kernel.config.ConfigurationModuleType;
 import org.apache.geronimo.kernel.config.ConfigurationStore;
-import org.apache.geronimo.kernel.repository.Environment;
 import org.apache.geronimo.kernel.repository.Artifact;
+import org.apache.geronimo.kernel.repository.Environment;
 import org.apache.geronimo.naming.deployment.ResourceEnvironmentSetter;
+import org.apache.geronimo.openejb.EjbContainer;
 import org.apache.geronimo.openejb.EjbDeployment;
 import org.apache.geronimo.openejb.EjbModuleImplGBean;
 import org.apache.geronimo.openejb.OpenEjbSystem;
@@ -79,18 +84,25 @@
 import org.apache.openejb.OpenEJBException;
 import org.apache.openejb.assembler.classic.AppInfo;
 import org.apache.openejb.assembler.classic.CmpJarBuilder;
+import org.apache.openejb.assembler.classic.ContainerInfo;
+import org.apache.openejb.assembler.classic.ContainerSystemInfo;
 import org.apache.openejb.assembler.classic.EjbJarInfo;
 import org.apache.openejb.assembler.classic.EnterpriseBeanInfo;
+import org.apache.openejb.assembler.classic.FacilitiesInfo;
+import org.apache.openejb.assembler.classic.MdbContainerInfo;
 import org.apache.openejb.assembler.classic.MessageDrivenBeanInfo;
+import org.apache.openejb.assembler.classic.OpenEjbConfiguration;
 import org.apache.openejb.config.AppModule;
+import org.apache.openejb.config.ConfigurationFactory;
 import org.apache.openejb.config.DeploymentLoader;
 import org.apache.openejb.config.ReadDescriptors;
 import org.apache.openejb.config.UnknownModuleTypeException;
 import org.apache.openejb.config.UnsupportedModuleTypeException;
-import org.apache.openejb.config.ValidationFailedException;
 import org.apache.openejb.config.ValidationError;
+import org.apache.openejb.config.ValidationFailedException;
 import org.apache.openejb.config.ValidationFailure;
 import org.apache.openejb.jee.EjbJar;
+import org.apache.openejb.jee.EjbRef;
 import org.apache.openejb.jee.EnterpriseBean;
 import org.apache.openejb.jee.MessageDestinationRef;
 import org.apache.openejb.jee.PersistenceContextRef;
@@ -98,16 +110,16 @@
 import org.apache.openejb.jee.ResourceEnvRef;
 import org.apache.openejb.jee.ResourceRef;
 import org.apache.openejb.jee.ServiceRef;
-import org.apache.openejb.jee.EjbRef;
 import org.apache.openejb.jee.jpa.unit.Persistence;
 import org.apache.openejb.jee.jpa.unit.PersistenceUnit;
 import org.apache.openejb.jee.jpa.unit.TransactionType;
+import org.apache.openejb.jee.oejb2.EjbRefType;
 import org.apache.openejb.jee.oejb2.GeronimoEjbJarType;
-import org.apache.openejb.jee.oejb2.ResourceLocatorType;
-import org.apache.openejb.jee.oejb2.PatternType;
-import org.apache.openejb.jee.oejb2.OpenejbJarType;
 import org.apache.openejb.jee.oejb2.MessageDrivenBeanType;
-import org.apache.openejb.jee.oejb2.EjbRefType;
+import org.apache.openejb.jee.oejb2.OpenejbJarType;
+import org.apache.openejb.jee.oejb2.PatternType;
+import org.apache.openejb.jee.oejb2.ResourceLocatorType;
+import org.apache.openejb.loader.SystemInstance;
 import org.apache.xmlbeans.XmlCursor;
 import org.apache.xmlbeans.XmlObject;
 
@@ -129,19 +141,17 @@
     private final NamespaceDrivenBuilderCollection serviceBuilders;
     private final NamingBuilder namingBuilder;
     private final ResourceEnvironmentSetter resourceEnvironmentSetter;
-    private final OpenEjbSystem openEjbSystem;
     private final Collection<ModuleBuilderExtension> moduleBuilderExtensions;
 
     public EjbModuleBuilder(Environment defaultEnvironment,
 
-            String defaultCmpJTADataSource, String defaultCmpNonJTADataSource, OpenEjbSystem
openEjbSystem,
-            Collection<ModuleBuilderExtension> moduleBuilderExtensions,
-            Collection securityBuilders,
-            Collection serviceBuilders,
-            NamingBuilder namingBuilders,
-            ResourceEnvironmentSetter resourceEnvironmentSetter) {
+                            String defaultCmpJTADataSource, String defaultCmpNonJTADataSource,
+                            Collection<ModuleBuilderExtension> moduleBuilderExtensions,
+                            Collection securityBuilders,
+                            Collection serviceBuilders,
+                            NamingBuilder namingBuilders,
+                            ResourceEnvironmentSetter resourceEnvironmentSetter) {
 
-        this.openEjbSystem = openEjbSystem;
         this.defaultEnvironment = defaultEnvironment;
         this.defaultCmpJTADataSource = defaultCmpJTADataSource;
         this.defaultCmpNonJTADataSource = defaultCmpNonJTADataSource;
@@ -154,8 +164,29 @@
             moduleBuilderExtensions = Collections.emptyList();
         }
         this.moduleBuilderExtensions = moduleBuilderExtensions;
+
+        //duplicate of stuff in OpenEjbSystemGBean, may not be essential
+        System.setProperty("duct tape", "");
+        System.setProperty("admin.disabled", "true");
+        System.setProperty("openejb.logger.external", "true");
+
+        setDefaultProperty("openejb.deploymentId.format", "{moduleId}/{ejbName}");
+        setDefaultProperty("openejb.jndiname.strategy.class", "org.apache.openejb.assembler.classic.JndiBuilder$TemplatedStrategy");
+        setDefaultProperty("openejb.jndiname.format", "{deploymentId}/{interfaceClass}");
+
+        System.setProperty("openejb.naming", "xbean");
+
     }
 
+    private void setDefaultProperty(String key, String value) {
+        SystemInstance systemInstance = SystemInstance.get();
+        String format = systemInstance.getProperty(key);
+        if (format == null) {
+            systemInstance.setProperty(key, value);
+        }
+    }
+
+
     public String getSchemaNamespace() {
         return EjbModuleBuilder.OPENEJBJAR_NAMESPACE;
     }
@@ -175,12 +206,12 @@
 
         // Load the module file
         DeploymentLoader loader = new DeploymentLoader();
-        AppModule appModule = null;
+        AppModule appModule;
         try {
             appModule = loader.load(new File(moduleFile.getName()));
-        } catch (UnknownModuleTypeException e){
+        } catch (UnknownModuleTypeException e) {
             return null;
-        } catch (UnsupportedModuleTypeException e){
+        } catch (UnsupportedModuleTypeException e) {
             return null;
         } catch (OpenEJBException e) {
             Throwable t = e.getCause();
@@ -226,8 +257,7 @@
             }
             if (qname.getLocalPart().equals("openejb-jar")) {
                 ejbModule.getAltDDs().put("openejb-jar.xml", xmlCursor.xmlText());
-            } else
-            if (qname.getLocalPart().equals("ejb-jar") && qname.getNamespaceURI().equals("http://geronimo.apache.org/xml/ns/j2ee/ejb/openejb-2.0"))
{
+            } else if (qname.getLocalPart().equals("ejb-jar") && qname.getNamespaceURI().equals("http://geronimo.apache.org/xml/ns/j2ee/ejb/openejb-2.0"))
{
                 ejbModule.getAltDDs().put("geronimo-openejb.xml", xmlCursor.xmlText());
             }
         }
@@ -306,14 +336,14 @@
 
             for (Iterator<EjbRef> iterator = enterpriseBean.getEjbRef().iterator();
iterator.hasNext();) {
                 EjbRef ref = iterator.next();
-                 if (!corbaEjbRefs.contains(ref.getEjbRefName())) {
-                     // remove all non corba refs to avoid overwriting normal ejb refs
-                     iterator.remove();
-                 } else {
-                     // clear mapped named data from corba refs
+                if (!corbaEjbRefs.contains(ref.getEjbRefName())) {
+                    // remove all non corba refs to avoid overwriting normal ejb refs
+                    iterator.remove();
+                } else {
+                    // clear mapped named data from corba refs
                     ref.setMappedName(null);
                     ref.getInjectionTarget().clear();
-                 }
+                }
             }
 
             for (MessageDestinationRef ref : enterpriseBean.getMessageDestinationRef()) {
@@ -332,8 +362,7 @@
                 ref.setMappedName(null);
                 ref.getInjectionTarget().clear();
             }
-            for (Iterator<ResourceEnvRef> iterator = enterpriseBean.getResourceEnvRef().iterator();
iterator.hasNext();)
-            {
+            for (Iterator<ResourceEnvRef> iterator = enterpriseBean.getResourceEnvRef().iterator();
iterator.hasNext();) {
                 ResourceEnvRef ref = iterator.next();
                 if (ref.getType().equals(SessionContext.class.getName())) {
                     iterator.remove();
@@ -384,7 +413,7 @@
         }
         module.setEarContext(moduleContext);
         module.setRootEarContext(earContext);
-        if (((EjbModule)module).getEjbJar().getAssemblyDescriptor() != null) {
+        if (((EjbModule) module).getEjbJar().getAssemblyDescriptor() != null) {
             namingBuilder.buildEnvironment(null, null, module.getEnvironment());
         }
         for (ModuleBuilderExtension builder : moduleBuilderExtensions) {
@@ -433,7 +462,6 @@
 
     public void initContext(EARContext earContext, Module module, ClassLoader classLoader)
throws DeploymentException {
         EjbModule ejbModule = (EjbModule) module;
-        EarData earData = (EarData) earContext.getGeneralData().get(EarData.class);
 
         EjbJarInfo ejbJarInfo = getEjbJarInfo(earContext, ejbModule, classLoader);
 
@@ -513,17 +541,17 @@
             // (metadata complete) and it run the openejb verifier
             AppInfo appInfo;
             try {
-                appInfo = openEjbSystem.configureApplication(appModule);
+                appInfo = configureApplication(appModule, earContext.getConfiguration());
             } catch (ValidationFailedException set) {
                 StringBuilder sb = new StringBuilder();
-                sb.append("Jar failed validation: "+appModule.getModuleId());
+                sb.append("Jar failed validation: ").append(appModule.getModuleId());
 
                 for (ValidationError e : set.getErrors()) {
-                    sb.append(e.getPrefix() + " ... " + e.getComponentName() + ":\t" + e.getMessage(2));
+                    sb.append(e.getPrefix()).append(" ... ").append(e.getComponentName()).append(":\t").append(e.getMessage(2));
                 }
 
                 for (ValidationFailure e : set.getFailures()) {
-                    sb.append(e.getPrefix() + " ... " + e.getComponentName() + ":\t" + e.getMessage(2));
+                    sb.append(e.getPrefix()).append(" ... ").append(e.getComponentName()).append(":\t").append(e.getMessage(2));
                 }
 
                 throw new DeploymentException(sb.toString());
@@ -563,6 +591,80 @@
         return ejbJarInfo;
     }
 
+    private AppInfo configureApplication(AppModule appModule, Configuration configuration)
throws OpenEJBException {
+        OpenEjbConfiguration openEjbConfiguration = new OpenEjbConfiguration();
+        openEjbConfiguration.containerSystem = new ContainerSystemInfo();
+        openEjbConfiguration.facilities = new FacilitiesInfo();
+        boolean offline = true;
+        ConfigurationFactory configurationFactory = new ConfigurationFactory(offline, openEjbConfiguration);
+        ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
+        Thread.currentThread().setContextClassLoader(appModule.getClassLoader());
+        try {
+            addContainerInfos(configuration, openEjbConfiguration.containerSystem, configurationFactory);
+            addResourceAdapterMDBInfos(configuration, openEjbConfiguration.containerSystem,
configurationFactory);
+            //process resource adapters
+
+            return configurationFactory.configureApplication(appModule);
+        } finally {
+            Thread.currentThread().setContextClassLoader(oldClassLoader);
+        }
+    }
+
+    private void addContainerInfos(Configuration configuration, ContainerSystemInfo containerSystem,
ConfigurationFactory configurationFactory) throws OpenEJBException {
+        LinkedHashSet<GBeanData> containerDatas = configuration.findGBeanDatas(Collections.singleton(new
AbstractNameQuery(EjbContainer.class.getName())));
+        for (GBeanData containerData : containerDatas) {
+            Class<? extends ContainerInfo> infoClass = (Class<? extends ContainerInfo>)
containerData.getAttribute("infoType");
+            if (infoClass == null) {
+                String type = (String) containerData.getAttribute("type");
+                infoClass = EjbContainer.getInfoType(type);
+            }
+            String serviceId = (String) containerData.getAttribute("id");
+            Properties declaredProperties = (Properties) containerData.getAttribute("properties");
+            String providerId = (String) containerData.getAttribute("provider");
+            ContainerInfo containerInfo = configurationFactory.configureService(infoClass,
serviceId, declaredProperties, providerId, "Container");
+            containerSystem.containers.add(containerInfo);
+        }
+    }
+
+    private void addResourceAdapterMDBInfos(Configuration configuration, ContainerSystemInfo
containerSystem, ConfigurationFactory configurationFactory) throws OpenEJBException {
+        LinkedHashSet<GBeanData> resourceAdapterWrappers = configuration.findGBeanDatas(Collections.singleton(new
AbstractNameQuery(ResourceAdapterWrapperGBean.class.getName())));
+        for (GBeanData resourceAdapterWrapperData : resourceAdapterWrappers) {
+            String resourceAdapterId = getResourceAdapterId(resourceAdapterWrapperData.getAbstractName());
+            Map<String, String> messageListenerToActivationSpecMap = (Map<String,
String>) resourceAdapterWrapperData.getAttribute("messageListenerToActivationSpecMap");
+            for (Map.Entry<String, String> entry : messageListenerToActivationSpecMap.entrySet())
{
+                String messageListenerInterface = entry.getKey();
+                String activationSpecClass = entry.getValue();
+
+                // only process RA if not previously processed
+                String containerName = resourceAdapterId + "-" + messageListenerInterface;
+                // get default mdb config
+                ContainerInfo containerInfo = configurationFactory.configureService(MdbContainerInfo.class);
+                containerInfo.id = containerName;
+                containerInfo.displayName = containerName;
+
+                // set ra specific properties
+
+                try {
+                    containerInfo.properties.put("MessageListenerInterface",
+                        configuration.getConfigurationClassLoader().loadClass(messageListenerInterface));
+                } catch (ClassNotFoundException e) {
+                    throw new OpenEJBException("Could not load MessageListenerInterface "
+ messageListenerInterface + " in classloader: " + configuration.getConfigurationClassLoader(),
e);
+                }
+                try {
+                    containerInfo.properties.put("ActivationSpecClass",
+                        configuration.getConfigurationClassLoader().loadClass(activationSpecClass));
+                } catch (ClassNotFoundException e) {
+                    throw new OpenEJBException("Could not load ActivationSpecClass " + activationSpecClass
+ " in classloader: " + configuration.getConfigurationClassLoader(), e);
+                }
+                //TODO is this necessary????
+//                containerInfo.properties.put("ResourceAdapter", resourceAdapter);
+
+                containerSystem.containers.add(containerInfo);
+            }
+        }
+    }
+
+
     private void addGeronimmoOpenEJBPersistenceUnit(EjbModule ejbModule) {
         GeronimoEjbJarType geronimoEjbJarType = (GeronimoEjbJarType) ejbModule.getEjbModule().getAltDDs().get("geronimo-openejb.xml");
 
@@ -673,7 +775,7 @@
         OpenejbJarType openejbJarType = (OpenejbJarType) altDD;
         EjbJarInfo ejbJarInfo = ejbModule.getEjbJarInfo();
 
-        Map<String, MessageDrivenBeanInfo> mdbs =  new TreeMap<String, MessageDrivenBeanInfo>();
+        Map<String, MessageDrivenBeanInfo> mdbs = new TreeMap<String, MessageDrivenBeanInfo>();
         for (EnterpriseBeanInfo enterpriseBean : ejbJarInfo.enterpriseBeans) {
             if (enterpriseBean instanceof MessageDrivenBeanInfo) {
                 mdbs.put(enterpriseBean.ejbName, (MessageDrivenBeanInfo) enterpriseBean);
@@ -694,25 +796,19 @@
             }
 
             if (bean.getResourceAdapter() == null) {
-                throw new DeploymentException("Resource Adapter defined for MDB '" + bean.getEjbName()
+ "'");
+                throw new DeploymentException("No Resource Adapter defined for MDB '" + bean.getEjbName()
+ "'");
             }
 
             AbstractNameQuery resourceAdapterNameQuery = getResourceAdapterNameQuery(bean.getResourceAdapter());
-            AbstractName resourceAdapterAbstractName = null;
+            AbstractName resourceAdapterAbstractName;
             try {
                 resourceAdapterAbstractName = earContext.findGBean(resourceAdapterNameQuery);
             } catch (GBeanNotFoundException e) {
                 throw new DeploymentException("Resource Adapter for MDB '" + bean.getEjbName()
+ "'not found: " + resourceAdapterNameQuery, e);
             }
 
-            Map properties = resourceAdapterAbstractName.getName();
-            String shortName = (String) properties.get("name");
-            String moduleName = (String) properties.get("ResourceAdapterModule");
-            if (shortName != null && moduleName != null) {
-                messageDrivenBeanInfo.containerId = moduleName + "." + shortName + "-" +
messageDrivenBeanInfo.mdbInterface;
-            } else {
-                messageDrivenBeanInfo.containerId = resourceAdapterAbstractName.getObjectName().toString()
+ "-" + messageDrivenBeanInfo.mdbInterface;
-            }
+            String resourceAdapterId = getResourceAdapterId(resourceAdapterAbstractName);
+            messageDrivenBeanInfo.containerId = resourceAdapterId + "-" + messageDrivenBeanInfo.mdbInterface;
 
             // add a dependency from the module to the ra so we can be assured the mdb
             // container exists when this app is started
@@ -720,6 +816,17 @@
         }
     }
 
+    private String getResourceAdapterId(AbstractName resourceAdapterAbstractName) {
+        Map properties = resourceAdapterAbstractName.getName();
+        String shortName = (String) properties.get("name");
+        String moduleName = (String) properties.get("ResourceAdapterModule");
+        if (shortName != null && moduleName != null) {
+            return moduleName + "." + shortName;
+        } else {
+            return resourceAdapterAbstractName.getObjectName().toString();
+        }
+    }
+
     private static AbstractNameQuery getResourceAdapterNameQuery(ResourceLocatorType resourceLocator)
{
         if (resourceLocator.getResourceLink() != null) {
             Map<String, String> nameMap = new HashMap<String, String>();
@@ -741,7 +848,7 @@
         if (pattern.getModule() != null) {
             nameMap.put(NameFactory.RESOURCE_ADAPTER_MODULE, pattern.getModule());
         }
-        return new AbstractNameQuery(artifact, nameMap, (Set)null);
+        return new AbstractNameQuery(artifact, nameMap, (Set) null);
     }
 
     public static class EarData {
@@ -790,7 +897,6 @@
         infoBuilder.addAttribute("defaultEnvironment", Environment.class, true);
         infoBuilder.addAttribute("defaultCmpJTADataSource", String.class, true);
         infoBuilder.addAttribute("defaultCmpNonJTADataSource", String.class, true);
-        infoBuilder.addReference("OpenEjbSystem", OpenEjbSystem.class);
         infoBuilder.addReference("ModuleBuilderExtensions", ModuleBuilderExtension.class,
NameFactory.MODULE_BUILDER);
         infoBuilder.addReference("SecurityBuilders", NamespaceDrivenBuilder.class, NameFactory.MODULE_BUILDER);
         infoBuilder.addReference("ServiceBuilders", NamespaceDrivenBuilder.class, NameFactory.MODULE_BUILDER);
@@ -801,7 +907,6 @@
                 "defaultEnvironment",
                 "defaultCmpJTADataSource",
                 "defaultCmpNonJTADataSource",
-                "OpenEjbSystem",
                 "ModuleBuilderExtensions",
                 "SecurityBuilders",
                 "ServiceBuilders",

Modified: geronimo/server/trunk/modules/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/EjbContainer.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/EjbContainer.java?rev=579069&r1=579068&r2=579069&view=diff
==============================================================================
--- geronimo/server/trunk/modules/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/EjbContainer.java
(original)
+++ geronimo/server/trunk/modules/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/EjbContainer.java
Mon Sep 24 21:44:32 2007
@@ -79,7 +79,7 @@
         this.type = type;
     }
 
-    private Class<? extends ContainerInfo> getInfoType(String type) {
+    public static Class<? extends ContainerInfo> getInfoType(String type) {
         if ("STATELESS".equalsIgnoreCase(type)) return StatelessSessionContainerInfo.class;
         if ("STATEFUL".equalsIgnoreCase(type)) return StatefulSessionContainerInfo.class;
         if ("BMP_ENTITY".equalsIgnoreCase(type)) return BmpEntityContainerInfo.class;



Mime
View raw message