geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: r497324 - in /geronimo/server/trunk: configs/openejb/src/plan/ modules/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/ modules/geronimo-openejb-builder/src/test/java/org/apache/geronimo/openejb/deployment/ mod...
Date Thu, 18 Jan 2007 07:07:43 GMT
Author: dain
Date: Wed Jan 17 23:07:42 2007
New Revision: 497324

URL: http://svn.apache.org/viewvc?view=rev&rev=497324
Log:
Add container creation code and ref mapped names

Added:
    geronimo/server/trunk/modules/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/EjbContainer.java
Modified:
    geronimo/server/trunk/configs/openejb/src/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-builder/src/test/java/org/apache/geronimo/openejb/deployment/EjbModuleBuilderTest.java
    geronimo/server/trunk/modules/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/EjbDeployment.java
    geronimo/server/trunk/modules/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/OpenEjbSystem.java
    geronimo/server/trunk/modules/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/OpenEjbSystemGBean.java

Modified: geronimo/server/trunk/configs/openejb/src/plan/plan.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/configs/openejb/src/plan/plan.xml?view=diff&rev=497324&r1=497323&r2=497324
==============================================================================
--- geronimo/server/trunk/configs/openejb/src/plan/plan.xml (original)
+++ geronimo/server/trunk/configs/openejb/src/plan/plan.xml Wed Jan 17 23:07:42 2007
@@ -23,9 +23,22 @@
     <gbean name="OpenEjbSystem" class="org.apache.geronimo.openejb.OpenEjbSystemGBean">
         <reference name="TransactionManager">
             <name>TransactionManager</name>
-        </reference>        
+        </reference>
     </gbean>
 
+    <gbean name="DefaultStatelessContainer" class="org.apache.geronimo.openejb.EjbContainer">
+        <attribute name="id">Default Stateless Container</attribute>
+    </gbean>
+    <gbean name="DefaultStatefulContainer" class="org.apache.geronimo.openejb.EjbContainer">
+        <attribute name="id">Default Stateful Container</attribute>
+    </gbean>
+    <gbean name="DefaultBMPContainer" class="org.apache.geronimo.openejb.EjbContainer">
+        <attribute name="id">Default BMP Container</attribute>
+    </gbean>
+    <gbean name="DefaultCMPContainer" class="org.apache.geronimo.openejb.EjbContainer">
+        <attribute name="id">Default CMP Container</attribute>
+    </gbean>
+    
 <!--
     <gbean name="StatelessEjbContainer" class="org.apache.openejb.slsb.DefaultStatelessEjbContainerGBean">
         <reference name="TransactionManager">

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?view=diff&rev=497324&r1=497323&r2=497324
==============================================================================
--- 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
Wed Jan 17 23:07:42 2007
@@ -50,10 +50,10 @@
 import org.apache.geronimo.kernel.config.ConfigurationStore;
 import org.apache.geronimo.kernel.repository.Environment;
 import org.apache.geronimo.naming.deployment.ResourceEnvironmentSetter;
-import org.apache.geronimo.openejb.xbeans.ejbjar.OpenejbGeronimoEjbJarType;
+import org.apache.geronimo.openejb.EjbDeployment;
 import org.apache.geronimo.openejb.EjbModuleImplGBean;
 import org.apache.geronimo.openejb.OpenEjbSystem;
-import org.apache.geronimo.openejb.EjbDeployment;
+import org.apache.geronimo.openejb.xbeans.ejbjar.OpenejbGeronimoEjbJarType;
 import org.apache.geronimo.security.jacc.ComponentPermissions;
 import org.apache.geronimo.xbeans.geronimo.j2ee.GerSecurityDocument;
 import org.apache.geronimo.xbeans.javaee.AssemblyDescriptorType;
@@ -62,6 +62,15 @@
 import org.apache.openejb.alt.config.ejb.OpenejbJar;
 import org.apache.openejb.assembler.classic.EjbJarInfo;
 import org.apache.openejb.jee.EjbJar;
