openejb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dblev...@apache.org
Subject svn commit: r504098 - in /incubator/openejb/trunk/openejb3/container: openejb-core/src/main/java/org/apache/openejb/config/ openejb-jee/src/main/java/org/apache/openejb/jee/oejb2/ openejb-jee/src/main/java/org/apache/openejb/jee/oejb3/ openejb-jee/src/...
Date Tue, 06 Feb 2007 12:06:51 GMT
Author: dblevins
Date: Tue Feb  6 04:06:50 2007
New Revision: 504098

URL: http://svn.apache.org/viewvc?view=rev&rev=504098
Log:
Basic openejb v2 to v3 converter (very untested)

Added:
    incubator/openejb/trunk/openejb3/container/openejb-jee/src/test/resources/geronimo-openejb-corrected.xml
    incubator/openejb/trunk/openejb3/container/openejb-jee/src/test/resources/geronimo-openejb-invalid.xml
      - copied, changed from r503923, incubator/openejb/trunk/openejb3/container/openejb-jee/src/test/resources/geronimo-openejb-jaxb-test.xml
Removed:
    incubator/openejb/trunk/openejb3/container/openejb-jee/src/test/resources/geronimo-openejb-jaxb-test.xml
Modified:
    incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java
    incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/OpenEjb2CmpConversion.java
    incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ReadDescriptors.java
    incubator/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/oejb2/GeronimoEjbJarType.java
    incubator/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/oejb2/JaxbOpenejbJar2.java
    incubator/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/oejb2/NamespaceFilter.java
    incubator/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/oejb3/JaxbOpenejbJar3.java
    incubator/openejb/trunk/openejb3/container/openejb-jee/src/test/java/org/apache/openejb/jee/oejb2/OpenejbJarTest.java

Modified: incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java?view=diff&rev=504098&r1=504097&r2=504098
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java
(original)
+++ incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java
Tue Feb  6 04:06:50 2007
@@ -224,7 +224,7 @@
                 throw e;
             }
 
-        } else {
+        } else if (EjbModule.class.equals(moduleClass)) {
 
             EjbModule ejbModule = new EjbModule(classLoader, jarFile.getAbsolutePath(), null,
null);
 
@@ -244,6 +244,8 @@
             }
 
             return appModule;
+        } else {
+            throw new OpenEJBException("Unsupported module type: "+moduleClass.getSimpleName());
         }
     }
 
@@ -316,12 +318,11 @@
             }
         }
 
-        ClassFinder classFinder = new ClassFinder(new TemporaryClassLoader(new URL[]{baseUrl},
classLoader), baseUrl);
-        List<Class> beans = classFinder.findAnnotatedClasses(Stateless.class);
-        beans.addAll(classFinder.findAnnotatedClasses(Stateful.class));
-        beans.addAll(classFinder.findAnnotatedClasses(javax.ejb.MessageDriven.class));
+        ClassFinder classFinder = new ClassFinder(classLoader, baseUrl);
 
-        if (beans.size() > 0) {
+        if (classFinder.isAnnotationPresent(Stateless.class) ||
+                classFinder.isAnnotationPresent(Stateful.class) ||
+                classFinder.isAnnotationPresent(javax.ejb.MessageDriven.class)) {
             return EjbModule.class;
         }
 

Modified: incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/OpenEjb2CmpConversion.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/OpenEjb2CmpConversion.java?view=diff&rev=504098&r1=504097&r2=504098
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/OpenEjb2CmpConversion.java
(original)
+++ incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/OpenEjb2CmpConversion.java
Tue Feb  6 04:06:50 2007
@@ -62,27 +62,6 @@
         return appModule;
     }
 
