geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: r504434 - in /geronimo/server/trunk/modules: geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/ geronimo-openejb-builder/src/test/java/org/apache/geronimo/openejb/deployment/ geronimo-openejb/src/main/java/org/ap...
Date Wed, 07 Feb 2007 05:06:14 GMT
Author: dain
Date: Tue Feb  6 21:06:13 2007
New Revision: 504434

URL: http://svn.apache.org/viewvc?view=rev&rev=504434
Log:
Fixed many, many, many bugs with the OpenEJB2 to OpenEJB3 converter

Removed:
    geronimo/server/trunk/modules/geronimo-openejb-builder/src/test/java/org/apache/geronimo/openejb/deployment/EjbModuleBuilderTest.java
    geronimo/server/trunk/modules/geronimo-openejb-builder/src/test/java/org/apache/geronimo/openejb/deployment/XmlUtilTest.java
Modified:
    geronimo/server/trunk/modules/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbModule.java
    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/main/java/org/apache/geronimo/openejb/deployment/XmlUtil.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
    geronimo/server/trunk/modules/geronimo-persistence-jpa10/src/main/java/org/apache/geronimo/persistence/PersistenceUnitGBean.java

Modified: geronimo/server/trunk/modules/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbModule.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbModule.java?view=diff&rev=504434&r1=504433&r2=504434
==============================================================================
--- geronimo/server/trunk/modules/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbModule.java
(original)
+++ geronimo/server/trunk/modules/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbModule.java
Tue Feb  6 21:06:13 2007
@@ -26,6 +26,7 @@
 import org.apache.openejb.jee.oejb3.OpenejbJar;
 import org.apache.openejb.assembler.classic.EjbJarInfo;
 import org.apache.openejb.jee.EjbJar;
+import org.apache.openejb.jee.oejb2.GeronimoEjbJarType;
 import org.apache.xmlbeans.XmlObject;
 
 /**
@@ -34,17 +35,14 @@
 public class EjbModule extends EJBModule {
     private String originalSpecDD;
     private XmlObject specDD;
-    private ClassLoader classLoader;
-    private final EjbJar ejbJar;
-    private final OpenejbJar openejbJar;
     private EjbJarInfo ejbJarInfo;
     private EjbDeploymentBuilder ejbDeploymentBuilder;
+    private OpenejbGeronimoEjbJarType vendorDD;
+    private final org.apache.openejb.config.EjbModule ejbModule;
 
-    public EjbModule(boolean standAlone, AbstractName moduleName, Environment environment,
JarFile moduleFile, String targetPath, EjbJar ejbJar, OpenejbJar openejbJar, OpenejbGeronimoEjbJarType
geronimoOpenejb, String ejbJarXml, Map sharedContext) {
-        super(standAlone, moduleName, environment, moduleFile, targetPath, null, geronimoOpenejb,
ejbJarXml, sharedContext);
-        this.ejbJar = ejbJar;
-        this.openejbJar = openejbJar;
-
+    public EjbModule(org.apache.openejb.config.EjbModule ejbModule, boolean standAlone, AbstractName
moduleName, Environment environment, JarFile moduleFile, String targetPath, String ejbJarXml,
Map sharedContext) {
+        super(standAlone, moduleName, environment, moduleFile, targetPath, null, null, ejbJarXml,
sharedContext);
+        this.ejbModule = ejbModule;
     }
 
     @Override
@@ -65,8 +63,17 @@
         this.specDD = specDD;
     }
 
+    @Override
+    public OpenejbGeronimoEjbJarType getVendorDD() {
+        return vendorDD;
+    }
+
+    public void setVendorDD(OpenejbGeronimoEjbJarType vendorDD) {
+        this.vendorDD = vendorDD;
+    }
+
     public org.apache.openejb.config.EjbModule getEjbModule() {
-        return new org.apache.openejb.config.EjbModule(classLoader, getModuleFile().getName(),
ejbJar,  openejbJar);
+        return ejbModule;
     }
 
     public EjbJarInfo getEjbJarInfo() {
@@ -86,18 +93,18 @@
     }
 
     public EjbJar getEjbJar() {
-        return ejbJar;
+        return ejbModule.getEjbJar();
     }
 
     public OpenejbJar getOpenejbJar() {
-        return openejbJar;
+        return ejbModule.getOpenejbJar();
     }
 
     public ClassLoader getClassLoader() {
-        return classLoader;
+        return ejbModule.getClassLoader();
     }
 
     public void setClassLoader(ClassLoader classLoader) {
-        this.classLoader = classLoader;
+        ejbModule.setClassLoader(classLoader);
     }
 }

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=504434&r1=504433&r2=504434
==============================================================================
--- 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
Tue Feb  6 21:06:13 2007
@@ -16,31 +16,14 @@
  */
 package org.apache.geronimo.openejb.deployment;
 