+import org.apache.openejb.jee.EjbLocalRef;
+import org.apache.openejb.jee.EjbRef;
+import org.apache.openejb.jee.EnterpriseBean;
+import org.apache.openejb.jee.MessageDestinationRef;
+import org.apache.openejb.jee.PersistenceContextRef;
+import org.apache.openejb.jee.PersistenceUnitRef;
+import org.apache.openejb.jee.ResourceEnvRef;
+import org.apache.openejb.jee.ResourceRef;
+import org.apache.openejb.jee.ServiceRef;
 import org.apache.xmlbeans.XmlCursor;
 import org.apache.xmlbeans.XmlObject;
 
@@ -73,6 +82,7 @@
  */
 public class EjbModuleBuilder implements ModuleBuilder {
     private static final String OPENEJBJAR_NAMESPACE = XmlUtil.OPENEJBJAR_QNAME.getNamespaceURI();
+    private static final String MAPPED_NAME_PREFIX = "java:/comp/geronimo/";
 
     private final Environment defaultEnvironment;
     private final Collection webServiceBuilders;
@@ -167,6 +177,9 @@
             namingBuilder.buildEnvironment(assemblyDescriptor, geronimoOpenejb, environment);
         }
 
+        // set mapped name or all refs
+        mapReferences(ejbJar);
+
         //overridden web service locations
         Map correctedPortLocations = new HashMap();
 
@@ -195,6 +208,44 @@
 
         return new EjbModule(standAlone, moduleName, environment, moduleFile, targetPath,
ejbJar, openejbJar, geronimoOpenejb, ejbJarXml, sharedContext);
     }
