geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r957655 [14/15] - in /geronimo/server/trunk: ./ framework/configs/geronimo-gbean-deployer-bootstrap/src/main/history/ framework/configs/geronimo-gbean-deployer/src/main/history/ framework/configs/jsr88-cli/src/main/history/ framework/config...
Date Thu, 24 Jun 2010 18:06:33 GMT
Modified: geronimo/server/trunk/plugins/openejb/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/XmlUtil.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/openejb/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/XmlUtil.java?rev=957655&r1=957654&r2=957655&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/openejb/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/XmlUtil.java (original)
+++ geronimo/server/trunk/plugins/openejb/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/XmlUtil.java Thu Jun 24 18:06:24 2010
@@ -27,9 +27,7 @@ import javax.xml.bind.JAXBContext;
 import javax.xml.bind.JAXBElement;
 import javax.xml.bind.JAXBException;
 import javax.xml.bind.Marshaller;
-import javax.xml.bind.ValidationEvent;
 import javax.xml.namespace.QName;
-
 import org.apache.geronimo.common.DeploymentException;
 import org.apache.geronimo.deployment.service.EnvironmentBuilder;
 import org.apache.geronimo.deployment.xmlbeans.XmlBeansUtil;
@@ -42,20 +40,12 @@ import org.apache.geronimo.kernel.util.I
 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.javaee6.EjbJarDocument;
-import org.apache.geronimo.xbeans.javaee6.EjbJarType;
 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.ArtifactType;
 import org.apache.openejb.jee.oejb2.DependencyType;
 import org.apache.openejb.jee.oejb2.EnvironmentType;
 import org.apache.openejb.jee.oejb2.GeronimoEjbJarType;
 import org.apache.openejb.jee.oejb2.ImportType;
-import org.apache.xmlbeans.XmlCursor;
-import org.apache.xmlbeans.XmlDocumentProperties;
-import org.apache.xmlbeans.XmlException;
 import org.apache.xmlbeans.XmlObject;
 
 public final class XmlUtil {
@@ -87,33 +77,6 @@ public final class XmlUtil {
         }
     }
 
-    public static EjbJarType convertToXmlbeans(EjbJar ejbJar) throws DeploymentException {
-        //
-        // it would be nice if Jaxb had a way to convert the object to a
-        // sax reader that could be fed directly into xmlbeans
-        //
-
-        // the geronimo xml beans tree is totally broken... fix some obvious stuff here
-        for (EnterpriseBean enterpriseBean : ejbJar.getEnterpriseBeans()) {
-            for (PersistenceContextRef ref : enterpriseBean.getPersistenceContextRef()) {
-                if (ref.getPersistenceContextType() == PersistenceContextType.TRANSACTION) {
-                    ref.setPersistenceContextType(null);
-                }
-            }
-        }
-
-        // marshal to xml
-        String xml = marshal(ejbJar);
-        try {
-            // parse the xml
-            EjbJarDocument ejbJarDoc = convertToEJBSchema(XmlBeansUtil.parse(xml));
-            EjbJarType ejbJarType = ejbJarDoc.getEjbJar();
-            return ejbJarType;
-        } catch (XmlException e) {
-            throw new DeploymentException("Error parsing ejb-jar.xml", e);
-        }
-
-    }
 
     public static OpenejbGeronimoEjbJarType convertToXmlbeans(GeronimoEjbJarType geronimoEjbJarType) throws DeploymentException {
         //
@@ -230,159 +193,4 @@ public final class XmlUtil {
         return geronimoEjbJarType;
     }
 
-    public static String getJ2eeStringValue(org.apache.geronimo.xbeans.javaee6.String string) {
-        if (string == null) {
-            return null;
-        }
-        return string.getStringValue();
-    }
-
-    public static class ValidationEventHandler implements javax.xml.bind.ValidationEventHandler {
-        public boolean handleEvent(ValidationEvent validationEvent) {
-            System.out.println(validationEvent.getMessage());
-            return true;
-        }
-    }
-
-    // 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())) {
-//            XmlBeansUtil.validateDD(xmlObject);
-            return (EjbJarDocument) xmlObject;
-        }
-        XmlCursor cursor = xmlObject.newCursor();
-        XmlCursor moveable = xmlObject.newCursor();
-        //cursor is intially located before the logical STARTDOC token
-        try {
-            cursor.toFirstChild();
-            if (EjbJarDocument.type.getDocumentElementName().getNamespaceURI().equals(cursor.getName().getNamespaceURI())) {
-                XmlObject result = xmlObject.changeType(EjbJarDocument.type);
-                // XmlBeansUtil.validateDD(result);
-                return (EjbJarDocument) result;
-            }
-            // deployment descriptor is probably in EJB 1.1 or 2.0 format
-            XmlDocumentProperties xmlDocumentProperties = cursor.documentProperties();
-            String publicId = xmlDocumentProperties.getDoctypePublicId();
-            String cmpVersion;
-            if ("-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 1.1//EN".equals(publicId)) {
-                cmpVersion = "1.x";
-            } else if ("-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN".equals(publicId)) {
-                cmpVersion = null;//2.x is the default "2.x";
-            } else {
-                throw new XmlException("Unrecognized document type: " + publicId);
-            }
-            String schemaLocationURL = "http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd";
-            String version = "2.1";
-            SchemaConversionUtils.convertToSchema(cursor, SchemaConversionUtils.J2EE_NAMESPACE, schemaLocationURL, version);
-            //play with message-driven
-            cursor.toStartDoc();
-            convertBeans(cursor, moveable, cmpVersion);
-        } finally {
-            cursor.dispose();
-            moveable.dispose();
-        }
-        XmlObject result = xmlObject.changeType(EjbJarDocument.type);
-        if (result != null) {
-            XmlBeansUtil.validateDD(result);
-            return (EjbJarDocument) result;
-        }
-        XmlBeansUtil.validateDD(xmlObject);
-        return (EjbJarDocument) xmlObject;
-    }
-
-    private static void convertBeans(XmlCursor cursor, XmlCursor moveable, String cmpVersion) {
-        cursor.toChild(SchemaConversionUtils.J2EE_NAMESPACE, "ejb-jar");
-        cursor.toChild(SchemaConversionUtils.J2EE_NAMESPACE, "enterprise-beans");
-        if (cursor.toFirstChild()) {
-            //there's at least one ejb...
-            do {
-                cursor.push();
-                String type = cursor.getName().getLocalPart();
-                if ("session".equals(type)) {
-                    cursor.toChild(SchemaConversionUtils.J2EE_NAMESPACE, "transaction-type");
-                    cursor.toNextSibling();
-                    SchemaConversionUtils.convertToJNDIEnvironmentRefsGroup(SchemaConversionUtils.J2EE_NAMESPACE, cursor, moveable);
-                } else if ("entity".equals(type)) {
-                    cursor.toChild(SchemaConversionUtils.J2EE_NAMESPACE, "persistence-type");
-                    String persistenceType = cursor.getTextValue();
-                    //reentrant is the last required tag before jndiEnvironmentRefsGroup
-                    cursor.toNextSibling(SchemaConversionUtils.J2EE_NAMESPACE, "reentrant");
-                    //Convert 2.0 True/False to true/false for 2.1
-                    cursor.setTextValue(cursor.getTextValue().toLowerCase());
-                    if (cmpVersion != null && !cursor.toNextSibling(CMP_VERSION) && "Container".equals(persistenceType)) {
-                        cursor.toNextSibling();
-                        cursor.insertElementWithText(CMP_VERSION, cmpVersion);
-                    }
-
-                    cursor.toNextSibling(SchemaConversionUtils.J2EE_NAMESPACE, "abstract-schema-name");
-                    while (cursor.toNextSibling(SchemaConversionUtils.J2EE_NAMESPACE, "cmp-field")) {
-                    }
-                    cursor.toNextSibling(SchemaConversionUtils.J2EE_NAMESPACE, "primkey-field");
-                    cursor.toNextSibling();
-                    SchemaConversionUtils.convertToJNDIEnvironmentRefsGroup(SchemaConversionUtils.J2EE_NAMESPACE, cursor, moveable);
-                } else if ("message-driven".equals(type)) {
-                    cursor.toFirstChild();
-                    if (cursor.toNextSibling(SchemaConversionUtils.J2EE_NAMESPACE, "messaging-type")) {
-                        cursor.toNextSibling(SchemaConversionUtils.J2EE_NAMESPACE, "transaction-type");
-                    } else {
-                        cursor.toNextSibling(SchemaConversionUtils.J2EE_NAMESPACE, "transaction-type");
-                        //insert messaging-type (introduced in EJB 2.1 spec) before transaction-type
-                        cursor.insertElementWithText("messaging-type", SchemaConversionUtils.J2EE_NAMESPACE, "javax.jms.MessageListener");
-                        //cursor still on transaction-type
-                    }
-                    if (!cursor.toNextSibling(SchemaConversionUtils.J2EE_NAMESPACE, "activation-config")) {
-                        //skip transaction-type
-                        cursor.toNextSibling();
-                        //convert EJB 2.0 elements to activation-config-properties.
-                        moveable.toCursor(cursor);
-                        cursor.push();
-                        cursor.beginElement("activation-config", SchemaConversionUtils.J2EE_NAMESPACE);
-                        boolean hasProperties = addActivationConfigProperty(moveable, cursor, "message-selector", "messageSelector");
-                        hasProperties |= addActivationConfigProperty(moveable, cursor, "acknowledge-mode", "acknowledgeMode");
-                        if (new QName(SchemaConversionUtils.J2EE_NAMESPACE, "message-driven-destination").equals(moveable.getName()) ||
-                                moveable.toNextSibling(SchemaConversionUtils.J2EE_NAMESPACE, "message-driven-destination")) {
-                            moveable.push();
-                            moveable.toFirstChild();
-                            hasProperties |= addActivationConfigProperty(moveable, cursor, "destination-type", "destinationType");
-                            hasProperties |= addActivationConfigProperty(moveable, cursor, "subscription-durability", "subscriptionDurability");
-                            moveable.pop();
-                            moveable.removeXml();
-                        }
-                        cursor.pop();
-                        if (!hasProperties) {
-                            //the activation-config element that we created is empty so delete it
-                            cursor.toPrevSibling();
-                            cursor.removeXml();
-                            //cursor should now be at first element in JNDIEnvironmentRefsGroup
-                        }
-                    } else {
-                        //cursor pointing at activation-config
-                        cursor.toNextSibling();
-                        //cursor should now be at first element in JNDIEnvironmentRefsGroup
-                    }
-                    SchemaConversionUtils.convertToJNDIEnvironmentRefsGroup(SchemaConversionUtils.J2EE_NAMESPACE, cursor, moveable);
-                }
-                cursor.pop();
-            } while (cursor.toNextSibling());
-        }
-    }
-
-    private static boolean addActivationConfigProperty(XmlCursor moveable, XmlCursor cursor, String elementName, String propertyName) {
-        QName name = new QName(SchemaConversionUtils.J2EE_NAMESPACE, elementName);
-        if (name.equals(moveable.getName()) || moveable.toNextSibling(name)) {
-            cursor.push();
-            cursor.beginElement("activation-config-property", SchemaConversionUtils.J2EE_NAMESPACE);
-            cursor.insertElementWithText("activation-config-property-name", SchemaConversionUtils.J2EE_NAMESPACE, propertyName);
-            cursor.insertElementWithText("activation-config-property-value", SchemaConversionUtils.J2EE_NAMESPACE, moveable.getTextValue());
-            moveable.removeXml();
-            cursor.pop();
-            cursor.toNextSibling();
-            return true;
-        }
-        return false;
-    }
-
 }