-import java.io.File;
-import java.io.IOException;
-import java.net.URI;
-import java.net.URL;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.List;
-import java.util.ArrayList;
-import java.util.jar.JarFile;
-
-import javax.ejb.SessionContext;
-import javax.ejb.EntityContext;
-import javax.xml.namespace.QName;
-
 import org.apache.geronimo.common.DeploymentException;
 import org.apache.geronimo.deployment.ModuleIDBuilder;
 import org.apache.geronimo.deployment.NamespaceDrivenBuilder;
 import org.apache.geronimo.deployment.NamespaceDrivenBuilderCollection;
-import org.apache.geronimo.deployment.xmlbeans.XmlBeansUtil;
 import org.apache.geronimo.deployment.service.EnvironmentBuilder;
 import org.apache.geronimo.deployment.service.GBeanBuilder;
 import org.apache.geronimo.deployment.xbeans.EnvironmentType;
+import org.apache.geronimo.deployment.xmlbeans.XmlBeansUtil;
 import org.apache.geronimo.gbean.AbstractName;
 import org.apache.geronimo.gbean.AbstractNameQuery;
 import org.apache.geronimo.gbean.GBeanData;
@@ -66,12 +49,12 @@
 import org.apache.geronimo.xbeans.javaee.AssemblyDescriptorType;
 import org.apache.geronimo.xbeans.javaee.EjbJarType;
 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.EjbJarInfo;
+import org.apache.openejb.config.AppModule;
 import org.apache.openejb.config.DeploymentLoader;
 import org.apache.openejb.config.ReadDescriptors;
-import org.apache.openejb.config.AppModule;
-import org.apache.openejb.assembler.classic.EjbJarInfo;
-import org.apache.openejb.assembler.classic.CmpJarBuilder;
-import org.apache.openejb.assembler.classic.AppInfo;
 import org.apache.openejb.jee.EjbJar;
 import org.apache.openejb.jee.EnterpriseBean;
 import org.apache.openejb.jee.MessageDestinationRef;
@@ -80,13 +63,27 @@
 import org.apache.openejb.jee.ResourceEnvRef;
 import org.apache.openejb.jee.ResourceRef;
 import org.apache.openejb.jee.ServiceRef;
-import org.apache.openejb.jee.oejb3.OpenejbJar;
+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.GeronimoEjbJarType;
-import org.apache.xmlbeans.XmlObject;
-import org.apache.xmlbeans.XmlException;
 import org.apache.xmlbeans.XmlCursor;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.apache.xmlbeans.XmlObject;