+
+    private static void mapReferences(EjbJar ejbJar) {
+        for (EnterpriseBean enterpriseBean : ejbJar.getEnterpriseBeans()) {
+            for (EjbRef ref : enterpriseBean.getEjbRef()) {
+                String refName = ref.getEjbRefName();
+                ref.setMappedName(MAPPED_NAME_PREFIX + refName);
+            }
+            for (EjbLocalRef ref : enterpriseBean.getEjbLocalRef()) {
+                String refName = ref.getEjbRefName();
+                ref.setMappedName(MAPPED_NAME_PREFIX + refName);
+            }
+            for (MessageDestinationRef ref : enterpriseBean.getMessageDestinationRef()) {
+                String refName = ref.getMessageDestinationRefName();
+                ref.setMappedName(MAPPED_NAME_PREFIX + refName);
+            }
+            for (PersistenceContextRef ref : enterpriseBean.getPersistenceContextRef()) {
+                String refName = ref.getPersistenceContextRefName();
+                ref.setMappedName(MAPPED_NAME_PREFIX + refName);
+            }
+            for (PersistenceUnitRef ref : enterpriseBean.getPersistenceUnitRef()) {
+                String refName = ref.getPersistenceUnitRefName();
+                ref.setMappedName(MAPPED_NAME_PREFIX + refName);
+            }
+            for (ResourceRef ref : enterpriseBean.getResourceRef()) {
+                String refName = ref.getResRefName();
+                ref.setMappedName(MAPPED_NAME_PREFIX + refName);
+            }
+            for (ResourceEnvRef ref : enterpriseBean.getResourceEnvRef()) {
+                String refName = ref.getResourceEnvRefName();
+                ref.setMappedName(MAPPED_NAME_PREFIX + refName);
+            }
+            for (ServiceRef ref : enterpriseBean.getServiceRef()) {
+                String refName = ref.getServiceRefName();
+                ref.setMappedName(MAPPED_NAME_PREFIX + refName);
+            }
+        }
+    }
+
 
     public void installModule(JarFile earFile, EARContext earContext, Module module, Collection
configurationStores, ConfigurationStore targetConfigurationStore, Collection repository) throws
DeploymentException {
         installModule(module, earContext);

Modified: geronimo/server/trunk/modules/geronimo-openejb-builder/src/test/java/org/apache/geronimo/openejb/deployment/EjbModuleBuilderTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-openejb-builder/src/test/java/org/apache/geronimo/openejb/deployment/EjbModuleBuilderTest.java?view=diff&rev=497324&r1=497323&r2=497324
==============================================================================
--- geronimo/server/trunk/modules/geronimo-openejb-builder/src/test/java/org/apache/geronimo/openejb/deployment/EjbModuleBuilderTest.java
(original)
+++ geronimo/server/trunk/modules/geronimo-openejb-builder/src/test/java/org/apache/geronimo/openejb/deployment/EjbModuleBuilderTest.java
Wed Jan 17 23:07:42 2007
@@ -17,13 +17,13 @@
 package org.apache.geronimo.openejb.deployment;
 
 import java.io.File;
-import java.util.jar.JarFile;
-import java.net.URLClassLoader;
 import java.net.URL;
-
+import java.net.URLClassLoader;
+import java.util.jar.JarFile;
 import javax.transaction.TransactionManager;
 
 import junit.framework.TestCase;
+import org.apache.geronimo.openejb.EjbContainer;
 import org.apache.geronimo.openejb.OpenEjbSystem;
 import org.apache.geronimo.openejb.OpenEjbSystemGBean;
 import org.apache.geronimo.transaction.manager.GeronimoTransactionManager;
@@ -38,13 +38,18 @@
 public class EjbModuleBuilderTest extends TestCase {
     public void test() throws Exception {
         // create reference to openejb itests
-        File file = new File(System.getProperty("user.home") + ".m2/repository/org/apache/openejb/openejb-itests-beans/3.0-incubating-SNAPSHOT/openejb-itests-beans-3.0-incubating-SNAPSHOT.jar");
+        File file = new File(System.getProperty("user.home") + "/.m2/repository/org/apache/openejb/openejb-itests-beans/3.0-incubating-SNAPSHOT/openejb-itests-beans-3.0-incubating-SNAPSHOT.jar");
         if (!file.canRead()) return;
         JarFile moduleFile = new JarFile(file);
 
         TransactionManager transactionManager = new GeronimoTransactionManager();
         OpenEjbSystem openEjbSystem = new OpenEjbSystemGBean(transactionManager);
 
+        addEjbContainer(openEjbSystem, "Default Stateless Container");
+        addEjbContainer(openEjbSystem, "Default Stateful Container");
+        addEjbContainer(openEjbSystem, "Default BMP Container");
+        addEjbContainer(openEjbSystem, "Default CMP Container");
+
         // load ejb-jar.xml
         String ejbJarXml = XmlUtil.loadEjbJarXml(null, moduleFile);
         assertNotNull(ejbJarXml);
@@ -59,9 +64,15 @@
         EjbModule ejbModule = new EjbModule(classLoader, moduleFile.getName(), ejbJar, openejbJar);
 
         // configure the application
-        EjbJarInfo ejbJarInfo = openEjbSystem.configureApplication(ejbModule);
+//        EjbJarInfo ejbJarInfo = openEjbSystem.configureApplication(ejbModule);
 
-        openEjbSystem.createEjbJar(ejbJarInfo, classLoader);
+//        openEjbSystem.createEjbJar(ejbJarInfo, classLoader);
+    }
 
+    private void addEjbContainer(OpenEjbSystem openEjbSystem, String id) throws Exception
{
+        EjbContainer ejbContainer = new EjbContainer();
+        ejbContainer.setOpenEjbSystem(openEjbSystem);
+        ejbContainer.setId(id);
+        ejbContainer.doStart();
     }
 }

Added: 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?view=auto&rev=497324
==============================================================================
--- geronimo/server/trunk/modules/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/EjbContainer.java
(added)
+++ geronimo/server/trunk/modules/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/EjbContainer.java
Wed Jan 17 23:07:42 2007
@@ -0,0 +1,101 @@
+/**
+ * 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
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  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.
+ */
+package org.apache.geronimo.openejb;
+
+import java.util.Properties;
+
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.GBeanInfoBuilder;
+import org.apache.geronimo.gbean.GBeanLifecycle;
+import org.apache.openejb.assembler.classic.ContainerInfo;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class EjbContainer implements GBeanLifecycle {
+    private OpenEjbSystem openEjbSystem;
+    private String id;
+    private Properties properties;
+    private String provider;
+    private Class<ContainerInfo> type = ContainerInfo.class;
+
+    public OpenEjbSystem getOpenEjbSystem() {
+        return openEjbSystem;
+    }
+
+    public void setOpenEjbSystem(OpenEjbSystem openEjbSystem) {
+        this.openEjbSystem = openEjbSystem;
+    }
+
+    public String getId() {
+        return id;
+    }
+
+    public void setId(String id) {
+        this.id = id;
+    }
+
+    public Properties getProperties() {
+        return properties;
+    }
+
+    public void setProperties(Properties properties) {
+        this.properties = properties;
+    }
+
+    public String getProvider() {
+        return provider;
+    }
+
+    public void setProvider(String provider) {
+        this.provider = provider;
+    }
+
+    public Class<ContainerInfo> getType() {
+        return type;
+    }
+
+    public void setType(Class<ContainerInfo> type) {
+        this.type = type;
+    }
+
+    public void doStart() throws Exception {
+        openEjbSystem.createContainer(type, id, properties, provider);
+    }
+
+    public void doStop() throws Exception {
+    }
+
+    public void doFail() {
+    }
+
+    public static final GBeanInfo GBEAN_INFO;
+
+    static {
+        GBeanInfoBuilder infoBuilder = GBeanInfoBuilder.createStatic(EjbContainer.class);
+        infoBuilder.addReference("OpenEjbSystem", OpenEjbSystem.class);
+        infoBuilder.addAttribute("id", String.class, true);
+        infoBuilder.addAttribute("properties", Properties.class, true);
+        infoBuilder.addAttribute("provider", String.class, true);
+        infoBuilder.addAttribute("type", Class.class, true);
+        GBEAN_INFO = infoBuilder.getBeanInfo();
+    }
+
+    public static GBeanInfo getGBeanInfo() {
+        return GBEAN_INFO;
+    }
+}

Modified: geronimo/server/trunk/modules/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/EjbDeployment.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/EjbDeployment.java?view=diff&rev=497324&r1=497323&r2=497324
==============================================================================
--- geronimo/server/trunk/modules/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/EjbDeployment.java
(original)
+++ geronimo/server/trunk/modules/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/EjbDeployment.java
Wed Jan 17 23:07:42 2007
@@ -136,7 +136,7 @@
     }
 
     public Context getComponentContext() {
-        return componentContext;
+        return deploymentInfo.getJndiEnc();
     }
 
     public Set getUnshareableResources() {
@@ -175,8 +175,9 @@
         return true;
     }
 