-    private String createGeronimoOpenejb(OpenejbJarType o2) throws JAXBException {
-        GeronimoEjbJarType g2 = new GeronimoEjbJarType();
-
-        g2.setEnvironment(o2.getEnvironment());
-        g2.setSecurity(o2.getSecurity());
-        g2.getService().addAll(o2.getService());
-        g2.getMessageDestination().addAll(o2.getMessageDestination());
-
-        for (EnterpriseBean bean : o2.getEnterpriseBeans()) {
-            g2.getAbstractNamingEntry().addAll(bean.getAbstractNamingEntry());
-            g2.getEjbLocalRef().addAll(bean.getEjbLocalRef());
-            g2.getEjbRef().addAll(bean.getEjbRef());
-            g2.getResourceEnvRef().addAll(bean.getResourceEnvRef());
-            g2.getResourceRef().addAll(bean.getResourceRef());
-            g2.getServiceRef().addAll(bean.getServiceRef());
-        }
-
-        JAXBElement root = new JAXBElement(new QName("http://geronimo.apache.org/xml/ns/j2ee/ejb/openejb-2.0","ejb-jar"),
GeronimoEjbJarType.class, g2);
-        return JaxbOpenejbJar2.marshal(GeronimoEjbJarType.class, root);
-    }
-
     public OpenejbJarType loadOpenEjbJar(ClassLoader classLoader) {
         InputStream in = classLoader.getResourceAsStream("META-INF/openejb-jar.xml");
         if (in == null) {

Modified: incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ReadDescriptors.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ReadDescriptors.java?view=diff&rev=504098&r1=504097&r2=504098
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ReadDescriptors.java
(original)
+++ incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ReadDescriptors.java
Tue Feb  6 04:06:50 2007
@@ -17,44 +17,43 @@
 package org.apache.openejb.config;
 
 import org.apache.openejb.OpenEJBException;
-import org.apache.openejb.jee.EjbJar;
 import org.apache.openejb.jee.ApplicationClient;
-import org.apache.openejb.jee.jpa.unit.Persistence;
+import org.apache.openejb.jee.EjbJar;
 import org.apache.openejb.jee.jpa.unit.JaxbPersistenceFactory;
+import org.apache.openejb.jee.jpa.unit.Persistence;
+import org.apache.openejb.jee.oejb2.EnterpriseBean;
+import org.apache.openejb.jee.oejb2.GeronimoEjbJarType;
+import org.apache.openejb.jee.oejb2.JaxbOpenejbJar2;
+import org.apache.openejb.jee.oejb2.OpenejbJarType;
+import org.apache.openejb.jee.oejb3.JaxbOpenejbJar3;
 import org.apache.openejb.jee.oejb3.OpenejbJar;
 
+import javax.xml.bind.JAXBElement;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
 import java.net.URL;
 import java.util.List;
 
 /**
  * @version $Rev$ $Date$
  */
-class ReadDescriptors implements DynamicDeployer {
+public class ReadDescriptors implements DynamicDeployer {
     public AppModule deploy(AppModule appModule) throws OpenEJBException {
         for (EjbModule ejbModule : appModule.getEjbModules()) {
 
-            Object data = ejbModule.getAltDDs().get("ejb-jar.xml");
-            if (data instanceof URL) {
-                URL url = (URL) data;
-                EjbJar ejbJar = DeploymentLoader.unmarshal(EjbJar.class, "META-INF/ejb-jar.xml",
url);
-                ejbModule.setEjbJar(ejbJar);
-            } else {
-                DeploymentLoader.logger.warning("No ejb-jar.xml found assuming annotated
beans present: " + appModule.getJarLocation() + ", module: " + ejbModule.getModuleId());
-                ejbModule.setEjbJar(new EjbJar());
+            if (ejbModule.getEjbJar() == null) {
+                readEjbJar(ejbModule, appModule);
             }
 
-            data = ejbModule.getAltDDs().get("openejb-jar.xml");
-            if (data instanceof URL) {
-                URL url = (URL) data;
-                OpenejbJar openejbJar = DeploymentLoader.unmarshal(OpenejbJar.class, "META-INF/openejb-jar.xml",
url);
-                ejbModule.setOpenejbJar(openejbJar);
+            if (ejbModule.getOpenejbJar() == null) {
+                readOpenejbJar(ejbModule);
             }
-
         }
 
         for (ClientModule clientModule : appModule.getClientModules()) {
 
-            Object data = clientModule.getAltDDs().get("ejb-jar.xml");
+            Object data = clientModule.getAltDDs().get("application-client.xml");
             if (data instanceof URL) {
                 URL url = (URL) data;
                 ApplicationClient applicationClient = DeploymentLoader.unmarshal(ApplicationClient.class,
"META-INF/application-client.xml", url);
@@ -67,23 +66,146 @@
         }
 
         List<URL> persistenceUrls = (List<URL>) appModule.getAltDDs().get("persistence.xml");
-        for (URL url1 : persistenceUrls) {
-            String moduleName1 = url1.toExternalForm().replaceFirst("!/?META-INF/persistence.xml$",
"");
-            moduleName1 = moduleName1.replaceFirst("/?META-INF/persistence.xml$", "/");
-            if (moduleName1.startsWith("jar:")) moduleName1 = moduleName1.substring("jar:".length());
-            if (moduleName1.startsWith("file:")) moduleName1 = moduleName1.substring("file:".length());
-        //    if (moduleName1.endsWith("/")) moduleName1 = moduleName1.substring(0, moduleName1.length()
-1);
+        if (persistenceUrls != null) {
+            for (URL url1 : persistenceUrls) {
+                String moduleName1 = url1.toExternalForm().replaceFirst("!/?META-INF/persistence.xml$",
"");
+                moduleName1 = moduleName1.replaceFirst("/?META-INF/persistence.xml$", "/");
+                if (moduleName1.startsWith("jar:")) moduleName1 = moduleName1.substring("jar:".length());
+                if (moduleName1.startsWith("file:")) moduleName1 = moduleName1.substring("file:".length());
+//                if (moduleName1.endsWith("/")) moduleName1 = moduleName1.substring(0, moduleName1.length()
- 1);
+                try {
+                    Persistence persistence = JaxbPersistenceFactory.getPersistence(url1);
+                    PersistenceModule persistenceModule = new PersistenceModule(moduleName1,
persistence);
+                    appModule.getPersistenceModules().add(persistenceModule);
+                } catch (Exception e1) {
+                    DeploymentLoader.logger.error("Unable to load Persistence Unit from EAR:
" + appModule.getJarLocation() + ", module: " + moduleName1 + ". Exception: " + e1.getMessage(),
e1);
+                }
+            }
+        }
+
+        return appModule;
+
+    }
+
+    private void readOpenejbJar(EjbModule ejbModule) throws OpenEJBException {
+        Source source = getSource(ejbModule.getAltDDs().get("openejb-jar.xml"));
+
+        if (source != null) {
             try {
-                Persistence persistence = JaxbPersistenceFactory.getPersistence(url1);
-                PersistenceModule persistenceModule = new PersistenceModule(moduleName1,
persistence);
-                appModule.getPersistenceModules().add(persistenceModule);
+                OpenejbJar openejbJar = JaxbOpenejbJar3.unmarshal(OpenejbJar.class, source.get());
+                ejbModule.setOpenejbJar(openejbJar);
+            } catch (Exception e) {
+                OpenejbJar openejbJar = new OpenejbJar();
+                ejbModule.getAltDDs().put("openejb-jar.xml", openejbJar);
+                ejbModule.setOpenejbJar(openejbJar);
 
-            } catch (Exception e1) {
-                DeploymentLoader.logger.error("Unable to load Persistence Unit from EAR:
" + appModule.getJarLocation() + ", module: " + moduleName1 + ". Exception: " + e1.getMessage(),
e1);
+                try {
+                    JAXBElement element = (JAXBElement) JaxbOpenejbJar2.unmarshal(OpenejbJarType.class,
source.get());
+                    OpenejbJarType o2 = (OpenejbJarType) element.getValue();
+
+                    GeronimoEjbJarType g2 = new GeronimoEjbJarType();
+
+                    g2.setEnvironment(o2.getEnvironment());
+                    g2.setSecurity(o2.getSecurity());
+                    g2.getService().addAll(o2.getService());
+                    g2.getMessageDestination().addAll(o2.getMessageDestination());
+
+                    for (EnterpriseBean bean : o2.getEnterpriseBeans()) {
+                        g2.getAbstractNamingEntry().addAll(bean.getAbstractNamingEntry());
+                        g2.getEjbLocalRef().addAll(bean.getEjbLocalRef());
+                        g2.getEjbRef().addAll(bean.getEjbRef());
+                        g2.getResourceEnvRef().addAll(bean.getResourceEnvRef());
+                        g2.getResourceRef().addAll(bean.getResourceRef());
+                        g2.getServiceRef().addAll(bean.getServiceRef());
+                    }
+
+                    ejbModule.getAltDDs().put("geronimo-openejb.xml", g2);
+                } catch (Exception e1) {
+                    throw new OpenEJBException(e);
+                }
             }
         }
 
-        return appModule;
+        Source source1 = getSource(ejbModule.getAltDDs().get("geronimo-openejb.xml"));
+        if (source1 != null) {
+            try {
+                GeronimoEjbJarType geronimoEjbJarType = null;
+                Object o = JaxbOpenejbJar2.unmarshal(GeronimoEjbJarType.class, source1.get());
+                if (o instanceof GeronimoEjbJarType) {
+                    geronimoEjbJarType = (GeronimoEjbJarType) o;
+                } else if (o instanceof JAXBElement) {
+                    JAXBElement element = (JAXBElement) o;
+                    geronimoEjbJarType = (GeronimoEjbJarType) element.getValue();
+                }
+                if (geronimoEjbJarType != null) {
+                    Object nested = geronimoEjbJarType.getOpenejbJar();
+                    if (nested != null && nested instanceof OpenejbJar) {
+                        OpenejbJar existingOpenejbJar = ejbModule.getOpenejbJar();
+                        if (existingOpenejbJar == null || existingOpenejbJar.getEjbDeploymentCount()
<= 0) {
+                            OpenejbJar openejbJar = (OpenejbJar) nested;
+                            ejbModule.getAltDDs().put("openejb-jar.xml", openejbJar);
+                            ejbModule.setOpenejbJar(openejbJar);
+                        }
+                    }
+                    ejbModule.getAltDDs().put("geronimo-openejb.xml", geronimoEjbJarType);
+                }
+            } catch (Exception e) {
+                throw new OpenEJBException("Failed parsing geronimo-openejb.xml", e);
+            }
+        }
 
     }
+
+    private void readEjbJar(EjbModule ejbModule, AppModule appModule) throws OpenEJBException
{
+        Object data = ejbModule.getAltDDs().get("ejb-jar.xml");
+        if (data instanceof URL) {
+            URL url = (URL) data;
+            EjbJar ejbJar = DeploymentLoader.unmarshal(EjbJar.class, "META-INF/ejb-jar.xml",
url);
+            ejbModule.setEjbJar(ejbJar);
+        } else {
+            DeploymentLoader.logger.warning("No ejb-jar.xml found assuming annotated beans
present: " + appModule.getJarLocation() + ", module: " + ejbModule.getModuleId());
+            ejbModule.setEjbJar(new EjbJar());
+        }
+    }
+
+    private Source getSource(Object o) {
+        if (o instanceof URL) {
+            return new UrlSource((URL) o);
+        }
+
+        if (o instanceof String) {
+            return new StringSource((String) o);
+        }
+
+        return null;
+    }
+
+    public static abstract class Source {
+        abstract InputStream get() throws IOException;
+    }
+
+    public static class UrlSource extends Source {
+        private final URL url;
+
+        public UrlSource(URL url) {
+            this.url = url;
+        }
+
+        InputStream get() throws IOException {
+            return url.openStream();
+        }
+    }
+
+    public static class StringSource extends Source {
+        private byte[] bytes;
+
+        public StringSource(String content) {
+            bytes = content.getBytes();
+        }
+
+        InputStream get() throws IOException {
+            return new ByteArrayInputStream(bytes);
+        }
+    }
+
 }

Modified: incubator/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/oejb2/GeronimoEjbJarType.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/oejb2/GeronimoEjbJarType.java?view=diff&rev=504098&r1=504097&r2=504098
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/oejb2/GeronimoEjbJarType.java
(original)
+++ incubator/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/oejb2/GeronimoEjbJarType.java
Tue Feb  6 04:06:50 2007
@@ -186,6 +186,13 @@
         return this.resourceEnvRef;
     }
 
+    public Object getOpenejbJar() {
+        return openejbJar;
+    }
+
+    public void setOpenejbJar(Object openejbJar) {
+        this.openejbJar = openejbJar;
+    }
 
 
     /**

Modified: incubator/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/oejb2/JaxbOpenejbJar2.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/oejb2/JaxbOpenejbJar2.java?view=diff&rev=504098&r1=504097&r2=504098
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/oejb2/JaxbOpenejbJar2.java
(original)
+++ incubator/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/oejb2/JaxbOpenejbJar2.java
Tue Feb  6 04:06:50 2007
@@ -71,6 +71,15 @@
                 return false;
             }
         });
+        unmarshaller.setListener(new Unmarshaller.Listener(){
+            public void afterUnmarshal(Object object, Object object1) {
+                super.afterUnmarshal(object, object1);
+            }
+
+            public void beforeUnmarshal(Object object, Object object1) {
+                super.beforeUnmarshal(object, object1);
+            }
+        });
 
 
         NamespaceFilter xmlFilter = new NamespaceFilter(parser.getXMLReader());

Modified: incubator/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/oejb2/NamespaceFilter.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/oejb2/NamespaceFilter.java?view=diff&rev=504098&r1=504097&r2=504098
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/oejb2/NamespaceFilter.java
(original)
+++ incubator/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/oejb2/NamespaceFilter.java
Tue Feb  6 04:06:50 2007
@@ -149,7 +149,8 @@
         }
         
         String correctNamespace = ns.get(localName);
-        if (uri.equals("http://openejb.apache.org/xml/ns/openejb-jar-2.2") && correctNamespace
!= null) {
+        boolean correctable = (uri.equals("http://openejb.apache.org/xml/ns/openejb-jar-2.2")
|| uri.equals("http://geronimo.apache.org/xml/ns/j2ee/ejb/openejb-2.0"));
+        if (correctable && correctNamespace != null) {
             uri = correctNamespace;
         } else if (duplicates.containsKey(localName)){
             List<String> possibleNamespaces = duplicates.get(localName);

Modified: incubator/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/oejb3/JaxbOpenejbJar3.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/oejb3/JaxbOpenejbJar3.java?view=diff&rev=504098&r1=504097&r2=504098
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/oejb3/JaxbOpenejbJar3.java
(original)
+++ incubator/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/oejb3/JaxbOpenejbJar3.java
Tue Feb  6 04:06:50 2007
@@ -28,6 +28,7 @@
 import javax.xml.bind.Unmarshaller;
 import javax.xml.bind.ValidationEventHandler;
 import javax.xml.bind.ValidationEvent;
+import javax.xml.bind.JAXBElement;
 import javax.xml.parsers.ParserConfigurationException;
 import javax.xml.parsers.SAXParserFactory;
 import javax.xml.parsers.SAXParser;
@@ -60,7 +61,7 @@
         return jaxbContext;
     }
 
-    public static <T>Object unmarshal(Class<T> type, InputStream in) throws ParserConfigurationException,
SAXException, JAXBException {
+    public static <T> T unmarshal(Class<T> type, InputStream in) throws ParserConfigurationException,
SAXException, JAXBException {
         InputSource inputSource = new InputSource(in);
 
         SAXParserFactory factory = SAXParserFactory.newInstance();
@@ -83,7 +84,12 @@
 
         SAXSource source = new SAXSource(xmlFilter, inputSource);
 
-        return unmarshaller.unmarshal(source);
+        Object o = unmarshaller.unmarshal(source);
+        if (o instanceof JAXBElement) {
+            JAXBElement element = (JAXBElement) o;
+            return (T) element.getValue();
+        }
+        return (T) o;
     }
 
     public static class NamespaceFilter extends XMLFilterImpl {
@@ -93,7 +99,7 @@
         }
 
         public void startElement(String uri, String localName, String qname, Attributes atts)
throws SAXException {
-            super.startElement(uri, localName, qname, atts);
+            super.startElement("http://www.openejb.org/openejb-jar/1.1", localName, qname,
atts);
         }
     }
 }

Modified: incubator/openejb/trunk/openejb3/container/openejb-jee/src/test/java/org/apache/openejb/jee/oejb2/OpenejbJarTest.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-jee/src/test/java/org/apache/openejb/jee/oejb2/OpenejbJarTest.java?view=diff&rev=504098&r1=504097&r2=504098
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-jee/src/test/java/org/apache/openejb/jee/oejb2/OpenejbJarTest.java
(original)
+++ incubator/openejb/trunk/openejb3/container/openejb-jee/src/test/java/org/apache/openejb/jee/oejb2/OpenejbJarTest.java
Tue Feb  6 04:06:50 2007
@@ -40,6 +40,10 @@
         unmarshalAndMarshal(GeronimoEjbJarType.class, "geronimo-openejb-full.xml");
     }
 
+    public void testGeronimoOpenejbInvalidXml() throws Exception {
+        unmarshalAndMarshal(GeronimoEjbJarType.class, "geronimo-openejb-invalid.xml", "geronimo-openejb-corrected.xml");
+    }
+
     public void testOpenejbJarMoreInvalid() throws Exception {
         unmarshalAndMarshal(OpenejbJarType.class, "daytrader-original.xml", "daytrader-corrected.xml");
     }

Added: incubator/openejb/trunk/openejb3/container/openejb-jee/src/test/resources/geronimo-openejb-corrected.xml
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-jee/src/test/resources/geronimo-openejb-corrected.xml?view=auto&rev=504098
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-jee/src/test/resources/geronimo-openejb-corrected.xml
(added)
+++ incubator/openejb/trunk/openejb3/container/openejb-jee/src/test/resources/geronimo-openejb-corrected.xml
Tue Feb  6 04:06:50 2007
@@ -0,0 +1,104 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<ns7:ejb-jar xmlns="http://geronimo.apache.org/xml/ns/deployment-1.2" xmlns:ns2="http://geronimo.apache.org/xml/ns/naming-1.2"
xmlns:ns3="http://openejb.apache.org/xml/ns/openejb-jar-2.2" xmlns:ns4="http://geronimo.apache.org/xml/ns/j2ee/application-1.2"
xmlns:ns5="http://openejb.apache.org/xml/ns/pkgen-2.1" xmlns:ns6="http://java.sun.com/xml/ns/persistence"
xmlns:ns7="http://geronimo.apache.org/xml/ns/j2ee/ejb/openejb-2.0">
+    <environment>
+        <moduleId>
+            <groupId>itests</groupId>
+            <artifactId>itests</artifactId>
+            <version>1</version>
+            <type>car</type>
+        </moduleId>
+        <dependencies>
+            <dependency>
+                <groupId>commons-lang</groupId>
+                <artifactId>commons-lang</artifactId>
+                <version>2.0</version>
+            </dependency>
+            <dependency>
+                <groupId>junit</groupId>
+                <artifactId>junit</artifactId>
+                <version>3.8.1</version>
+            </dependency>
+            <dependency>
+                <groupId>org.apache.geronimo.configs</groupId>
+                <artifactId>system-database</artifactId>
+                <type>car</type>
+            </dependency>
+        </dependencies>
+    </environment>
+    <ns6:persistence version="1.0">
+        <ns6:persistence-unit transaction-type="JTA" name="cmp">
+            <ns6:provider>org.apache.openjpa.persistence.PersistenceProviderImpl</ns6:provider>
+            <ns6:jta-data-source>?name=SystemDatasource</ns6:jta-data-source>
+            <ns6:non-jta-data-source>?name=NoTxDatasource</ns6:non-jta-data-source>
+            <ns6:mapping-file>META-INF/jpa.mapping.xml</ns6:mapping-file>
+            <ns6:class>org.apache.openejb.test.entity.cmp.BasicCmpBean</ns6:class>
+            <ns6:exclude-unlisted-classes>false</ns6:exclude-unlisted-classes>
+        </ns6:persistence-unit>
+        <ns6:persistence-unit transaction-type="JTA" name="openjpa-test-unit">
+            <ns6:provider>org.apache.openjpa.persistence.PersistenceProviderImpl</ns6:provider>
+            <ns6:jta-data-source>?name=SystemDatasource</ns6:jta-data-source>
+            <ns6:non-jta-data-source>?name=NoTxDatasource</ns6:non-jta-data-source>
+            <ns6:class>org.apache.openejb.test.entity.Customer</ns6:class>
+        </ns6:persistence-unit>
+    </ns6:persistence>
+    <ns2:persistence-context-ref>
+        <ns2:persistence-context-ref-name>persistence/TestContext</ns2:persistence-context-ref-name>
+        <ns2:persistence-unit-name>openjpa-test-unit</ns2:persistence-unit-name>
+    </ns2:persistence-context-ref>
+    <ns2:persistence-context-ref>
+        <ns2:persistence-context-ref-name>persistence/ExtendedTestContext</ns2:persistence-context-ref-name>
+        <ns2:persistence-unit-name>openjpa-test-unit</ns2:persistence-unit-name>
+    </ns2:persistence-context-ref>
+    <ns2:persistence-context-ref>
+        <ns2:persistence-context-ref-name>openejb/cmp</ns2:persistence-context-ref-name>
+        <ns2:persistence-unit-name>cmp</ns2:persistence-unit-name>
+    </ns2:persistence-context-ref>
+    <ns2:resource-ref>
+        <ns2:ref-name>database</ns2:ref-name>
+        <ns2:pattern>
+            <ns2:groupId>org.apache.geronimo.configs</ns2:groupId>
+            <ns2:artifactId>system-database</ns2:artifactId>
+            <ns2:name>SystemDatasource</ns2:name>
+        </ns2:pattern>
+    </ns2:resource-ref>
+    <ns2:resource-ref>
+        <ns2:ref-name>datasource</ns2:ref-name>
+        <ns2:pattern>
+            <ns2:groupId>org.apache.geronimo.configs</ns2:groupId>
+            <ns2:artifactId>system-database</ns2:artifactId>
+            <ns2:name>SystemDatasource</ns2:name>
+        </ns2:pattern>
+    </ns2:resource-ref>
+    <ns2:resource-ref>
+        <ns2:ref-name>jdbc/basic/entityDatabase</ns2:ref-name>
+        <ns2:pattern>
+            <ns2:groupId>org.apache.geronimo.configs</ns2:groupId>
+            <ns2:artifactId>system-database</ns2:artifactId>
+            <ns2:name>SystemDatasource</ns2:name>
+        </ns2:pattern>
+    </ns2:resource-ref>
+    <ns2:resource-ref>
+        <ns2:ref-name>stateless/references/Resource_manager_access</ns2:ref-name>
+        <ns2:pattern>
+            <ns2:groupId>org.apache.geronimo.configs</ns2:groupId>
+            <ns2:artifactId>system-database</ns2:artifactId>
+            <ns2:name>SystemDatasource</ns2:name>
+        </ns2:pattern>
+    </ns2:resource-ref>
+    <ns2:resource-ref>
+        <ns2:ref-name>org.apache.openejb.test.stateless.AnnotatedFieldInjectionStatelessBean/daataSource</ns2:ref-name>
+        <ns2:pattern>
+            <ns2:groupId>org.apache.geronimo.configs</ns2:groupId>
+            <ns2:artifactId>system-database</ns2:artifactId>
+            <ns2:name>SystemDatasource</ns2:name>
+        </ns2:pattern>
+    </ns2:resource-ref>
+    <ns2:resource-ref>
+        <ns2:ref-name>org.apache.openejb.test.stateful.AnnotatedFieldInjectionStatefulBean/daataSource</ns2:ref-name>
+        <ns2:pattern>
+            <ns2:groupId>org.apache.geronimo.configs</ns2:groupId>
+            <ns2:artifactId>system-database</ns2:artifactId>
+            <ns2:name>SystemDatasource</ns2:name>
+        </ns2:pattern>
+    </ns2:resource-ref>
+</ns7:ejb-jar>

Copied: incubator/openejb/trunk/openejb3/container/openejb-jee/src/test/resources/geronimo-openejb-invalid.xml
(from r503923, incubator/openejb/trunk/openejb3/container/openejb-jee/src/test/resources/geronimo-openejb-jaxb-test.xml)
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-jee/src/test/resources/geronimo-openejb-invalid.xml?view=diff&rev=504098&p1=incubator/openejb/trunk/openejb3/container/openejb-jee/src/test/resources/geronimo-openejb-jaxb-test.xml&r1=503923&p2=incubator/openejb/trunk/openejb3/container/openejb-jee/src/test/resources/geronimo-openejb-invalid.xml&r2=504098
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-jee/src/test/resources/geronimo-openejb-jaxb-test.xml
(original)
+++ incubator/openejb/trunk/openejb3/container/openejb-jee/src/test/resources/geronimo-openejb-invalid.xml
Tue Feb  6 04:06:50 2007
@@ -1,4 +1,22 @@
 <?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    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.
+-->
+
 <ejb-jar xmlns="http://geronimo.apache.org/xml/ns/j2ee/ejb/openejb-2.0"
     xmlns:n="http://geronimo.apache.org/xml/ns/naming-1.2"
 >
@@ -59,6 +77,22 @@
             <n:name>SystemDatasource</n:name>
         </n:pattern>
     </n:resource-ref>
+    <n:resource-ref>
+        <n:ref-name>org.apache.openejb.test.stateless.AnnotatedFieldInjectionStatelessBean/daataSource</n:ref-name>
+        <n:pattern>
+            <n:groupId>org.apache.geronimo.configs</n:groupId>
+            <n:artifactId>system-database</n:artifactId>
+            <n:name>SystemDatasource</n:name>
+        </n:pattern>
+    </n:resource-ref>
+    <n:resource-ref>
+        <n:ref-name>org.apache.openejb.test.stateful.AnnotatedFieldInjectionStatefulBean/daataSource</n:ref-name>
+        <n:pattern>
+            <n:groupId>org.apache.geronimo.configs</n:groupId>
+            <n:artifactId>system-database</n:artifactId>
+            <n:name>SystemDatasource</n:name>
+        </n:pattern>
+    </n:resource-ref>
     <n:persistence-context-ref>
         <n:persistence-context-ref-name>persistence/TestContext</n:persistence-context-ref-name>
         <n:persistence-unit-name>openjpa-test-unit</n:persistence-unit-name>
@@ -79,20 +113,20 @@
         <n:persistence-unit-name>openjpa-test-unit</n:persistence-unit-name>
     </n:persistence-unit-ref>
 
-    <!--<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">-->
-        <!--<persistence-unit transaction-type="JTA" name="cmp">-->
-            <!--<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>-->
-            <!--<jta-data-source>?name=SystemDatasource</jta-data-source>-->
-            <!--<non-jta-data-source>?name=NoTxDatasource</non-jta-data-source>-->
-            <!--<mapping-file>META-INF/jpa.mapping.xml</mapping-file>-->
-            <!--<class>org.apache.openejb.test.entity.cmp.BasicCmpBean</class>-->
-            <!--<exclude-unlisted-classes>false</exclude-unlisted-classes>-->
-        <!--</persistence-unit>-->
-        <!--<persistence-unit transaction-type="JTA" name="openjpa-test-unit">-->
-            <!--<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>-->
-            <!--<jta-data-source>?name=SystemDatasource</jta-data-source>-->
-            <!--<non-jta-data-source>?name=NoTxDatasource</non-jta-data-source>-->
-            <!--<class>org.apache.openejb.test.entity.Customer</class>-->
-        <!--</persistence-unit>-->
-    <!--</persistence>-->
+    <persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
+        <persistence-unit transaction-type="JTA" name="cmp">
+            <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
+            <jta-data-source>?name=SystemDatasource</jta-data-source>
+            <non-jta-data-source>?name=NoTxDatasource</non-jta-data-source>
+            <mapping-file>META-INF/jpa.mapping.xml</mapping-file>
+            <class>org.apache.openejb.test.entity.cmp.BasicCmpBean</class>
+            <exclude-unlisted-classes>false</exclude-unlisted-classes>
+        </persistence-unit>
+        <persistence-unit transaction-type="JTA" name="openjpa-test-unit">
+            <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
+            <jta-data-source>?name=SystemDatasource</jta-data-source>
+            <non-jta-data-source>?name=NoTxDatasource</non-jta-data-source>
+            <class>org.apache.openejb.test.entity.Customer</class>
+        </persistence-unit>
+    </persistence>
 </ejb-jar>



Mime
View raw message