+
+import javax.ejb.EntityContext;
+import javax.ejb.SessionContext;
+import javax.xml.namespace.QName;
+import java.io.File;
+import java.io.IOException;
+import java.net.URI;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.jar.JarFile;
 
 /**
  * Master builder for processing EJB JAR deployments and creating the
@@ -95,7 +92,6 @@
  * @version $Revision: 479481 $ $Date: 2006-11-26 16:52:20 -0800 (Sun, 26 Nov 2006) $
  */
 public class EjbModuleBuilder implements ModuleBuilder {
-    private static final Log log = LogFactory.getLog(EjbModuleBuilder.class);
     private static final String OPENEJBJAR_NAMESPACE = XmlUtil.OPENEJBJAR_QNAME.getNamespaceURI();
 
     private final Environment defaultEnvironment;
@@ -136,23 +132,15 @@
     }
 
     private Module createModule(Object plan, JarFile moduleFile, String targetPath, URL specDDUrl,
Environment earEnvironment, AbstractName earName, Naming naming, ModuleIDBuilder idBuilder)
throws DeploymentException {
-        if (moduleFile == null) {
-            throw new NullPointerException("moduleFile is null");
-        }
-        if (targetPath == null) {
-            throw new NullPointerException("targetPath is null");
-        }
-        if (targetPath.endsWith("/")) {
-            throw new IllegalArgumentException("targetPath must not end with a '/'");
-        }
-
+        if (moduleFile == null) throw new NullPointerException("moduleFile is null");
+        if (targetPath == null) throw new NullPointerException("targetPath is null");
+        if (targetPath.endsWith("/")) throw new IllegalArgumentException("targetPath must
not end with a '/'");
 
+        // Load the module file
         DeploymentLoader loader = new DeploymentLoader();
-        File file = new File(moduleFile.getName());
-
         AppModule appModule = null;
         try {
-            appModule = loader.load(file);
+            appModule = loader.load(new File(moduleFile.getName()));
         } catch (OpenEJBException e) {
             if (e.getMessage().startsWith("Unsupported module type")){
                 return null;
@@ -160,16 +148,21 @@
             throw new DeploymentException(e);
         }
 
+        // did we find a ejb jar?
         if (appModule.getEjbModules().size() == 0){
-            // not an ejb module
             return null;
         }
 
+        // get the module
         org.apache.openejb.config.EjbModule ejbModule = appModule.getEjbModules().get(0);
 
+        // add the ejb-jar.xml altDD plan
+        if (specDDUrl != null) {
+            ejbModule.getAltDDs().put("ejb-jar.xml", specDDUrl);
+        }
 
+        // convert the vendor plan object to the ejbModule altDD map
         XmlObject unknownXmlObject = null;
-
         if (plan instanceof XmlObject) {
             unknownXmlObject = (XmlObject) plan;
         } else if (plan != null) {
@@ -191,57 +184,29 @@
             }
         }
 
-        if (specDDUrl != null) {
-            ejbModule.getAltDDs().put("ejb-jar.xml", specDDUrl);
-        }
-
+        // Read in the deploument desiptor files
         ReadDescriptors readDescriptors = new ReadDescriptors();
-
         try {
             readDescriptors.deploy(appModule);
         } catch (OpenEJBException e) {
             throw new DeploymentException("Failed parsing descriptors for module: "+moduleFile.getName(),
e);
         }
 
-        EjbJar ejbJar = ejbModule.getEjbJar();
-        OpenejbJar openejbJar = ejbModule.getOpenejbJar();
-
-        OpenejbGeronimoEjbJarType geronimoOpenejb;
-
 
+        // Get the geronimo-openejb.xml tree
         boolean standAlone = earEnvironment == null;
-
-        GeronimoEjbJarType jaxbGeronimoOpenejb = (GeronimoEjbJarType) ejbModule.getAltDDs().get("geronimo-openejb.xml");
-        if (jaxbGeronimoOpenejb != null) {
-            geronimoOpenejb = XmlUtil.convertToXmlbeans(jaxbGeronimoOpenejb);
-        } else {
+        GeronimoEjbJarType geronimoEjbJarType = (GeronimoEjbJarType) ejbModule.getAltDDs().get("geronimo-openejb.xml");
+        if (geronimoEjbJarType == null) {
+            // create default plan
             String path = (standAlone)? new File(moduleFile.getName()).getName(): targetPath;
-            geronimoOpenejb = XmlUtil.createDefaultPlan(path, ejbJar);
+            geronimoEjbJarType = XmlUtil.createDefaultPlan(path, ejbModule.getEjbJar());
+            ejbModule.getAltDDs().put("geronimo-openejb.xml", geronimoEjbJarType);
         }
 
-        // initialize the geronimo environment
-        EnvironmentType environmentType = geronimoOpenejb.getEnvironment();
-        Environment environment = EnvironmentBuilder.buildEnvironment(environmentType, defaultEnvironment);
-        if (earEnvironment != null) {
-            EnvironmentBuilder.mergeEnvironments(earEnvironment, environment);
-            environment = earEnvironment;
-            if (!environment.getConfigId().isResolved()) {
-                throw new IllegalStateException("EJB module ID should be fully resolved (not
" + environment.getConfigId() + ")");
-            }
-        } else {
-            idBuilder.resolve(environment, new File(moduleFile.getName()).getName(), "jar");
-        }
-
-        // todo THIS WILL NOT WORK WITH ANNOTATIONS... move this to initContext when naming
is fixed
-        // since assembly descriptor will only be valid once metadata complete
-        // which is only available once a class loader has been constructed in the init phase
-        EjbJarType ejbJarType = XmlUtil.convertToXmlbeans(ejbJar);
-        if (ejbJar.getAssemblyDescriptor() != null) {
-            AssemblyDescriptorType assemblyDescriptor = ejbJarType.getAssemblyDescriptor();
-            namingBuilder.buildEnvironment(assemblyDescriptor, geronimoOpenejb, environment);
-        }
+        // create the geronimo environment object
+        Environment environment = createEnvironment(ejbModule, geronimoEjbJarType, moduleFile,
earEnvironment, idBuilder);
 
-        //overridden web service locations
+        // overridden web service locations
         Map correctedPortLocations = new HashMap();
 
         // todo
@@ -267,7 +232,33 @@
             moduleName = naming.createChildName(earName, targetPath, NameFactory.EJB_MODULE);
         }
 
-        return new EjbModule(standAlone, moduleName, environment, moduleFile, targetPath,
ejbJar, openejbJar, geronimoOpenejb, "", sharedContext);
+        return new EjbModule(ejbModule, standAlone, moduleName, environment, moduleFile,
targetPath, "", sharedContext);
+    }
+
+    private Environment createEnvironment(org.apache.openejb.config.EjbModule ejbModule,
GeronimoEjbJarType jaxbGeronimoOpenejb, JarFile moduleFile, Environment earEnvironment, ModuleIDBuilder
idBuilder) throws DeploymentException {
+        OpenejbGeronimoEjbJarType geronimoOpenejb;
+        geronimoOpenejb = XmlUtil.convertToXmlbeans(jaxbGeronimoOpenejb);
+        EnvironmentType environmentType = geronimoOpenejb.getEnvironment();
+        Environment environment = EnvironmentBuilder.buildEnvironment(environmentType, defaultEnvironment);
+        if (earEnvironment != null) {
+            EnvironmentBuilder.mergeEnvironments(earEnvironment, environment);
+            environment = earEnvironment;
+            if (!environment.getConfigId().isResolved()) {
+                throw new IllegalStateException("EJB module ID should be fully resolved (not
" + environment.getConfigId() + ")");
+            }
+        } else {
+            idBuilder.resolve(environment, new File(moduleFile.getName()).getName(), "jar");
+        }
+
+        // todo THIS WILL NOT WORK WITH ANNOTATIONS... move this to initContext when naming
is fixed
+        // since assembly descriptor will only be valid once metadata complete
+        // which is only available once a class loader has been constructed in the init phase
+        if (ejbModule.getEjbJar().getAssemblyDescriptor() != null) {
+            EjbJarType ejbJarType = XmlUtil.convertToXmlbeans(ejbModule.getEjbJar());
+            AssemblyDescriptorType assemblyDescriptor = ejbJarType.getAssemblyDescriptor();
+            namingBuilder.buildEnvironment(assemblyDescriptor, geronimoOpenejb, environment);
+        }
+        return environment;
     }
 
     protected static void unmapReferences(EjbJar ejbJar) {
@@ -335,9 +326,13 @@
         // build the config info tree
         // this method fills in the ejbJar jaxb tree based on the annotations
         // (metadata complete) and it run the openejb verifier
+        AppModule appModule = new AppModule(ejbModule.getEjbModule().getClassLoader(), ejbModule.getEjbModule().getModuleId());
+        appModule.getEjbModules().add(ejbModule.getEjbModule());
+        AppInfo appInfo;
         EjbJarInfo ejbJarInfo;
         try {
-            ejbJarInfo = openEjbSystem.configureApplication(ejbModule.getEjbModule());
+            appInfo = openEjbSystem.configureApplication(appModule);
+            ejbJarInfo = appInfo.ejbJars.get(0);
             ejbModule.setEjbJarInfo(ejbJarInfo);
         } catch (OpenEJBException e) {
             e.printStackTrace();
@@ -352,8 +347,6 @@
 
         // generate the CMP2 implementation classes
         // Generate the cmp2 concrete subclasses
-        AppInfo appInfo = new AppInfo();
-        appInfo.ejbJars.add(ejbJarInfo);
         CmpJarBuilder cmp2Builder = new CmpJarBuilder(appInfo, classLoader);
         try {
             File generatedJar = cmp2Builder.getJarFile();
@@ -380,11 +373,19 @@
         EjbJarType ejbJarType = XmlUtil.convertToXmlbeans(ejbJar);
         ejbModule.setSpecDD(ejbJarType);
 
+        // add the cmp persistence unit if needed
+        GeronimoEjbJarType geronimoEjbJarType = (GeronimoEjbJarType) ejbModule.getEjbModule().getAltDDs().get("geronimo-openejb.xml");
+        if (appInfo.cmpMappingsXml != null) {
+            addGeronimmoOpenEJBPersistenceUnit(ejbModule, geronimoEjbJarType);
+        }
+
+        // convert the plan to xmlbeans since geronimo naming is coupled on xmlbeans objects
+        OpenejbGeronimoEjbJarType geronimoOpenejb = XmlUtil.convertToXmlbeans(geronimoEjbJarType);
+        ejbModule.setVendorDD(geronimoOpenejb);
 
         // todo move namingBuilders.buildEnvironment() here when geronimo naming supports
it
 
         // initialize the naming builders
-        OpenejbGeronimoEjbJarType geronimoOpenejb = (OpenejbGeronimoEjbJarType) ejbModule.getVendorDD();
         if (ejbJarType.getAssemblyDescriptor() != null) {
             namingBuilder.initContext(ejbJarType.getAssemblyDescriptor(),
                     geronimoOpenejb,
@@ -402,6 +403,48 @@
 
         // Add extra gbean declared in the geronimo-openejb.xml file
         serviceBuilders.build(geronimoOpenejb, earContext, ejbModule.getEarContext());
+    }
+
+    private void addGeronimmoOpenEJBPersistenceUnit(EjbModule ejbModule, GeronimoEjbJarType
geronimoEjbJarType) {
+        // search for the cmp persistence unit
+        PersistenceUnit persistenceUnit = null;
+        for (Persistence persistence : geronimoEjbJarType.getPersistence()) {
+            for (PersistenceUnit unit : persistence.getPersistenceUnit()) {
+                if ("cmp".equals(unit.getName())) {
+                    persistenceUnit = unit;
+                    break;
+                }
+
+            }
+        }
+
+        // if not found create one
+        if (persistenceUnit == null) {
+            String jtaDataSource = null;
+            Object altDD = ejbModule.getEjbModule().getAltDDs().get("openejb-jar.xml");
+            // todo Persistence Unit Data Sources need to be global JNDI names
+            // if (altDD instanceof OpenejbJarType) {
+            //     String datasourceName = ((OpenejbJarType) altDD).getCmpConnectionFactory().getResourceLink();
+            //     jtaDataSource = "?name=" + datasourceName;
+            // }
+
+            persistenceUnit = new PersistenceUnit();
+            persistenceUnit.setName("cmp");
+            persistenceUnit.setTransactionType(TransactionType.JTA);
+            if (jtaDataSource != null) {
+                persistenceUnit.setJtaDataSource(jtaDataSource);
+            } else {
+                persistenceUnit.setJtaDataSource("?name=SystemDatasource");
+                persistenceUnit.setNonJtaDataSource("?name=NoTxDatasource");
+            }
+
+            Persistence persistence = new Persistence();
+            persistence.setVersion("1.0");
+            persistence.getPersistenceUnit().add(persistenceUnit);
+
+            geronimoEjbJarType.getPersistence().add(persistence);
+        }
+        persistenceUnit.getMappingFile().add("META-INF/openejb-cmp-generated-orm.xml");
     }
 
     /**

Modified: geronimo/server/trunk/modules/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/XmlUtil.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/XmlUtil.java?view=diff&rev=504434&r1=504433&r2=504434
==============================================================================
--- geronimo/server/trunk/modules/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/XmlUtil.java
(original)
+++ geronimo/server/trunk/modules/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/XmlUtil.java
Tue Feb  6 21:06:13 2007
@@ -17,47 +17,47 @@
  */
 package org.apache.geronimo.openejb.deployment;
 
-import java.net.URL;
-import java.util.jar.JarFile;
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.IOException;
-import java.io.ByteArrayOutputStream;
-import javax.xml.bind.ValidationEvent;
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.Unmarshaller;
-import javax.xml.bind.JAXBException;
-import javax.xml.bind.Marshaller;
-import javax.xml.bind.JAXBElement;
-import javax.xml.namespace.QName;
-import javax.xml.parsers.SAXParserFactory;
-import javax.xml.parsers.SAXParser;
-import javax.xml.transform.sax.SAXSource;
-
-import org.apache.geronimo.openejb.xbeans.ejbjar.OpenejbEjbJarDocument;
-import org.apache.geronimo.openejb.xbeans.ejbjar.OpenejbGeronimoEjbJarType;
+import org.apache.geronimo.common.DeploymentException;
 import org.apache.geronimo.deployment.util.DeploymentUtil;
 import org.apache.geronimo.deployment.xmlbeans.XmlBeansUtil;
-import org.apache.geronimo.deployment.xbeans.EnvironmentType;
-import org.apache.geronimo.deployment.xbeans.ArtifactType;
-import org.apache.geronimo.common.DeploymentException;
+import org.apache.geronimo.openejb.xbeans.ejbjar.OpenejbEjbJarDocument;
+import org.apache.geronimo.openejb.xbeans.ejbjar.OpenejbGeronimoEjbJarType;
 import org.apache.geronimo.schema.SchemaConversionUtils;
 import org.apache.geronimo.xbeans.javaee.EjbJarDocument;
 import org.apache.geronimo.xbeans.javaee.EjbJarType;
-import org.apache.xmlbeans.XmlObject;
-import org.apache.xmlbeans.XmlException;
-import org.apache.xmlbeans.XmlCursor;
-import org.apache.xmlbeans.XmlDocumentProperties;
 import org.apache.openejb.jee.EjbJar;
 import org.apache.openejb.jee.EnterpriseBean;
 import org.apache.openejb.jee.PersistenceContextRef;
 import org.apache.openejb.jee.PersistenceContextType;
 import org.apache.openejb.jee.oejb2.GeronimoEjbJarType;
-import org.xml.sax.helpers.XMLFilterImpl;
-import org.xml.sax.XMLReader;
+import org.apache.openejb.jee.oejb2.EnvironmentType;
+import org.apache.openejb.jee.oejb2.ArtifactType;
+import org.apache.xmlbeans.XmlCursor;
+import org.apache.xmlbeans.XmlDocumentProperties;
+import org.apache.xmlbeans.XmlException;
+import org.apache.xmlbeans.XmlObject;
 import org.xml.sax.Attributes;
-import org.xml.sax.SAXException;
 import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.XMLReader;
+import org.xml.sax.helpers.XMLFilterImpl;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Marshaller;
+import javax.xml.bind.Unmarshaller;
+import javax.xml.bind.ValidationEvent;
+import javax.xml.namespace.QName;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+import javax.xml.transform.sax.SAXSource;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+import java.util.jar.JarFile;
 
 public final class XmlUtil {
     public static final QName OPENEJBJAR_QNAME = OpenejbEjbJarDocument.type.getDocumentElementName();
@@ -66,22 +66,6 @@
     private XmlUtil() {
     }
 
-    public static String loadEjbJarXml(URL ejbJarUrl, JarFile moduleFile) {
-        String ejbJarXml;
-        try {
-            if (ejbJarUrl == null) {
-                ejbJarUrl = DeploymentUtil.createJarURL(moduleFile, "META-INF/ejb-jar.xml");
-            }
-
-            // read in the entire specDD as a string, we need this for getDeploymentDescriptor
-            // on the J2ee management object
-            ejbJarXml = DeploymentUtil.readAll(ejbJarUrl);
-            return ejbJarXml;
-        } catch (Exception e) {
-            return null;
-        }
-    }
-
     public static class EjbJarNamespaceFilter extends XMLFilterImpl {
 
         public EjbJarNamespaceFilter(XMLReader xmlReader) {
@@ -155,32 +139,6 @@
         }
     }
 
-    public static String loadOpenejbJarXml(XmlObject xmlObject, JarFile moduleFile) throws
DeploymentException {
-        // load the openejb-jar.xml from either the supplied plan or from the earFile
-        try {
-            String openejbJarXml;
-            if (xmlObject instanceof XmlObject) {
-                openejbJarXml = xmlObject.xmlText();
-            } else {
-                if (xmlObject != null) {
-                    xmlObject = XmlBeansUtil.parse(((File) xmlObject).toURL(), XmlUtil.class.getClassLoader());
-                    openejbJarXml = xmlObject.xmlText();
-                } else {
-                    URL path = DeploymentUtil.createJarURL(moduleFile, "META-INF/openejb-jar.xml");
-                    if (path == null) {
-                        return null;
-                    }
-                    openejbJarXml = DeploymentUtil.readAll(path);
-                }
-            }
-            return openejbJarXml;
-        } catch (IOException e) {
-            return null;
-        } catch (XmlException e) {
-            throw new DeploymentException(e);
-        }
-    }
-
     public static EjbJarType convertToXmlbeans(EjbJar ejbJar) throws DeploymentException
{
         //
         // it would be nice if Jaxb had a way to convert the object to a
@@ -230,48 +188,7 @@
         }
     }
 
-    public static OpenejbGeronimoEjbJarType loadGeronimOpenejbJar(Object plan, JarFile moduleFile,
boolean standAlone, String targetPath, EjbJar ejbJar) throws DeploymentException {
-        OpenejbGeronimoEjbJarType openejbJar;
-        XmlObject rawPlan = null;
-        try {
-            // load the openejb-jar.xml from either the supplied plan or from the earFile
-            try {
-                if (plan instanceof XmlObject) {
-                    rawPlan = (XmlObject) plan;
-                } else {
-                    if (plan != null) {
-                        OpenejbEjbJarDocument document = (OpenejbEjbJarDocument) XmlBeansUtil.parse(((File)
plan).toURL(), XmlUtil.class.getClassLoader());
-                        rawPlan = document.getEjbJar();
-                    } else {
-                        URL path = DeploymentUtil.createJarURL(moduleFile, "META-INF/geronimo-openejb.xml");
-                        rawPlan = XmlBeansUtil.parse(path, XmlUtil.class.getClassLoader());
-                    }
-                }
-            } catch (IOException e) {
-                //no plan, create a default
-            }
-
-            // if we got one extract, adjust, and validate it otherwise create a default
one
-            if (rawPlan != null) {
-                openejbJar = (OpenejbGeronimoEjbJarType) SchemaConversionUtils.fixGeronimoSchema(rawPlan,
OPENEJBJAR_QNAME, OpenejbGeronimoEjbJarType.type);
-            } else {
-                String path;
-                if (standAlone) {
-                    // default configId is based on the moduleFile name
-                    path = new File(moduleFile.getName()).getName();
-                } else {
-                    // default configId is based on the module uri from the application.xml
-                    path = targetPath;
-                }
-                openejbJar = createDefaultPlan(path, ejbJar);
-            }
-        } catch (XmlException e) {
-            throw new DeploymentException(e);
-        }
-        return openejbJar;
-    }
-
-    public static OpenejbGeronimoEjbJarType createDefaultPlan(String name, EjbJar ejbJar)
{
+    public static GeronimoEjbJarType createDefaultPlan(String name, EjbJar ejbJar) {
         String id = ejbJar.getId();
         if (id == null) {
             id = name;
@@ -283,11 +200,17 @@
             }
         }
 
-        OpenejbGeronimoEjbJarType openejbEjbJar = OpenejbGeronimoEjbJarType.Factory.newInstance();
-        EnvironmentType environmentType = openejbEjbJar.addNewEnvironment();
-        ArtifactType artifactType = environmentType.addNewModuleId();
+
+        ArtifactType artifactType = new ArtifactType();
         artifactType.setArtifactId(id);
-        return openejbEjbJar;
+
+        EnvironmentType environmentType = new EnvironmentType();
+        environmentType.setModuleId(artifactType);
+
+        GeronimoEjbJarType geronimoEjbJarType = new GeronimoEjbJarType();
+        geronimoEjbJarType.setEnvironment(environmentType);
+
+        return geronimoEjbJarType;
     }
 
     public static String getJ2eeStringValue(org.apache.geronimo.xbeans.javaee.String string)
{
@@ -304,7 +227,9 @@
         }
     }
 
-
+    // TODO I don't think we need this since openejb will always generate the newest spec,
+    // but this code is doing more than just schema conversion, it is also converting message
+    // driven properties to activation-config
     // coerce to newest spec... this shouldn't be necessary as the jaxb tree always creates
the newest spec
     public static EjbJarDocument convertToEJBSchema(XmlObject xmlObject) throws XmlException
{
         if (EjbJarDocument.type.equals(xmlObject.schemaType())) {

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=504434&r1=504433&r2=504434
==============================================================================
--- 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
Tue Feb  6 21:06:13 2007
@@ -27,9 +27,11 @@
 import org.apache.openejb.NoSuchApplicationException;
 import org.apache.openejb.config.ClientModule;
 import org.apache.openejb.config.EjbModule;
+import org.apache.openejb.config.AppModule;
 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.assembler.classic.AppInfo;
 import org.apache.openejb.spi.ContainerSystem;
 
 /**
@@ -51,4 +53,6 @@
     DeploymentInfo getDeploymentInfo(String deploymentId);
 
     void removeEjbJar(EjbJarInfo ejbJarInfo, ClassLoader classLoader) throws UndeployException,
NoSuchApplicationException;
+
+    AppInfo configureApplication(AppModule appModule) 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=504434&r1=504433&r2=504434
==============================================================================
--- 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 Feb  6 21:06:13 2007
@@ -37,6 +37,7 @@
 import org.apache.openejb.config.ClientModule;
 import org.apache.openejb.config.ConfigurationFactory;
 import org.apache.openejb.config.EjbModule;
+import org.apache.openejb.config.AppModule;
 import org.apache.openejb.assembler.classic.Assembler;
 import org.apache.openejb.assembler.classic.ClientInfo;
 import org.apache.openejb.assembler.classic.ContainerInfo;
@@ -44,6 +45,7 @@
 import org.apache.openejb.assembler.classic.TransactionServiceInfo;
 import org.apache.openejb.assembler.classic.ProxyFactoryInfo;
 import org.apache.openejb.assembler.classic.SecurityServiceInfo;
+import org.apache.openejb.assembler.classic.AppInfo;
 import org.apache.openejb.assembler.dynamic.PassthroughFactory;
 import org.apache.openejb.spi.ContainerSystem;
 import org.apache.openejb.spi.ApplicationServer;
@@ -140,6 +142,16 @@
         Thread.currentThread().setContextClassLoader(clientModule.getClassLoader());
         try {
             return configurationFactory.configureApplication(clientModule);
+        } finally {
+            Thread.currentThread().setContextClassLoader(oldClassLoader);
+        }
+    }
+
+    public AppInfo configureApplication(AppModule appModule) throws OpenEJBException {
+        ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
+        Thread.currentThread().setContextClassLoader(appModule.getClassLoader());
+        try {
+            return configurationFactory.configureApplication(appModule);
         } finally {
             Thread.currentThread().setContextClassLoader(oldClassLoader);
         }

Modified: geronimo/server/trunk/modules/geronimo-persistence-jpa10/src/main/java/org/apache/geronimo/persistence/PersistenceUnitGBean.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-persistence-jpa10/src/main/java/org/apache/geronimo/persistence/PersistenceUnitGBean.java?view=diff&rev=504434&r1=504433&r2=504434
==============================================================================
--- geronimo/server/trunk/modules/geronimo-persistence-jpa10/src/main/java/org/apache/geronimo/persistence/PersistenceUnitGBean.java
(original)
+++ geronimo/server/trunk/modules/geronimo-persistence-jpa10/src/main/java/org/apache/geronimo/persistence/PersistenceUnitGBean.java
Tue Feb  6 21:06:13 2007
@@ -45,7 +45,6 @@
  * @version $Rev$ $Date$
  */
 public class PersistenceUnitGBean implements GBeanLifecycle {
-
     private final PersistenceUnitInfoImpl persistenceUnitInfo;
     private final EntityManagerFactory entityManagerFactory;
     private final TransactionManagerImpl transactionManager;
@@ -75,6 +74,8 @@
         List<String> managedClassNames = managedClassNamesUntyped == null? new ArrayList<String>():
new ArrayList<String>(managedClassNamesUntyped);
         PersistenceUnitTransactionType persistenceUnitTransactionType = persistenceUnitTransactionTypeString
== null? PersistenceUnitTransactionType.JTA: PersistenceUnitTransactionType.valueOf(persistenceUnitTransactionTypeString);
 
+        if (persistenceProviderClassName == null) persistenceProviderClassName = "org.apache.openjpa.persistence.PersistenceProviderImpl";
+        
         persistenceUnitInfo = new PersistenceUnitInfoImpl(persistenceUnitName,
                 persistenceProviderClassName,
                 persistenceUnitTransactionType,



Mime
View raw message