-    protected void start() {
+    protected void start() throws Exception {
         deploymentInfo = (CoreDeploymentInfo) openEjbSystem.getDeploymentInfo(deploymentId);
+        deploymentInfo.getJndiEnc().bind("geronimo", componentContext);
         if (deploymentInfo == null) {
             throw new IllegalStateException("Ejb does not exist " + deploymentId);
         }

Modified: geronimo/server/trunk/modules/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/OpenEjbSystem.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/OpenEjbSystem.java?view=diff&rev=497324&r1=497323&r2=497324
==============================================================================
--- geronimo/server/trunk/modules/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/OpenEjbSystem.java
(original)
+++ geronimo/server/trunk/modules/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/OpenEjbSystem.java
Wed Jan 17 23:07:42 2007
@@ -27,6 +27,7 @@
 import org.apache.openejb.alt.config.EjbModule;
 import org.apache.openejb.assembler.classic.ClientInfo;
 import org.apache.openejb.assembler.classic.EjbJarInfo;
+import org.apache.openejb.assembler.classic.ContainerInfo;
 import org.apache.openejb.spi.ContainerSystem;
 
 /**
@@ -35,7 +36,7 @@
 public interface OpenEjbSystem {
     ContainerSystem getContainerSystem();
 
-    Container createContainer(String serviceId, Properties declaredProperties, String providerId,
String serviceType) throws OpenEJBException;
+    Container createContainer(Class<? extends ContainerInfo> type, String serviceId,
Properties declaredProperties, String providerId) throws OpenEJBException;
 
     ClientInfo configureApplication(ClientModule clientModule) throws OpenEJBException;
 

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=497324&r1=497323&r2=497324
==============================================================================
--- 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
Wed Jan 17 23:07:42 2007
@@ -16,27 +16,26 @@
  */
 package org.apache.geronimo.openejb;
 
-import java.util.Properties;
 import java.io.IOException;
-
+import java.util.Properties;
 import javax.naming.NamingException;
 import javax.transaction.TransactionManager;
 
-import org.apache.openejb.alt.config.ConfigurationFactory;
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.GBeanInfoBuilder;
+import org.apache.openejb.Container;
+import org.apache.openejb.DeploymentInfo;
+import org.apache.openejb.OpenEJBException;
 import org.apache.openejb.alt.config.ClientModule;
+import org.apache.openejb.alt.config.ConfigurationFactory;
 import org.apache.openejb.alt.config.EjbModule;
 import org.apache.openejb.assembler.classic.Assembler;
-import org.apache.openejb.assembler.classic.ContainerInfo;
 import org.apache.openejb.assembler.classic.ClientInfo;
+import org.apache.openejb.assembler.classic.ContainerInfo;
 import org.apache.openejb.assembler.classic.EjbJarInfo;
 import org.apache.openejb.assembler.classic.TransactionServiceInfo;
 import org.apache.openejb.assembler.dynamic.PassthroughFactory;
 import org.apache.openejb.spi.ContainerSystem;
-import org.apache.openejb.Container;
-import org.apache.openejb.OpenEJBException;
-import org.apache.openejb.DeploymentInfo;
-import org.apache.geronimo.gbean.GBeanInfo;
-import org.apache.geronimo.gbean.GBeanInfoBuilder;
 
 /**
  * @version $Rev$ $Date$
@@ -45,8 +44,10 @@
     private final ConfigurationFactory configurationFactory;
     private final Assembler assembler;
 
-    public OpenEjbSystemGBean(TransactionManager transactionManager) throws OpenEJBException
{
-        if (transactionManager == null) throw new NullPointerException("transactionManager
is null");
+    public OpenEjbSystemGBean(TransactionManager transactionManager) throws Exception {
+        if (transactionManager == null) {
+            throw new NullPointerException("transactionManager is null");
+        }
 
         configurationFactory = new ConfigurationFactory();
         assembler = new Assembler();
@@ -67,8 +68,8 @@
         return assembler.getContainerSystem();
     }
 
-    public Container createContainer(String serviceId, Properties declaredProperties, String
providerId, String serviceType) throws OpenEJBException {
-        ContainerInfo containerInfo = configurationFactory.configureService(ContainerInfo.class,
serviceId, declaredProperties, providerId, ContainerInfo.class.getSimpleName());
+    public Container createContainer(Class<? extends ContainerInfo> type, String serviceId,
Properties declaredProperties, String providerId) throws OpenEJBException {
+        ContainerInfo containerInfo = configurationFactory.configureService(type, serviceId,
declaredProperties, providerId, "Container");
         assembler.createContainer(containerInfo);
         Container container = assembler.getContainerSystem().getContainer(serviceId);
         return container;
@@ -123,7 +124,9 @@
     static {
         GBeanInfoBuilder infoBuilder = GBeanInfoBuilder.createStatic(OpenEjbSystemGBean.class);
         infoBuilder.addReference("TransactionManager", TransactionManager.class);
-        infoBuilder.setConstructor(new String[] {"TransactionManager"});
+        infoBuilder.setConstructor(new String[] {
+                "TransactionManager",
+        });
         GBEAN_INFO = infoBuilder.getBeanInfo();
     }
 



Mime
View raw message