Modified: geronimo/server/trunk/plugins/openejb/geronimo-openejb-builder/src/test/java/org/apache/geronimo/openejb/deployment/SchemaConversionTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/openejb/geronimo-openejb-builder/src/test/java/org/apache/geronimo/openejb/deployment/SchemaConversionTest.java?rev=957655&r1=957654&r2=957655&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/openejb/geronimo-openejb-builder/src/test/java/org/apache/geronimo/openejb/deployment/SchemaConversionTest.java (original)
+++ geronimo/server/trunk/plugins/openejb/geronimo-openejb-builder/src/test/java/org/apache/geronimo/openejb/deployment/SchemaConversionTest.java Thu Jun 24 18:06:24 2010
@@ -18,16 +18,7 @@
 
 package org.apache.geronimo.openejb.deployment;
 
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.List;
-
-import junit.framework.Assert;
-import org.apache.geronimo.deployment.xmlbeans.XmlBeansUtil;
-import org.apache.geronimo.schema.SchemaConversionUtils;
 import org.apache.geronimo.testsupport.XmlBeansTestSupport;
-import org.apache.xmlbeans.XmlCursor;
-import org.apache.xmlbeans.XmlObject;
 
 /**
  * ejb 1.1 dtd appears to be a subset of ejb 2.0 dtd so the same xsl should
@@ -42,132 +33,134 @@ public class SchemaConversionTest extend
     public void testNothing() {
     }
 
-    public void XtestEJB11ToEJB21Transform() throws Exception {
-        URL srcXml = classLoader.getResource("j2ee_1_2dtd/ejb-1-11.xml");
-        URL expectedOutputXml = classLoader.getResource("j2ee_1_2dtd/ejb-1-21.xml");
-        XmlObject xmlObject = XmlObject.Factory.parse(srcXml);
-        XmlObject expected = XmlObject.Factory.parse(expectedOutputXml);
-        XmlBeansUtil.validateDD(expected);
-        xmlObject = XmlUtil.convertToEJBSchema(xmlObject);
-//        log.debug(xmlObject.toString());
-//        log.debug(expected.toString());
-        List problems = new ArrayList();
-        boolean ok = compareXmlObjects(xmlObject, expected, problems);
-        Assert.assertTrue("Differences: " + problems, ok);
-        //make sure trying to convert twice has no bad effects
-        XmlCursor cursor2 = xmlObject.newCursor();
-        try {
-            String schemaLocationURL = "http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd";
-            String version = "2.1";
-            Assert.assertFalse(SchemaConversionUtils.convertToSchema(cursor2, SchemaConversionUtils.J2EE_NAMESPACE, schemaLocationURL, version));
-        } finally {
-            cursor2.dispose();
-        }
-        boolean ok2 = compareXmlObjects(xmlObject, expected, problems);
-        Assert.assertTrue("Differences after reconverting to schema: " + problems, ok2);
-        //do the whole transform twice...
-        xmlObject = XmlUtil.convertToEJBSchema(xmlObject);
-        boolean ok3 = compareXmlObjects(xmlObject, expected, problems);
-        Assert.assertTrue("Differences after reconverting to ejb schema: " + problems, ok3);
-    }
-
-    public void XtestEJB20ToEJB21Transform() throws Exception {
-        URL srcXml = classLoader.getResource("j2ee_1_3dtd/ejb-jar.xml");
-        URL expectedOutputXml = classLoader.getResource("j2ee_1_3dtd/ejb-jar-21.xml");
-        XmlObject xmlObject = XmlObject.Factory.parse(srcXml);
-        XmlObject expected = XmlObject.Factory.parse(expectedOutputXml);
-        XmlBeansUtil.validateDD(expected);
-        xmlObject = XmlUtil.convertToEJBSchema(xmlObject);
-//        log.debug(xmlObject.toString());
-//        log.debug(expected.toString());
-        List problems = new ArrayList();
-        boolean ok = compareXmlObjects(xmlObject, expected, problems);
-        Assert.assertTrue("Differences: " + problems, ok);
-        //make sure trying to convert twice has no bad effects
-        XmlCursor cursor2 = xmlObject.newCursor();
-        try {
-            String schemaLocationURL = "http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd";
-            String version = "2.1";
-            Assert.assertFalse(SchemaConversionUtils.convertToSchema(cursor2, SchemaConversionUtils.J2EE_NAMESPACE, schemaLocationURL, version));
-        } finally {
-            cursor2.dispose();
-        }
-        boolean ok2 = compareXmlObjects(xmlObject, expected, problems);
-        Assert.assertTrue("Differences after reconverting to schema: " + problems, ok2);
-        //do the whole transform twice...
-        xmlObject = XmlUtil.convertToEJBSchema(xmlObject);
-        boolean ok3 = compareXmlObjects(xmlObject, expected, problems);
-        Assert.assertTrue("Differences after reconverting to ejb schema: " + problems, ok3);
-    }
-
-    public void xtestMDB20ToEJB21TransformBugGERONIMO_1649() throws Exception {
-        URL srcXml = classLoader.getResource("j2ee_1_3dtd/mdb-ejb-jar-20-GERONIMO-1649.xml");
-        URL expectedOutputXml = classLoader.getResource("j2ee_1_3dtd/mdb-ejb-jar-21-GERONIMO-1649.xml");
-        XmlObject xmlObject = XmlObject.Factory.parse(srcXml);
-        XmlObject expected = XmlObject.Factory.parse(expectedOutputXml);
-        XmlBeansUtil.validateDD(expected);
-        xmlObject = XmlUtil.convertToEJBSchema(xmlObject);
-//        log.debug(xmlObject.toString());
-//        log.debug(expected.toString());
-        List problems = new ArrayList();
-        boolean ok = compareXmlObjects(xmlObject, expected, problems);
-        Assert.assertTrue("Differences: " + problems, ok);
-        //make sure trying to convert twice has no bad effects
-        XmlCursor cursor2 = xmlObject.newCursor();
-        try {
-            String schemaLocationURL = "http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd";
-            String version = "2.1";
-            Assert.assertFalse(SchemaConversionUtils.convertToSchema(cursor2, SchemaConversionUtils.J2EE_NAMESPACE, schemaLocationURL, version));
-        } finally {
-            cursor2.dispose();
-        }
-        boolean ok2 = compareXmlObjects(xmlObject, expected, problems);
-        Assert.assertTrue("Differences after reconverting to schema: " + problems, ok2);
-        //do the whole transform twice...
-        xmlObject = XmlUtil.convertToEJBSchema(xmlObject);
-        boolean ok3 = compareXmlObjects(xmlObject, expected, problems);
-        Assert.assertTrue("Differences after reconverting to ejb schema: " + problems, ok3);
-    }
+    //TODO consider moving tests to openejb-jee.
 
-    public void XtestMDB20To21Transform() throws Exception {
-        URL srcXml = classLoader.getResource("j2ee_1_3dtd/mdb-ejb-jar-20.xml");
-        URL expectedOutputXml = classLoader.getResource("j2ee_1_3dtd/mdb-ejb-jar-21.xml");
-        XmlObject xmlObject = XmlObject.Factory.parse(srcXml);
-        XmlObject expected = XmlObject.Factory.parse(expectedOutputXml);
-        XmlBeansUtil.validateDD(expected);
-        xmlObject = XmlUtil.convertToEJBSchema(xmlObject);
-//        log.debug(xmlObject.toString());
-//        log.debug(expected.toString());
-        List problems = new ArrayList();
-        boolean ok = compareXmlObjects(xmlObject, expected, problems);
-        Assert.assertTrue("Differences: " + problems, ok);
-        //make sure trying to convert twice has no bad effects
-        XmlCursor cursor2 = xmlObject.newCursor();
-        try {
-            String schemaLocationURL = "http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd";
-            String version = "2.1";
-            Assert.assertFalse(SchemaConversionUtils.convertToSchema(cursor2, SchemaConversionUtils.J2EE_NAMESPACE, schemaLocationURL, version));
-        } finally {
-            cursor2.dispose();
-        }
-        boolean ok2 = compareXmlObjects(xmlObject, expected, problems);
-        Assert.assertTrue("Differences after reconverting to schema: " + problems, ok2);
-        //do the whole transform twice...
-        xmlObject = XmlUtil.convertToEJBSchema(xmlObject);
-        boolean ok3 = compareXmlObjects(xmlObject, expected, problems);
-        Assert.assertTrue("Differences after reconverting to ejb schema: " + problems, ok3);
-    }
-
-
-    public void XtestEJB21To21DoesNothing() throws Exception {
-        URL srcXml = classLoader.getResource("j2ee_1_4schema/ejb-jar.xml");
-        URL expectedOutputXml = classLoader.getResource("j2ee_1_4schema/ejb-jar.xml");
-        XmlObject xmlObject = XmlObject.Factory.parse(srcXml);
-        xmlObject = XmlUtil.convertToEJBSchema(xmlObject);
-        XmlObject expected = XmlObject.Factory.parse(expectedOutputXml);
-        List problems = new ArrayList();
-        boolean ok = compareXmlObjects(xmlObject, expected, problems);
-        Assert.assertTrue("Differences: " + problems, ok);
-    }
+//    public void XtestEJB11ToEJB21Transform() throws Exception {
+//        URL srcXml = classLoader.getResource("j2ee_1_2dtd/ejb-1-11.xml");
+//        URL expectedOutputXml = classLoader.getResource("j2ee_1_2dtd/ejb-1-21.xml");
+//        XmlObject xmlObject = XmlObject.Factory.parse(srcXml);
+//        XmlObject expected = XmlObject.Factory.parse(expectedOutputXml);
+//        XmlBeansUtil.validateDD(expected);
+//        xmlObject = XmlUtil.convertToEJBSchema(xmlObject);
+////        log.debug(xmlObject.toString());
+////        log.debug(expected.toString());
+//        List problems = new ArrayList();
+//        boolean ok = compareXmlObjects(xmlObject, expected, problems);
+//        Assert.assertTrue("Differences: " + problems, ok);
+//        //make sure trying to convert twice has no bad effects
+//        XmlCursor cursor2 = xmlObject.newCursor();
+//        try {
+//            String schemaLocationURL = "http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd";
+//            String version = "2.1";
+//            Assert.assertFalse(SchemaConversionUtils.convertToSchema(cursor2, SchemaConversionUtils.J2EE_NAMESPACE, schemaLocationURL, version));
+//        } finally {
+//            cursor2.dispose();
+//        }
+//        boolean ok2 = compareXmlObjects(xmlObject, expected, problems);
+//        Assert.assertTrue("Differences after reconverting to schema: " + problems, ok2);
+//        //do the whole transform twice...
+//        xmlObject = XmlUtil.convertToEJBSchema(xmlObject);
+//        boolean ok3 = compareXmlObjects(xmlObject, expected, problems);
+//        Assert.assertTrue("Differences after reconverting to ejb schema: " + problems, ok3);
+//    }
+
+//    public void XtestEJB20ToEJB21Transform() throws Exception {
+//        URL srcXml = classLoader.getResource("j2ee_1_3dtd/ejb-jar.xml");
+//        URL expectedOutputXml = classLoader.getResource("j2ee_1_3dtd/ejb-jar-21.xml");
+//        XmlObject xmlObject = XmlObject.Factory.parse(srcXml);
+//        XmlObject expected = XmlObject.Factory.parse(expectedOutputXml);
+//        XmlBeansUtil.validateDD(expected);
+//        xmlObject = XmlUtil.convertToEJBSchema(xmlObject);
+////        log.debug(xmlObject.toString());
+////        log.debug(expected.toString());
+//        List problems = new ArrayList();
+//        boolean ok = compareXmlObjects(xmlObject, expected, problems);
+//        Assert.assertTrue("Differences: " + problems, ok);
+//        //make sure trying to convert twice has no bad effects
+//        XmlCursor cursor2 = xmlObject.newCursor();
+//        try {
+//            String schemaLocationURL = "http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd";
+//            String version = "2.1";
+//            Assert.assertFalse(SchemaConversionUtils.convertToSchema(cursor2, SchemaConversionUtils.J2EE_NAMESPACE, schemaLocationURL, version));
+//        } finally {
+//            cursor2.dispose();
+//        }
+//        boolean ok2 = compareXmlObjects(xmlObject, expected, problems);
+//        Assert.assertTrue("Differences after reconverting to schema: " + problems, ok2);
+//        //do the whole transform twice...
+//        xmlObject = XmlUtil.convertToEJBSchema(xmlObject);
+//        boolean ok3 = compareXmlObjects(xmlObject, expected, problems);
+//        Assert.assertTrue("Differences after reconverting to ejb schema: " + problems, ok3);
+//    }
+
+//    public void xtestMDB20ToEJB21TransformBugGERONIMO_1649() throws Exception {
+//        URL srcXml = classLoader.getResource("j2ee_1_3dtd/mdb-ejb-jar-20-GERONIMO-1649.xml");
+//        URL expectedOutputXml = classLoader.getResource("j2ee_1_3dtd/mdb-ejb-jar-21-GERONIMO-1649.xml");
+//        XmlObject xmlObject = XmlObject.Factory.parse(srcXml);
+//        XmlObject expected = XmlObject.Factory.parse(expectedOutputXml);
+//        XmlBeansUtil.validateDD(expected);
+//        xmlObject = XmlUtil.convertToEJBSchema(xmlObject);
+////        log.debug(xmlObject.toString());
+////        log.debug(expected.toString());
+//        List problems = new ArrayList();
+//        boolean ok = compareXmlObjects(xmlObject, expected, problems);
+//        Assert.assertTrue("Differences: " + problems, ok);
+//        //make sure trying to convert twice has no bad effects
+//        XmlCursor cursor2 = xmlObject.newCursor();
+//        try {
+//            String schemaLocationURL = "http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd";
+//            String version = "2.1";
+//            Assert.assertFalse(SchemaConversionUtils.convertToSchema(cursor2, SchemaConversionUtils.J2EE_NAMESPACE, schemaLocationURL, version));
+//        } finally {
+//            cursor2.dispose();
+//        }
+//        boolean ok2 = compareXmlObjects(xmlObject, expected, problems);
+//        Assert.assertTrue("Differences after reconverting to schema: " + problems, ok2);
+//        //do the whole transform twice...
+//        xmlObject = XmlUtil.convertToEJBSchema(xmlObject);
+//        boolean ok3 = compareXmlObjects(xmlObject, expected, problems);
+//        Assert.assertTrue("Differences after reconverting to ejb schema: " + problems, ok3);
+//    }
+
+//    public void XtestMDB20To21Transform() throws Exception {
+//        URL srcXml = classLoader.getResource("j2ee_1_3dtd/mdb-ejb-jar-20.xml");
+//        URL expectedOutputXml = classLoader.getResource("j2ee_1_3dtd/mdb-ejb-jar-21.xml");
+//        XmlObject xmlObject = XmlObject.Factory.parse(srcXml);
+//        XmlObject expected = XmlObject.Factory.parse(expectedOutputXml);
+//        XmlBeansUtil.validateDD(expected);
+//        xmlObject = XmlUtil.convertToEJBSchema(xmlObject);
+////        log.debug(xmlObject.toString());
+////        log.debug(expected.toString());
+//        List problems = new ArrayList();
+//        boolean ok = compareXmlObjects(xmlObject, expected, problems);
+//        Assert.assertTrue("Differences: " + problems, ok);
+//        //make sure trying to convert twice has no bad effects
+//        XmlCursor cursor2 = xmlObject.newCursor();
+//        try {
+//            String schemaLocationURL = "http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd";
+//            String version = "2.1";
+//            Assert.assertFalse(SchemaConversionUtils.convertToSchema(cursor2, SchemaConversionUtils.J2EE_NAMESPACE, schemaLocationURL, version));
+//        } finally {
+//            cursor2.dispose();
+//        }
+//        boolean ok2 = compareXmlObjects(xmlObject, expected, problems);
+//        Assert.assertTrue("Differences after reconverting to schema: " + problems, ok2);
+//        //do the whole transform twice...
+//        xmlObject = XmlUtil.convertToEJBSchema(xmlObject);
+//        boolean ok3 = compareXmlObjects(xmlObject, expected, problems);
+//        Assert.assertTrue("Differences after reconverting to ejb schema: " + problems, ok3);
+//    }
+
+
+//    public void XtestEJB21To21DoesNothing() throws Exception {
+//        URL srcXml = classLoader.getResource("j2ee_1_4schema/ejb-jar.xml");
+//        URL expectedOutputXml = classLoader.getResource("j2ee_1_4schema/ejb-jar.xml");
+//        XmlObject xmlObject = XmlObject.Factory.parse(srcXml);
+//        xmlObject = XmlUtil.convertToEJBSchema(xmlObject);
+//        XmlObject expected = XmlObject.Factory.parse(expectedOutputXml);
+//        List problems = new ArrayList();
+//        boolean ok = compareXmlObjects(xmlObject, expected, problems);
+//        Assert.assertTrue("Differences: " + problems, ok);
+//    }
 
 }

Modified: geronimo/server/trunk/plugins/openejb/geronimo-openejb-clustering-builder-wadi/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/openejb/geronimo-openejb-clustering-builder-wadi/pom.xml?rev=957655&r1=957654&r2=957655&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/openejb/geronimo-openejb-clustering-builder-wadi/pom.xml (original)
+++ geronimo/server/trunk/plugins/openejb/geronimo-openejb-clustering-builder-wadi/pom.xml Thu Jun 24 18:06:24 2010
@@ -60,14 +60,6 @@
                     <instructions>
                         <!--<_versionpolicy>[$(version;==;$(@)),$(version;+;$(@)))</_versionpolicy>-->
                         <Import-Package>
-                            org.apache.geronimo.xbeans.javaee.impl,
-                            org.apache.geronimo.xbeans.javaee,
-                            org.apache.geronimo.xbeans.persistence.impl,
-                            org.apache.geronimo.xbeans.persistence,
-                            org.apache.geronimo.xbeans.j2ee.impl,
-                            org.apache.geronimo.xbeans.j2ee,
-                            org.w3.xml.x1998.namespace.impl,
-                            org.w3.xml.x1998.namespace,
                             org.apache.geronimo.deployment.xbeans.impl,
                             org.apache.geronimo.deployment.javabean.xbeans.impl,
                             org.apache.geronimo.deployment.xbeans,

Modified: geronimo/server/trunk/plugins/openejb/openejb-clustering-builder-wadi/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/openejb/openejb-clustering-builder-wadi/pom.xml?rev=957655&r1=957654&r2=957655&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/openejb/openejb-clustering-builder-wadi/pom.xml (original)
+++ geronimo/server/trunk/plugins/openejb/openejb-clustering-builder-wadi/pom.xml Thu Jun 24 18:06:24 2010
@@ -78,14 +78,6 @@
                     <instructions>
                         <!--<_versionpolicy>[$(version;==;$(@)),$(version;+;$(@)))</_versionpolicy>-->
                         <Import-Package>
-                            org.apache.geronimo.xbeans.javaee.impl,
-                            org.apache.geronimo.xbeans.javaee,
-                            org.apache.geronimo.xbeans.persistence.impl,
-                            org.apache.geronimo.xbeans.persistence,
-                            org.apache.geronimo.xbeans.j2ee.impl,
-                            org.apache.geronimo.xbeans.j2ee,
-                            org.w3.xml.x1998.namespace.impl,
-                            org.w3.xml.x1998.namespace,
                             org.apache.geronimo.deployment.xbeans.impl,
                             org.apache.geronimo.deployment.javabean.xbeans.impl,
                             org.apache.geronimo.deployment.xbeans,

Modified: geronimo/server/trunk/plugins/openejb/openejb-deployer/src/main/history/dependencies.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/openejb/openejb-deployer/src/main/history/dependencies.xml?rev=957655&r1=957654&r2=957655&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/openejb/openejb-deployer/src/main/history/dependencies.xml (original)
+++ geronimo/server/trunk/plugins/openejb/openejb-deployer/src/main/history/dependencies.xml Thu Jun 24 18:06:24 2010
@@ -36,9 +36,4 @@
         <artifactId>openejb-osgi-core</artifactId>
         <type>jar</type>
     </dependency>
-    <dependency>
-        <groupId>org.osgi</groupId>
-        <artifactId>org.osgi.core</artifactId>
-        <type>jar</type>
-    </dependency>
 </plugin-artifact>

Modified: geronimo/server/trunk/plugins/openejb/openejb/src/main/history/dependencies.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/openejb/openejb/src/main/history/dependencies.xml?rev=957655&r1=957654&r2=957655&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/openejb/openejb/src/main/history/dependencies.xml (original)
+++ geronimo/server/trunk/plugins/openejb/openejb/src/main/history/dependencies.xml Thu Jun 24 18:06:24 2010
@@ -122,6 +122,11 @@
         <type>jar</type>
     </dependency>
     <dependency>
+        <groupId>org.apache.xbean</groupId>
+        <artifactId>xbean-bundleutils</artifactId>
+        <type>jar</type>
+    </dependency>
+    <dependency>
         <groupId>org.apache.yoko</groupId>
         <artifactId>yoko-spec-corba</artifactId>
         <type>jar</type>

Modified: geronimo/server/trunk/plugins/openjpa2/geronimo-persistence-jpa20-builder/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/openjpa2/geronimo-persistence-jpa20-builder/pom.xml?rev=957655&r1=957654&r2=957655&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/openjpa2/geronimo-persistence-jpa20-builder/pom.xml (original)
+++ geronimo/server/trunk/plugins/openjpa2/geronimo-persistence-jpa20-builder/pom.xml Thu Jun 24 18:06:24 2010
@@ -47,6 +47,10 @@
             <artifactId>geronimo-persistence-jpa20</artifactId>
             <version>${project.version}</version>
         </dependency>
+        <dependency>
+            <groupId>org.apache.openejb</groupId>
+            <artifactId>openejb-jee</artifactId>
+        </dependency>
         
     </dependencies>
 

Modified: geronimo/server/trunk/plugins/openjpa2/geronimo-persistence-jpa20-builder/src/main/java/org/apache/geronimo/persistence/builder/PersistenceContextRefBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/openjpa2/geronimo-persistence-jpa20-builder/src/main/java/org/apache/geronimo/persistence/builder/PersistenceContextRefBuilder.java?rev=957655&r1=957654&r2=957655&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/openjpa2/geronimo-persistence-jpa20-builder/src/main/java/org/apache/geronimo/persistence/builder/PersistenceContextRefBuilder.java (original)
+++ geronimo/server/trunk/plugins/openjpa2/geronimo-persistence-jpa20-builder/src/main/java/org/apache/geronimo/persistence/builder/PersistenceContextRefBuilder.java Thu Jun 24 18:06:24 2010
@@ -18,6 +18,7 @@
 package org.apache.geronimo.persistence.builder;
 
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.LinkedHashSet;
@@ -26,17 +27,13 @@ import java.util.Map;
 import java.util.Set;
 
 import javax.xml.namespace.QName;
-
 import org.apache.geronimo.common.DeploymentException;
 import org.apache.geronimo.gbean.AbstractName;
 import org.apache.geronimo.gbean.AbstractNameQuery;
 import org.apache.geronimo.gbean.GBeanData;
-import org.apache.geronimo.gbean.GBeanInfo;
-import org.apache.geronimo.gbean.GBeanInfoBuilder;
 import org.apache.geronimo.gbean.annotation.GBean;
 import org.apache.geronimo.gbean.annotation.ParamAttribute;
 import org.apache.geronimo.j2ee.deployment.Module;
-import org.apache.geronimo.j2ee.deployment.NamingBuilder;
 import org.apache.geronimo.j2ee.deployment.annotation.PersistenceContextAnnotationHelper;
 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
 import org.apache.geronimo.kernel.GBeanNotFoundException;
@@ -51,9 +48,10 @@ import org.apache.geronimo.xbeans.geroni
 import org.apache.geronimo.xbeans.geronimo.naming.GerPersistenceContextRefType;
 import org.apache.geronimo.xbeans.geronimo.naming.GerPersistenceContextTypeType;
 import org.apache.geronimo.xbeans.geronimo.naming.GerPropertyType;
-import org.apache.geronimo.xbeans.javaee6.PersistenceContextRefType;
-import org.apache.geronimo.xbeans.javaee6.PersistenceContextTypeType;
-import org.apache.geronimo.xbeans.javaee6.PropertyType;
+import org.apache.openejb.jee.JndiConsumer;
+import org.apache.openejb.jee.PersistenceContextRef;
+import org.apache.openejb.jee.PersistenceContextType;
+import org.apache.openejb.jee.Property;
 import org.apache.xmlbeans.QNameSet;
 import org.apache.xmlbeans.XmlObject;
 
@@ -71,41 +69,41 @@ public class PersistenceContextRefBuilde
     private final boolean strictMatching;
 
     public PersistenceContextRefBuilder(@ParamAttribute(name = "defaultEnvironment") Environment defaultEnvironment,
-                                     @ParamAttribute(name = "defaultPersistenceUnitAbstractNameQuery") AbstractNameQuery defaultPersistenceUnitAbstractNameQuery,
-                                     @ParamAttribute(name = "strictMatching") boolean strictMatching) {
+                                        @ParamAttribute(name = "defaultPersistenceUnitAbstractNameQuery") AbstractNameQuery defaultPersistenceUnitAbstractNameQuery,
+                                        @ParamAttribute(name = "strictMatching") boolean strictMatching) {
         super(defaultEnvironment);
         this.defaultPersistenceUnitAbstractNameQuery = defaultPersistenceUnitAbstractNameQuery;
         this.strictMatching = strictMatching;
     }
 
-    protected boolean willMergeEnvironment(XmlObject specDD, XmlObject plan) throws DeploymentException {
-        return plan != null && plan.selectChildren(PersistenceContextRefBuilder.GER_PERSISTENCE_CONTEXT_REF_QNAME_SET).length > 0;
+    protected boolean willMergeEnvironment(JndiConsumer specDD, XmlObject plan) throws DeploymentException {
+        return specDD != null && specDD.getPersistenceContextRef().size() > 0;
     }
 
-    public void buildNaming(XmlObject specDD, XmlObject plan, Module module, Map componentContext) throws DeploymentException {
+    public void buildNaming(JndiConsumer specDD, XmlObject plan, Module module, Map componentContext) throws DeploymentException {
 
         // Discover and process any @PersistenceContextRef annotations (if !metadata-complete)
         if ((module != null) && (module.getClassFinder() != null)) {
-            processAnnotations(module);
+            processAnnotations(specDD, module);
         }
 
-        List<PersistenceContextRefType> specPersistenceContextRefsUntyped = convert(specDD.selectChildren(PERSISTENCE_CONTEXT_REF_QNAME_SET), JEE_CONVERTER, PersistenceContextRefType.class, PersistenceContextRefType.type);
+        Collection<PersistenceContextRef> specPersistenceContextRefsUntyped = specDD.getPersistenceContextRef();
         Map<String, GerPersistenceContextRefType> gerPersistenceContextRefsUntyped = getGerPersistenceContextRefs(plan);
         List<DeploymentException> problems = new ArrayList<DeploymentException>();
         Configuration localConfiguration = module.getEarContext().getConfiguration();
-        for (PersistenceContextRefType persistenceContextRef : specPersistenceContextRefsUntyped) {
+        for (PersistenceContextRef persistenceContextRef : specPersistenceContextRefsUntyped) {
             try {
-                String persistenceContextRefName = persistenceContextRef.getPersistenceContextRefName().getStringValue().trim();
+                String persistenceContextRefName = persistenceContextRef.getPersistenceContextRefName().trim();
 
-                addInjections(persistenceContextRefName, persistenceContextRef.getInjectionTargetArray(), componentContext);
-                PersistenceContextTypeType persistenceContextType = persistenceContextRef.getPersistenceContextType();
-                boolean transactionScoped = persistenceContextType == null || !persistenceContextType.getStringValue().equalsIgnoreCase("extended");
+                addInjections(persistenceContextRefName, persistenceContextRef.getInjectionTarget(), componentContext);
+                PersistenceContextType persistenceContextType = persistenceContextRef.getPersistenceContextType();
+                boolean transactionScoped = persistenceContextType == null || persistenceContextType.equals(PersistenceContextType.TRANSACTION);
 
-                PropertyType[] propertyTypes = persistenceContextRef.getPersistencePropertyArray();
+                List<Property> propertyTypes = persistenceContextRef.getPersistenceProperty();
                 Map<String, String> properties = new HashMap<String, String>();
-                for (PropertyType propertyType : propertyTypes) {
-                    String key = propertyType.getName().getStringValue();
-                    String value = propertyType.getValue().getStringValue();
+                for (Property propertyType : propertyTypes) {
+                    String key = propertyType.getName();
+                    String value = propertyType.getValue();
                     properties.put(key, value);
                 }
 
@@ -115,8 +113,8 @@ public class PersistenceContextRefBuilde
                     persistenceUnitNameQuery = findPersistenceUnit(gerPersistenceContextRef);
                     addProperties(gerPersistenceContextRef, properties);
                     checkForGBean(localConfiguration, persistenceUnitNameQuery, true);
-                } else if (persistenceContextRef.isSetPersistenceUnitName() && persistenceContextRef.getPersistenceUnitName().getStringValue().trim().length() > 0) {
-                    String persistenceUnitName = persistenceContextRef.getPersistenceUnitName().getStringValue().trim();
+                } else if (persistenceContextRef.getPersistenceUnitName() != null && persistenceContextRef.getPersistenceUnitName().trim().length() > 0) {
+                    String persistenceUnitName = persistenceContextRef.getPersistenceUnitName().trim();
                     persistenceUnitNameQuery = new AbstractNameQuery(null, Collections.singletonMap("name", persistenceUnitName), PERSISTENCE_UNIT_INTERFACE_TYPES);
                     if (!checkForGBean(localConfiguration, persistenceUnitNameQuery, strictMatching)) {
                         persistenceUnitName = "persistence/" + persistenceUnitName;
@@ -246,9 +244,9 @@ public class PersistenceContextRefBuilde
         return persistenceUnitNameQuery;
     }
 
-    private void processAnnotations(Module module) throws DeploymentException {
+    private void processAnnotations(JndiConsumer specDD, Module module) throws DeploymentException {
         // Process all the annotations for this naming builder type
-        PersistenceContextAnnotationHelper.processAnnotations(module.getAnnotatedApp(), module.getClassFinder());
+        PersistenceContextAnnotationHelper.processAnnotations(specDD, module.getClassFinder());
     }
 
     public QNameSet getSpecQNameSet() {

Modified: geronimo/server/trunk/plugins/openjpa2/geronimo-persistence-jpa20-builder/src/main/java/org/apache/geronimo/persistence/builder/PersistenceUnitBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/openjpa2/geronimo-persistence-jpa20-builder/src/main/java/org/apache/geronimo/persistence/builder/PersistenceUnitBuilder.java?rev=957655&r1=957654&r2=957655&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/openjpa2/geronimo-persistence-jpa20-builder/src/main/java/org/apache/geronimo/persistence/builder/PersistenceUnitBuilder.java (original)
+++ geronimo/server/trunk/plugins/openjpa2/geronimo-persistence-jpa20-builder/src/main/java/org/apache/geronimo/persistence/builder/PersistenceUnitBuilder.java Thu Jun 24 18:06:24 2010
@@ -29,13 +29,16 @@ import java.util.Properties;
 import java.util.jar.JarFile;
 import java.util.zip.ZipEntry;
 
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Unmarshaller;
 import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamReader;
 import org.apache.geronimo.common.DeploymentException;
 import org.apache.geronimo.deployment.ClassPathList;
 import org.apache.geronimo.deployment.DeployableBundle;
 import org.apache.geronimo.deployment.ModuleIDBuilder;
 import org.apache.geronimo.deployment.service.EnvironmentBuilder;
-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;
@@ -53,13 +56,11 @@ import org.apache.geronimo.kernel.config
 import org.apache.geronimo.kernel.repository.Environment;
 import org.apache.geronimo.naming.ResourceSource;
 import org.apache.geronimo.persistence.PersistenceUnitGBean;
-import org.apache.geronimo.schema.SchemaConversionUtils;
-import org.apache.geronimo.xbeans.persistence20.PersistenceDocument;
-import org.apache.xbean.osgi.bundle.util.BundleClassLoader;
+import org.apache.openejb.jee.JAXBContextFactory;
+import org.apache.openejb.jee.JaxbJavaee;
+import org.apache.openejb.jee.Persistence;
 import org.apache.xbean.osgi.bundle.util.BundleResourceFinder;
 import org.apache.xmlbeans.QNameSet;
-import org.apache.xmlbeans.XmlCursor;
-import org.apache.xmlbeans.XmlException;
 import org.apache.xmlbeans.XmlObject;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
@@ -85,7 +86,7 @@ public class PersistenceUnitBuilder impl
         }
     };
 
-    private static final QName PERSISTENCE_QNAME = PersistenceDocument.type.getDocumentElementName();
+    private static final QName PERSISTENCE_QNAME = new QName("http://java.sun.com/xml/ns/persistence", "persistence");
 
     private final Environment defaultEnvironment;
     private final String defaultPersistenceProviderClassName;
@@ -132,15 +133,15 @@ public class PersistenceUnitBuilder impl
         EARContext moduleContext = module.getEarContext();
         XmlObject[] raws = container.selectChildren(PERSISTENCE_QNAME);
 
-        Map<String, PersistenceDocument.Persistence.PersistenceUnit> overrides = new HashMap<String, PersistenceDocument.Persistence.PersistenceUnit>();
+        Map<String, Persistence.PersistenceUnit> overrides = new HashMap<String, Persistence.PersistenceUnit>();
         try {
             for (XmlObject raw : raws) {
-                PersistenceDocument.Persistence persistence = convertToPersistenceUnit(raw.copy());
-                for (PersistenceDocument.Persistence.PersistenceUnit unit : persistence.getPersistenceUnitArray()) {
+                Persistence persistence = fromXmlObject(raw);
+                for (Persistence.PersistenceUnit unit : persistence.getPersistenceUnit()) {
                     overrides.put(unit.getName().trim(), unit);
                 }
             }
-        } catch (XmlException e) {
+        } catch (JAXBException e) {
             throw new DeploymentException("Parse Persistence configuration file failed", e);
         }
         try {
@@ -182,14 +183,15 @@ public class PersistenceUnitBuilder impl
             for (Map.Entry<URL, String> entry : persistenceURLs.entrySet()) {
                 URL persistenceUrl = entry.getKey();
                 String persistenceLocation = entry.getValue();
-                PersistenceDocument persistenceDocument;
+                Persistence persistence;
+                InputStream in = persistenceUrl.openStream();
                 try {
-                    XmlObject xmlObject = XmlBeansUtil.parse(persistenceUrl, new BundleClassLoader(moduleContext.getDeploymentBundle()));
-                    persistenceDocument = convertToPersistenceDocument(xmlObject);
-                } catch (XmlException e) {
+                    persistence = (Persistence) JaxbJavaee.unmarshal(Persistence.class, in);
+                } catch (JAXBException e) {
                     throw new DeploymentException("Could not parse persistence.xml file: " + persistenceUrl, e);
+                } finally {
+                    in.close();
                 }
-                PersistenceDocument.Persistence persistence = persistenceDocument.getPersistence();
                 buildPersistenceUnits(persistence, overrides, module, persistenceLocation);
                 knownPersistenceUrls.add(persistenceUrl);
             }
@@ -197,7 +199,7 @@ public class PersistenceUnitBuilder impl
             throw new DeploymentException("Could not look for META-INF/persistence.xml files", e);
         }
 
-        for (PersistenceDocument.Persistence.PersistenceUnit persistenceUnit : overrides.values()) {
+        for (Persistence.PersistenceUnit persistenceUnit : overrides.values()) {
             GBeanData data = installPersistenceUnitGBean(persistenceUnit, module, module.getTargetPath());
             respectExcludeUnlistedClasses(data);
         }
@@ -206,50 +208,9 @@ public class PersistenceUnitBuilder impl
     public void addGBeans(EARContext earContext, Module module, Bundle bundle, Collection repository) throws DeploymentException {
     }
 
-    protected PersistenceDocument convertToPersistenceDocument(XmlObject xmlObject) throws XmlException {
-        XmlCursor cursor = null;
-        try {
-            cursor = xmlObject.newCursor();
-            cursor.toStartDoc();
-            cursor.toFirstChild();
-            SchemaConversionUtils.convertSchemaVersion(cursor, SchemaConversionUtils.JPA_PERSISTENCE_NAMESPACE, "http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd", "2.0");
-            XmlObject result = xmlObject.changeType(PersistenceDocument.type);
-            XmlBeansUtil.validateDD(result);
-            return (PersistenceDocument) result;
-        } finally {
-            if (cursor != null) {
-                try {
-                    cursor.dispose();
-                } catch (Exception e) {
-                    //ignore
-                }
-            }
-        }
-    }
-
-    protected PersistenceDocument.Persistence convertToPersistenceUnit(XmlObject xmlObject) throws XmlException {
-//        XmlCursor cursor = null;
-//        try {
-//            cursor = xmlObject.newCursor();
-//            cursor.toStartDoc();
-//            cursor.toFirstChild();
-//            SchemaConversionUtils.convertSchemaVersion(cursor, SchemaConversionUtils.JPA_PERSISTENCE_NAMESPACE, "http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd", "2.0");
-        XmlObject result = xmlObject.changeType(PersistenceDocument.Persistence.type);
-        XmlBeansUtil.validateDD(result);
-        return (PersistenceDocument.Persistence) result;
-//        } finally {
-//            if (cursor != null) {
-//                try {
-//                    cursor.dispose();
-//                } catch (Exception e) {
-//                }
-//            }
-//        }
-    }
-
-    private void buildPersistenceUnits(PersistenceDocument.Persistence persistence, Map<String, PersistenceDocument.Persistence.PersistenceUnit> overrides, Module module, String persistenceModulePath) throws DeploymentException {
-        PersistenceDocument.Persistence.PersistenceUnit[] persistenceUnits = persistence.getPersistenceUnitArray();
-        for (PersistenceDocument.Persistence.PersistenceUnit persistenceUnit : persistenceUnits) {
+    private void buildPersistenceUnits(Persistence persistence, Map<String, Persistence.PersistenceUnit> overrides, Module module, String persistenceModulePath) throws DeploymentException {
+        List<Persistence.PersistenceUnit> persistenceUnits = persistence.getPersistenceUnit();
+        for (Persistence.PersistenceUnit persistenceUnit : persistenceUnits) {
             GBeanData data = installPersistenceUnitGBean(persistenceUnit, module, persistenceModulePath);
             String unitName = persistenceUnit.getName().trim();
             if (overrides.get(unitName) != null) {
@@ -259,7 +220,7 @@ public class PersistenceUnitBuilder impl
         }
     }
 
-    private GBeanData installPersistenceUnitGBean(PersistenceDocument.Persistence.PersistenceUnit persistenceUnit, Module module, String persistenceModulePath) throws DeploymentException {
+    private GBeanData installPersistenceUnitGBean(Persistence.PersistenceUnit persistenceUnit, Module module, String persistenceModulePath) throws DeploymentException {
         EARContext moduleContext = module.getEarContext();
         String persistenceUnitName = persistenceUnit.getName().trim();
         if (persistenceUnitName.length() == 0) {
@@ -307,14 +268,14 @@ public class PersistenceUnitBuilder impl
         return gbeanData;
     }
 
-    private void setOverrideableProperties(PersistenceDocument.Persistence.PersistenceUnit persistenceUnit, GBeanData gbeanData) throws DeploymentException {
-        if (persistenceUnit.isSetProvider()) {
+    private void setOverrideableProperties(Persistence.PersistenceUnit persistenceUnit, GBeanData gbeanData) throws DeploymentException {
+        if (persistenceUnit.getProvider() != null) {
             gbeanData.setAttribute("persistenceProviderClassName", persistenceUnit.getProvider().trim());
         }
-        if (persistenceUnit.isSetTransactionType()) {
+        if (persistenceUnit.getTransactionType() != null) {
             gbeanData.setAttribute("persistenceUnitTransactionType", persistenceUnit.getTransactionType().toString());
         }
-        if (persistenceUnit.isSetJtaDataSource()) {
+        if (persistenceUnit.getJtaDataSource() != null) {
             String jtaDataSourceString = persistenceUnit.getJtaDataSource().trim();
             try {
                 AbstractNameQuery jtaDataSourceNameQuery = getAbstractNameQuery(jtaDataSourceString);
@@ -324,7 +285,7 @@ public class PersistenceUnitBuilder impl
             }
         }
 
-        if (persistenceUnit.isSetNonJtaDataSource()) {
+        if (persistenceUnit.getNonJtaDataSource() != null) {
             String nonJtaDataSourceString = persistenceUnit.getNonJtaDataSource().trim();
             try {
                 AbstractNameQuery nonJtaDataSourceNameQuery = getAbstractNameQuery(nonJtaDataSourceString);
@@ -335,36 +296,33 @@ public class PersistenceUnitBuilder impl
         }
 
         List<String> mappingFileNames = (List<String>) gbeanData.getAttribute("mappingFileNames");
-        String[] mappingFileNameStrings = persistenceUnit.getMappingFileArray();
+        List<String> mappingFileNameStrings = persistenceUnit.getMappingFile();
         for (String mappingFileNameString : mappingFileNameStrings) {
             mappingFileNames.add(mappingFileNameString.trim());
         }
 
-        if (persistenceUnit.isSetExcludeUnlistedClasses()) {
-            gbeanData.setAttribute("excludeUnlistedClasses", persistenceUnit.getExcludeUnlistedClasses());
+        if (persistenceUnit.isExcludeUnlistedClasses()) {
+            gbeanData.setAttribute("excludeUnlistedClasses", persistenceUnit.isExcludeUnlistedClasses());
         }
 
-        String[] managedClassNameStrings = persistenceUnit.getClass1Array();
+        List<String> managedClassNameStrings = persistenceUnit.getClazz();
         List<String> managedClassNames = (List<String>) gbeanData.getAttribute("managedClassNames");
         for (String managedClassNameString : managedClassNameStrings) {
             managedClassNames.add(managedClassNameString.trim());
         }
         List<String> jarFileUrls = (List<String>) gbeanData.getAttribute("jarFileUrls");
         //add the specified locations in the ear
-        String[] jarFileUrlStrings = persistenceUnit.getJarFileArray();
+        List<String> jarFileUrlStrings = persistenceUnit.getJarFile();
         for (String jarFileUrlString : jarFileUrlStrings) {
             jarFileUrls.add(jarFileUrlString.trim());
         }
 
-        if (persistenceUnit.isSetProperties()) {
             Properties properties = (Properties) gbeanData.getAttribute("properties");
-            PersistenceDocument.Persistence.PersistenceUnit.Properties.Property[] propertyObjects = persistenceUnit.getProperties().getPropertyArray();
-            for (PersistenceDocument.Persistence.PersistenceUnit.Properties.Property propertyObject : propertyObjects) {
+            for (Persistence.PersistenceUnit.Properties.Property propertyObject : persistenceUnit.getProperties().getProperty()) {
                 String key = propertyObject.getName().trim();
                 String value = propertyObject.getValue().trim();
                 properties.setProperty(key, value);
             }
-        }
 
     }
 
@@ -384,6 +342,13 @@ public class PersistenceUnitBuilder impl
         return dataSourceNameQuery;
     }
 
+    private Persistence fromXmlObject(XmlObject xmlObject) throws JAXBException {
+        XMLStreamReader reader = xmlObject.newXMLStreamReader();
+        JAXBContext context = JAXBContextFactory.newInstance(Persistence.class);
+        Unmarshaller unmarshaller = context.createUnmarshaller();
+        return (Persistence) unmarshaller.unmarshal(reader);
+    }
+
     public QNameSet getSpecQNameSet() {
         return QNameSet.EMPTY;
     }

Modified: geronimo/server/trunk/plugins/openjpa2/geronimo-persistence-jpa20-builder/src/main/java/org/apache/geronimo/persistence/builder/PersistenceUnitRefBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/openjpa2/geronimo-persistence-jpa20-builder/src/main/java/org/apache/geronimo/persistence/builder/PersistenceUnitRefBuilder.java?rev=957655&r1=957654&r2=957655&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/openjpa2/geronimo-persistence-jpa20-builder/src/main/java/org/apache/geronimo/persistence/builder/PersistenceUnitRefBuilder.java (original)
+++ geronimo/server/trunk/plugins/openjpa2/geronimo-persistence-jpa20-builder/src/main/java/org/apache/geronimo/persistence/builder/PersistenceUnitRefBuilder.java Thu Jun 24 18:06:24 2010
@@ -17,25 +17,22 @@
 package org.apache.geronimo.persistence.builder;
 
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
+import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
-import java.util.LinkedHashSet;
 
 import javax.xml.namespace.QName;
-
 import org.apache.geronimo.common.DeploymentException;
+import org.apache.geronimo.gbean.AbstractName;
 import org.apache.geronimo.gbean.AbstractNameQuery;
-import org.apache.geronimo.gbean.GBeanInfo;
-import org.apache.geronimo.gbean.GBeanInfoBuilder;
 import org.apache.geronimo.gbean.GBeanData;
-import org.apache.geronimo.gbean.AbstractName;
 import org.apache.geronimo.gbean.annotation.GBean;
 import org.apache.geronimo.gbean.annotation.ParamAttribute;
 import org.apache.geronimo.j2ee.deployment.Module;
-import org.apache.geronimo.j2ee.deployment.NamingBuilder;
 import org.apache.geronimo.j2ee.deployment.annotation.PersistenceUnitAnnotationHelper;
 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
 import org.apache.geronimo.kernel.GBeanNotFoundException;
@@ -48,7 +45,8 @@ import org.apache.geronimo.schema.Schema
 import org.apache.geronimo.xbeans.geronimo.naming.GerPatternType;
 import org.apache.geronimo.xbeans.geronimo.naming.GerPersistenceUnitRefDocument;
 import org.apache.geronimo.xbeans.geronimo.naming.GerPersistenceUnitRefType;
-import org.apache.geronimo.xbeans.javaee6.PersistenceUnitRefType;
+import org.apache.openejb.jee.JndiConsumer;
+import org.apache.openejb.jee.PersistenceUnitRef;
 import org.apache.xmlbeans.QNameSet;
 import org.apache.xmlbeans.XmlObject;
 
@@ -74,35 +72,35 @@ public class PersistenceUnitRefBuilder e
         this.strictMatching = strictMatching;
     }
 
-    protected boolean willMergeEnvironment(XmlObject specDD, XmlObject plan) throws DeploymentException {
-        if (specDD != null && specDD.selectChildren(PersistenceUnitRefBuilder.PERSISTENCE_UNIT_REF_QNAME_SET).length > 0) {
+    protected boolean willMergeEnvironment(JndiConsumer specDD, XmlObject plan) throws DeploymentException {
+        if (specDD != null && specDD.getPersistenceUnitRef().size() > 0) {
             return true;
         }
         return plan != null && plan.selectChildren(PersistenceUnitRefBuilder.GER_PERSISTENCE_UNIT_REF_QNAME_SET).length > 0;
     }
 
-    public void buildNaming(XmlObject specDD, XmlObject plan, Module module, Map componentContext) throws DeploymentException {
+    public void buildNaming(JndiConsumer specDD, XmlObject plan, Module module, Map componentContext) throws DeploymentException {
         Configuration localConfiguration = module.getEarContext().getConfiguration();
         // Discover and process any @PersistenceUnitRef annotations (if !metadata-complete)
         if (module.getClassFinder() != null) {
-            processAnnotations(module);
+            processAnnotations(specDD, module);
         }
 
-        List<PersistenceUnitRefType> specPersistenceUnitRefsUntyped = convert(specDD.selectChildren(PersistenceUnitRefBuilder.PERSISTENCE_UNIT_REF_QNAME_SET), JEE_CONVERTER, PersistenceUnitRefType.class, PersistenceUnitRefType.type);
+        Collection<PersistenceUnitRef> specPersistenceUnitRefsUntyped = specDD.getPersistenceUnitRef();
         Map<String, GerPersistenceUnitRefType> gerPersistenceUnitRefsUntyped = getGerPersistenceUnitRefs(plan);
         List<DeploymentException> problems = new ArrayList<DeploymentException>();
-        for (PersistenceUnitRefType persistenceUnitRef : specPersistenceUnitRefsUntyped) {
+        for (PersistenceUnitRef persistenceUnitRef : specPersistenceUnitRefsUntyped) {
             try {
-                String persistenceUnitRefName = persistenceUnitRef.getPersistenceUnitRefName().getStringValue().trim();
+                String persistenceUnitRefName = persistenceUnitRef.getPersistenceUnitRefName().trim();
 
-                addInjections(persistenceUnitRefName, persistenceUnitRef.getInjectionTargetArray(), componentContext);
+                addInjections(persistenceUnitRefName, persistenceUnitRef.getInjectionTarget(), componentContext);
                 AbstractNameQuery persistenceUnitNameQuery;
                 GerPersistenceUnitRefType gerPersistenceUnitRef = gerPersistenceUnitRefsUntyped.remove(persistenceUnitRefName);
                 if (gerPersistenceUnitRef != null) {
                     persistenceUnitNameQuery = findPersistenceUnit(gerPersistenceUnitRef);
                     checkForGBean(localConfiguration, persistenceUnitNameQuery, true);
-                } else if (persistenceUnitRef.isSetPersistenceUnitName() && persistenceUnitRef.getPersistenceUnitName().getStringValue().trim().length() > 0) {
-                    String persistenceUnitName = persistenceUnitRef.getPersistenceUnitName().getStringValue().trim();
+                } else if (persistenceUnitRef.getPersistenceUnitName() != null && !persistenceUnitRef.getPersistenceUnitName().trim().isEmpty()) {
+                    String persistenceUnitName = persistenceUnitRef.getPersistenceUnitName().trim();
                     persistenceUnitNameQuery = new AbstractNameQuery(null, Collections.singletonMap("name", persistenceUnitName), PERSISTENCE_UNIT_INTERFACE_TYPES);
                     if (!checkForGBean(localConfiguration, persistenceUnitNameQuery, strictMatching)) {
                         persistenceUnitName = "persistence/" + persistenceUnitName;
@@ -191,9 +189,9 @@ public class PersistenceUnitRefBuilder e
         }
     }
 
-    private void processAnnotations(Module module) throws DeploymentException {
+    private void processAnnotations(JndiConsumer specDD, Module module) throws DeploymentException {
         // Process all the annotations for this naming builder type
-        PersistenceUnitAnnotationHelper.processAnnotations(module.getAnnotatedApp(), module.getClassFinder());
+        PersistenceUnitAnnotationHelper.processAnnotations(specDD, module.getClassFinder());
     }
 
     private AbstractNameQuery findPersistenceUnit(GerPersistenceUnitRefType gerPersistenceUnitRef) {

Modified: geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7-builder/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7-builder/pom.xml?rev=957655&r1=957654&r2=957655&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7-builder/pom.xml (original)
+++ geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7-builder/pom.xml Thu Jun 24 18:06:24 2010
@@ -47,7 +47,11 @@
             <artifactId>geronimo-web-2.5-builder</artifactId>
             <version>${project.version}</version>
         </dependency>
-
+        <dependency>
+            <groupId>org.apache.openejb</groupId>
+            <artifactId>openejb-jee</artifactId>
+        </dependency>
+   
         <dependency>
             <groupId>org.apache.geronimo.specs</groupId>
             <artifactId>geronimo-jsp_2.2_spec</artifactId>
@@ -111,16 +115,6 @@
                     </systemProperties>
                 </configuration>
             </plugin>
-            <plugin>
-                <groupId>org.apache.felix</groupId>
-                <artifactId>maven-bundle-plugin</artifactId>
-                <configuration>
-                    <instructions>
-                        <Import-Package>org.apache.xmlbeans.impl.schema;version="2.4",*</Import-Package>
-                        <!--<_versionpolicy>[$(version;==;$(@)),$(version;+;$(@)))</_versionpolicy>-->
-                    </instructions>
-                </configuration>
-            </plugin>
 
             <plugin>
                 <groupId>org.codehaus.mojo</groupId>
@@ -182,14 +176,6 @@
                     <instructions>
                         <!--<_versionpolicy>[$(version;==;$(@)),$(version;+;$(@)))</_versionpolicy>-->
                         <Import-Package>
-                            org.apache.geronimo.xbeans.javaee.impl,
-                            org.apache.geronimo.xbeans.javaee,
-                            org.apache.geronimo.xbeans.persistence.impl,
-                            org.apache.geronimo.xbeans.persistence,
-                            org.apache.geronimo.xbeans.j2ee.impl,
-                            org.apache.geronimo.xbeans.j2ee,
-                            org.w3.xml.x1998.namespace.impl,
-                            org.w3.xml.x1998.namespace,
                             org.apache.geronimo.deployment.xbeans.impl,
                             org.apache.geronimo.deployment.javabean.xbeans.impl,
                             org.apache.geronimo.deployment.xbeans,

Modified: geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7-builder/src/main/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7-builder/src/main/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java?rev=957655&r1=957654&r2=957655&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7-builder/src/main/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java (original)
+++ geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7-builder/src/main/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java Thu Jun 24 18:06:24 2010
@@ -19,12 +19,14 @@ package org.apache.geronimo.tomcat.deplo
 
 import java.io.File;
 import java.io.IOException;
+import java.io.InputStream;
 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.List;
 import java.util.Map;
 import java.util.jar.JarFile;
 
@@ -56,7 +58,6 @@ import org.apache.geronimo.j2ee.deployme
 import org.apache.geronimo.j2ee.deployment.NamingBuilder;
 import org.apache.geronimo.j2ee.deployment.WebModule;
 import org.apache.geronimo.j2ee.deployment.WebServiceBuilder;
-import org.apache.geronimo.j2ee.deployment.annotation.AnnotatedWebApp;
 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
 import org.apache.geronimo.kernel.Kernel;
 import org.apache.geronimo.kernel.Naming;
@@ -66,7 +67,6 @@ import org.apache.geronimo.kernel.util.J
 import org.apache.geronimo.naming.deployment.ENCConfigBuilder;
 import org.apache.geronimo.naming.deployment.GBeanResourceEnvironmentBuilder;
 import org.apache.geronimo.naming.deployment.ResourceEnvironmentSetter;
-import org.apache.geronimo.schema.SchemaConversionUtils;
 import org.apache.geronimo.security.deployment.GeronimoSecurityBuilderImpl;
 import org.apache.geronimo.security.jaas.ConfigurationFactory;
 import org.apache.geronimo.tomcat.LifecycleListenerGBean;
@@ -80,7 +80,6 @@ import org.apache.geronimo.web.WebAttrib
 import org.apache.geronimo.web.deployment.GenericToSpecificPlanConverter;
 import org.apache.geronimo.web25.deployment.AbstractWebModuleBuilder;
 import org.apache.geronimo.web25.deployment.security.AuthenticationWrapper;
-import org.apache.geronimo.web25.deployment.utils.WebDeploymentValidationUtils;
 import org.apache.geronimo.xbeans.geronimo.jaspi.JaspiAuthModuleType;
 import org.apache.geronimo.xbeans.geronimo.jaspi.JaspiConfigProviderType;
 import org.apache.geronimo.xbeans.geronimo.jaspi.JaspiServerAuthConfigType;
@@ -89,9 +88,8 @@ import org.apache.geronimo.xbeans.geroni
 import org.apache.geronimo.xbeans.geronimo.web.tomcat.TomcatWebAppDocument;
 import org.apache.geronimo.xbeans.geronimo.web.tomcat.TomcatWebAppType;
 import org.apache.geronimo.xbeans.geronimo.web.tomcat.config.GerTomcatDocument;
-import org.apache.geronimo.xbeans.javaee6.ServletType;
-import org.apache.geronimo.xbeans.javaee6.WebAppDocument;
-import org.apache.geronimo.xbeans.javaee6.WebAppType;
+import org.apache.openejb.jee.JaxbJavaee;
+import org.apache.openejb.jee.WebApp;
 import org.apache.xbean.osgi.bundle.util.BundleUtils;
 import org.apache.xmlbeans.XmlException;
 import org.apache.xmlbeans.XmlObject;
@@ -100,7 +98,6 @@ import org.osgi.framework.BundleContext;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import static java.lang.Boolean.FALSE;
 import static java.lang.Boolean.TRUE;
 
 /**
@@ -170,20 +167,23 @@ public class TomcatModuleBuilder extends
         }
 
         String specDD = null;
-        WebAppType webApp = null;
+        WebApp webApp = null;
 
         URL specDDUrl = BundleUtils.getEntry(bundle, "WEB-INF/web.xml");
         if (specDDUrl == null) {
-            webApp = WebAppType.Factory.newInstance();
+            webApp = new WebApp();
         } else {
             try {
                 specDD = JarUtils.readAll(specDDUrl);
-                XmlObject parsed = XmlBeansUtil.parse(specDD);
-                WebAppDocument webAppDoc = SchemaConversionUtils.convertToServletSchema(parsed);
-                webApp = webAppDoc.getWebApp();
-                WebDeploymentValidationUtils.validateWebApp(webApp);
-            } catch (XmlException e) {
-                throw new DeploymentException("Error parsing web.xml for " + bundle.getSymbolicName(), e);
+//                XmlObject parsed = XmlBeansUtil.parse(specDD);
+//                WebAppDocument webAppDoc = SchemaConversionUtils.convertToServletSchema(parsed);
+                InputStream in = specDDUrl.openStream();
+                try {
+                    webApp = (WebApp) JaxbJavaee.unmarshal(WebApp.class, in);
+                } finally {
+                    in.close();
+                }
+//                WebDeploymentValidationUtils.validateWebApp(webApp);
             } catch (Exception e) {
                 throw new DeploymentException("Error reading web.xml for " + bundle.getSymbolicName(), e);
             }
@@ -200,7 +200,7 @@ public class TomcatModuleBuilder extends
         EnvironmentType environmentType = tomcatWebApp.getEnvironment();
         Environment environment = EnvironmentBuilder.buildEnvironment(environmentType, defaultEnvironment);
 
-        if (webApp.getDistributableArray().length == 1) {
+        if (webApp.getDistributable().size() == 1) {
             clusteringBuilders.buildEnvironment(tomcatWebApp, environment);
         }
 
@@ -214,15 +214,12 @@ public class TomcatModuleBuilder extends
             moduleName = naming.createChildName(earName, targetPath, NameFactory.WEB_MODULE);
         }
 
-        // Create the AnnotatedApp interface for the WebModule
-        AnnotatedWebApp annotatedWebApp = new AnnotatedWebApp(webApp);
-
-        String name = getModuleName(webApp);
+        String name = webApp.getModuleName();
         if (name == null) {
             name = bundle.getSymbolicName();
         }
 
-        WebModule module = new WebModule(standAlone, moduleName, name, environment, deployable, targetPath, webApp, tomcatWebApp, specDD, contextPath, TOMCAT_NAMESPACE, annotatedWebApp, shareJndi(null), null);
+        WebModule module = new WebModule(standAlone, moduleName, name, environment, deployable, targetPath, webApp, tomcatWebApp, specDD, contextPath, TOMCAT_NAMESPACE, shareJndi(null), null);
         for (ModuleBuilderExtension mbe : moduleBuilderExtensions) {
             mbe.createModule(module, bundle, naming, idBuilder);
         }
@@ -236,37 +233,32 @@ public class TomcatModuleBuilder extends
 
         // parse the spec dd
         String specDD = null;
-        WebAppType webApp = null;
+        WebApp webApp = null;
         try {
             if (specDDUrl == null) {
                 specDDUrl = JarUtils.createJarURL(moduleFile, "WEB-INF/web.xml");
             }
-
-            // read in the entire specDD as a string, we need this for getDeploymentDescriptor
-            // on the J2ee management object
-            specDD = JarUtils.readAll(specDDUrl);
-
-            // we found web.xml, if it won't parse that's an error.
-            XmlObject parsed = XmlBeansUtil.parse(specDD);
-
-            WebAppDocument webAppDoc = SchemaConversionUtils.convertToServletSchema(parsed);
-            webApp = webAppDoc.getWebApp();
-            WebDeploymentValidationUtils.validateWebApp(webApp);
-        } catch (XmlException e) {
-            // Output the target path in the error to make it clearer to the user which webapp
-            // has the problem.  The targetPath is used, as moduleFile may have an unhelpful
-            // value such as C:\geronimo-1.1\var\temp\geronimo-deploymentUtil22826.tmpdir
-            throw new DeploymentException("Error parsing web.xml for " + targetPath, e);
-        } catch (Exception e) {
-            if (!moduleFile.getName().endsWith(".war")) {
-                //not for us
-                return null;
+            if (specDDUrl == null) {
+                if (!moduleFile.getName().endsWith(".war")) {
+                    //not for us
+                    return null;
+                }
+                webApp = new WebApp();
+            } else {
+                // read in the entire specDD as a string, we need this for getDeploymentDescriptor
+                // on the J2ee management object
+                specDD = JarUtils.readAll(specDDUrl);
+                InputStream in = specDDUrl.openStream();
+                try {
+                    webApp = (WebApp) JaxbJavaee.unmarshal(WebApp.class, in);
+                } finally {
+                    in.close();
+                }
             }
-            //else ignore as jee5 allows optional spec dd for .war's
-        }
 
-        if (webApp == null) {
-            webApp = WebAppType.Factory.newInstance();
+//            WebDeploymentValidationUtils.validateWebApp(webApp);
+        } catch (Exception e) {
+            throw new DeploymentException("Error parsing web.xml for " + targetPath, e);
         }
 
         Deployable deployable = new DeployableJarFile(moduleFile);
@@ -278,7 +270,7 @@ public class TomcatModuleBuilder extends
         EnvironmentType environmentType = tomcatWebApp.getEnvironment();
         Environment environment = EnvironmentBuilder.buildEnvironment(environmentType, defaultEnvironment);
 
-        if (webApp.getDistributableArray().length == 1) {
+        if (webApp.getDistributable().size() == 1) {
             clusteringBuilders.buildEnvironment(tomcatWebApp, environment);
         }
 
@@ -304,10 +296,7 @@ public class TomcatModuleBuilder extends
             moduleName = naming.createChildName(earName, targetPath, NameFactory.WEB_MODULE);
         }
 
-        // Create the AnnotatedApp interface for the WebModule
-        AnnotatedWebApp annotatedWebApp = new AnnotatedWebApp(webApp);
-
-        String name = getModuleName(webApp);
+        String name = webApp.getModuleName();
         if (name == null) {
             if (standAlone) {
                 name = FileUtils.removeExtension(new File(moduleFile.getName()).getName(), ".war");
@@ -316,14 +305,14 @@ public class TomcatModuleBuilder extends
             }
         }
 
-        WebModule module = new WebModule(standAlone, moduleName, name, environment, deployable, targetPath, webApp, tomcatWebApp, specDD, contextRoot, TOMCAT_NAMESPACE, annotatedWebApp, shareJndi(parentModule), parentModule);
+        WebModule module = new WebModule(standAlone, moduleName, name, environment, deployable, targetPath, webApp, tomcatWebApp, specDD, contextRoot, TOMCAT_NAMESPACE, shareJndi(parentModule), parentModule);
         for (ModuleBuilderExtension mbe : moduleBuilderExtensions) {
             mbe.createModule(module, plan, moduleFile, targetPath, specDDUrl, environment, contextRoot, earName, naming, idBuilder);
         }
         return module;
     }
 
-    private String getContextRoot(TomcatWebAppType tomcatWebApp, String contextRoot, WebAppType webApp, boolean standAlone, JarFile moduleFile, String targetPath) {
+    private String getContextRoot(TomcatWebAppType tomcatWebApp, String contextRoot, WebApp webApp, boolean standAlone, JarFile moduleFile, String targetPath) {
         //If we have a context root, override everything
         if (tomcatWebApp.isSetContextRoot()) {
             contextRoot = tomcatWebApp.getContextRoot();
@@ -344,7 +333,7 @@ public class TomcatModuleBuilder extends
     }
 
 
-    TomcatWebAppType getTomcatWebApp(Object plan, Deployable deployable, boolean standAlone, String targetPath, WebAppType webApp) throws DeploymentException {
+    TomcatWebAppType getTomcatWebApp(Object plan, Deployable deployable, boolean standAlone, String targetPath, WebApp webApp) throws DeploymentException {
         XmlObject rawPlan = null;
         try {
             // load the geronimo-web.xml from either the supplied plan or from the earFile
@@ -409,7 +398,7 @@ public class TomcatModuleBuilder extends
         AbstractName moduleName = module.getModuleName();
         WebModule webModule = (WebModule) module;
 
-        WebAppType webApp = (WebAppType) webModule.getSpecDD();
+        WebApp webApp = webModule.getSpecDD();
 
         TomcatWebAppType tomcatWebApp = (TomcatWebAppType) webModule.getVendorDD();
 
@@ -425,7 +414,7 @@ public class TomcatModuleBuilder extends
             // unsharableResources, applicationManagedSecurityResources
             GBeanResourceEnvironmentBuilder rebuilder = new GBeanResourceEnvironmentBuilder(webModuleData);
             //N.B. use earContext not moduleContext
-            resourceEnvironmentSetter.setResourceEnvironment(rebuilder, webApp.getResourceRefArray(), tomcatWebApp.getResourceRefArray());
+            resourceEnvironmentSetter.setResourceEnvironment(rebuilder, webApp.getResourceRef(), tomcatWebApp.getResourceRefArray());
 
             if (tomcatWebApp.isSetWebContainer()) {
                 AbstractNameQuery webContainerName = ENCConfigBuilder.getGBeanQuery(GBeanInfoBuilder.DEFAULT_J2EE_TYPE, tomcatWebApp.getWebContainer());
@@ -435,8 +424,8 @@ public class TomcatModuleBuilder extends
             }
 
             //get Tomcat display-name
-            if (webApp.getDisplayNameArray().length > 0) {
-                webModuleData.setAttribute("displayName", webApp.getDisplayNameArray()[0].getStringValue());
+            if (webApp.getDisplayNames().length > 0) {
+                webModuleData.setAttribute("displayName", webApp.getDisplayName());
             }
 
             // Process the Tomcat container-config elements
@@ -483,7 +472,7 @@ public class TomcatModuleBuilder extends
                 webModuleData.setReferencePattern(TomcatWebAppContext.GBEAN_REF_MANAGER_RETRIEVER, managerName);
             }
 
-            Boolean distributable = webApp.getDistributableArray().length == 1 ? TRUE : FALSE;
+            Boolean distributable = !webApp.getDistributable().isEmpty();
             if (TRUE == distributable) {
                 clusteringBuilders.build(tomcatWebApp, earContext, moduleContext);
                 if (null == webModuleData.getReferencePatterns(TomcatWebAppContext.GBEAN_REF_CLUSTERED_VALVE_RETRIEVER)) {
@@ -495,7 +484,7 @@ public class TomcatModuleBuilder extends
             webModuleData.setAttribute("listenerClassNames", listeners);
 
             //Handle the role permissions and webservices on the servlets.
-            ServletType[] servletTypes = webApp.getServletArray();
+            List<org.apache.openejb.jee.Servlet> servletTypes = webApp.getServlet();
             Map<String, AbstractName> webServices = new HashMap<String, AbstractName>();
             Class baseServletClass;
             try {
@@ -503,11 +492,11 @@ public class TomcatModuleBuilder extends
             } catch (ClassNotFoundException e) {
                 throw new DeploymentException("Could not load javax.servlet.Servlet in bundle " + bundle, e);
             }
-            for (ServletType servletType : servletTypes) {
+            for (org.apache.openejb.jee.Servlet servletType : servletTypes) {
 
-                if (servletType.isSetServletClass()) {
-                    String servletName = servletType.getServletName().getStringValue().trim();
-                    String servletClassName = servletType.getServletClass().getStringValue().trim();
+                if (servletType.getServletClass() != null) {
+                    String servletName = servletType.getServletName().trim();
+                    String servletClassName = servletType.getServletClass().trim();
                     Class servletClass;
                     try {
                         servletClass = webBundle.loadClass(servletClassName);
@@ -579,7 +568,7 @@ public class TomcatModuleBuilder extends
 
             //Save Deployment Attributes
             Map<String, Object> deploymentAttributes = new HashMap<String, Object>();
-            deploymentAttributes.put(WebAttributeName.META_COMPLETE.name(), webApp.getMetadataComplete());
+            deploymentAttributes.put(WebAttributeName.META_COMPLETE.name(), webApp.isMetadataComplete());
             deploymentAttributes.put(WebAttributeName.SCHEMA_VERSION.name(), INITIAL_WEB_XML_SCHEMA_VERSION.get(earContext.getGeneralData()));
             deploymentAttributes.put(WebAttributeName.ORDERED_LIBS.name(), AbstractWebModuleBuilder.ORDERED_LIBS.get(earContext.getGeneralData()));
             deploymentAttributes.put(WebAttributeName.SERVLET_CONTAINER_INITIALIZERS.name(), AbstractWebModuleBuilder.SERVLET_CONTAINER_INITIALIZERS.get(earContext.getGeneralData()));
@@ -594,7 +583,7 @@ public class TomcatModuleBuilder extends
                 webModuleData.setReferencePattern("applicationPolicyConfigurationManager", EARContext.JACC_MANAGER_NAME_KEY.get(earContext.getGeneralData()));
             }
             //not truly metadata complete until MBEs have run
-            if (!webApp.getMetadataComplete()) {
+            if (!webApp.isMetadataComplete()) {
                 webApp.setMetadataComplete(true);
                 if (INITIAL_WEB_XML_SCHEMA_VERSION.get(earContext.getGeneralData()) >= 2.5f) {
                     String specDeploymentPlan = getSpecDDAsString(webModule);

Modified: geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7-builder/src/main/xsd/geronimo-tomcat-2.0.1.xsd
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7-builder/src/main/xsd/geronimo-tomcat-2.0.1.xsd?rev=957655&r1=957654&r2=957655&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7-builder/src/main/xsd/geronimo-tomcat-2.0.1.xsd (original)
+++ geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7-builder/src/main/xsd/geronimo-tomcat-2.0.1.xsd Thu Jun 24 18:06:24 2010
@@ -24,9 +24,9 @@
     xmlns:app="http://geronimo.apache.org/xml/ns/j2ee/application-2.0"
     xmlns:sys="http://geronimo.apache.org/xml/ns/deployment-1.2"
     xmlns:jaspi="http://geronimo.apache.org/xml/ns/geronimo-jaspi"
-    xmlns:ee="http://java.sun.com/xml/ns/persistence"
     xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"
     attributeFormDefault="unqualified" version="1.1">
+    <!--xmlns:ee="http://java.sun.com/xml/ns/persistence"-->
 
     <xs:annotation>
         <xs:documentation>
@@ -78,7 +78,7 @@
         </xs:annotation>
     </xs:import>
 
-    <xs:import namespace="http://java.sun.com/xml/ns/persistence" schemaLocation="http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"/>
+    <!--<xs:import namespace="http://java.sun.com/xml/ns/persistence" schemaLocation="http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"/>-->
     <xs:import namespace="http://geronimo.apache.org/xml/ns/geronimo-jaspi" schemaLocation="geronimo-jaspi.xsd"/>
   
     <xs:element name="web-app" type="tomcat:web-appType">
@@ -269,7 +269,7 @@
             </xs:sequence>
 
             <xs:choice minOccurs="0" maxOccurs="unbounded">
-                <xs:element ref="sys:service" minOccurs="0" maxOccurs="unbounded">
+                <xs:element ref="sys:service">
                     <xs:annotation>
                         <xs:documentation>
                             Reference to abstract service element defined in imported
@@ -277,7 +277,8 @@
                         </xs:documentation>
                     </xs:annotation>
                 </xs:element>
-                <xs:element ref="ee:persistence"/>
+                <!--<xs:element ref="ee:persistence"/>-->
+                <xs:any namespace="http://java.sun.com/xml/ns/persistence"/>
             </xs:choice>
         </xs:sequence>
     </xs:complexType>

Modified: geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7-builder/src/test/java/org/apache/geronimo/tomcat/deployment/MockResourceEnvironmentSetter.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7-builder/src/test/java/org/apache/geronimo/tomcat/deployment/MockResourceEnvironmentSetter.java?rev=957655&r1=957654&r2=957655&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7-builder/src/test/java/org/apache/geronimo/tomcat/deployment/MockResourceEnvironmentSetter.java (original)
+++ geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7-builder/src/test/java/org/apache/geronimo/tomcat/deployment/MockResourceEnvironmentSetter.java Thu Jun 24 18:06:24 2010
@@ -16,15 +16,17 @@
  */
 package org.apache.geronimo.tomcat.deployment;
 
-import org.apache.geronimo.naming.deployment.ResourceEnvironmentSetter;
+import java.util.Collection;
+
 import org.apache.geronimo.naming.deployment.ResourceEnvironmentBuilder;
+import org.apache.geronimo.naming.deployment.ResourceEnvironmentSetter;
 import org.apache.geronimo.xbeans.geronimo.naming.GerResourceRefType;
-import org.apache.xmlbeans.XmlObject;
+import org.apache.openejb.jee.ResourceRef;
 
 /**
  * @version $Rev$ $Date$
  */
 public class MockResourceEnvironmentSetter implements ResourceEnvironmentSetter {
-    public void setResourceEnvironment(ResourceEnvironmentBuilder builder, XmlObject[] resourceRefs, GerResourceRefType[] gerResourceRefs) {
+    public void setResourceEnvironment(ResourceEnvironmentBuilder builder, Collection<ResourceRef> resourceRefs, GerResourceRefType[] gerResourceRefs) {
     }
 }



Mime
View raw message