geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r292930 - in /geronimo/branches/1.0-M5/modules: jetty-builder/src/java/org/apache/geronimo/jetty/deployment/ jetty-builder/src/test/org/apache/geronimo/jetty/deployment/ tomcat-builder/src/java/org/apache/geronimo/tomcat/deployment/ web-bui...
Date Sat, 01 Oct 2005 06:29:28 GMT
Author: djencks
Date: Fri Sep 30 23:29:22 2005
New Revision: 292930

URL: http://svn.apache.org/viewcvs?rev=292930&view=rev
Log:
Fix problems with ear deployment including web apps

Modified:
    geronimo/branches/1.0-M5/modules/jetty-builder/src/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java
    geronimo/branches/1.0-M5/modules/jetty-builder/src/test/org/apache/geronimo/jetty/deployment/PlanParsingTest.java
    geronimo/branches/1.0-M5/modules/tomcat-builder/src/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java
    geronimo/branches/1.0-M5/modules/web-builder/src/java/org/apache/geronimo/web/deployment/GenericToSpecificPlanConverter.java

Modified: geronimo/branches/1.0-M5/modules/jetty-builder/src/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.0-M5/modules/jetty-builder/src/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java?rev=292930&r1=292929&r2=292930&view=diff
==============================================================================
--- geronimo/branches/1.0-M5/modules/jetty-builder/src/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java
(original)
+++ geronimo/branches/1.0-M5/modules/jetty-builder/src/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java
Fri Sep 30 23:29:22 2005
@@ -291,7 +291,7 @@
             // load the geronimo-web.xml from either the supplied plan or from the earFile
             try {
                 if (plan instanceof XmlObject) {
-                    rawPlan = (XmlObject) plan;//SchemaConversionUtils.getNestedObject((XmlObject)
plan, "web-app");
+                    rawPlan = (XmlObject) plan;
                 } else {
                     if (plan != null) {
                         rawPlan = XmlBeansUtil.parse(((File) plan).toURL());
@@ -315,16 +315,10 @@
 
             JettyWebAppType jettyWebApp = null;
             if (rawPlan != null) {
-                XmlCursor cursor = rawPlan.newCursor();
-                try {
-                    new GenericToSpecificPlanConverter(GerJettyDocument.type.getDocumentElementName().getNamespaceURI(),
-                            JettyWebAppDocument.type.getDocumentElementName().getNamespaceURI()).convertToSpecificPlan(cursor);
-                    SchemaConversionUtils.findNestedElement(cursor, "web-app");
-                    jettyWebApp = (JettyWebAppType) cursor.getObject().copy().changeType(JettyWebAppType.type);
-                    SchemaConversionUtils.validateDD(jettyWebApp);
-                } finally {
-                    cursor.dispose();
-                }
+                XmlObject webPlan = new GenericToSpecificPlanConverter(GerJettyDocument.type.getDocumentElementName().getNamespaceURI(),
+                        JettyWebAppDocument.type.getDocumentElementName().getNamespaceURI(),
"jetty").convertToSpecificPlan(rawPlan);
+                jettyWebApp = (JettyWebAppType) webPlan.changeType(JettyWebAppType.type);
+                SchemaConversionUtils.validateDD(jettyWebApp);
             } else {
                 String defaultContextRoot = determineDefaultContextRoot(webApp, standAlone,
moduleFile, targetPath);
                 jettyWebApp = createDefaultPlan(defaultContextRoot);

Modified: geronimo/branches/1.0-M5/modules/jetty-builder/src/test/org/apache/geronimo/jetty/deployment/PlanParsingTest.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.0-M5/modules/jetty-builder/src/test/org/apache/geronimo/jetty/deployment/PlanParsingTest.java?rev=292930&r1=292929&r2=292930&view=diff
==============================================================================
--- geronimo/branches/1.0-M5/modules/jetty-builder/src/test/org/apache/geronimo/jetty/deployment/PlanParsingTest.java
(original)
+++ geronimo/branches/1.0-M5/modules/jetty-builder/src/test/org/apache/geronimo/jetty/deployment/PlanParsingTest.java
Fri Sep 30 23:29:22 2005
@@ -2,9 +2,9 @@
 
 import java.io.File;
 import java.net.URI;
+import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.List;
-import java.util.ArrayList;
 import java.util.jar.JarFile;
 import javax.management.ObjectName;
 
@@ -14,17 +14,15 @@
 import org.apache.geronimo.j2ee.deployment.WebServiceBuilder;
 import org.apache.geronimo.kernel.jmx.JMXUtil;
 import org.apache.geronimo.schema.SchemaConversionUtils;
+import org.apache.geronimo.web.deployment.GenericToSpecificPlanConverter;
 import org.apache.geronimo.xbeans.geronimo.naming.GerResourceRefType;
-import org.apache.geronimo.xbeans.geronimo.web.GerWebAppDocument;
-import org.apache.geronimo.xbeans.geronimo.web.GerWebAppType;
-import org.apache.geronimo.xbeans.geronimo.web.jetty.config.GerJettyDocument;
 import org.apache.geronimo.xbeans.geronimo.web.jetty.JettyWebAppDocument;
 import org.apache.geronimo.xbeans.geronimo.web.jetty.JettyWebAppType;
+import org.apache.geronimo.xbeans.geronimo.web.jetty.config.GerJettyDocument;
 import org.apache.geronimo.xbeans.j2ee.WebAppDocument;
 import org.apache.geronimo.xbeans.j2ee.WebAppType;
-import org.apache.geronimo.web.deployment.GenericToSpecificPlanConverter;
-import org.apache.xmlbeans.XmlObject;
 import org.apache.xmlbeans.XmlCursor;
+import org.apache.xmlbeans.XmlObject;
 
 /**
  */
@@ -128,6 +126,12 @@
 
     }
 
+    /** This test has 2 purposes: one the obvious one explicitly tested,
+     * the other that passing a JettyWebAppType XmlObject in works.  This latter
+     * models a web-app element inside an ear plan.
+     *
+     * @throws Exception
+     */
     public void testContextRootWithPlanAndContextSet() throws Exception {
 
         JettyWebAppDocument jettyWebAppDoc = JettyWebAppDocument.Factory.newInstance();
@@ -182,21 +186,17 @@
     public void testConvertToJettySchema() throws Exception {
         File resourcePlan = new File(basedir, "src/test-resources/plans/plan4.xml");
         assertTrue(resourcePlan.exists());
-        XmlObject plan = XmlBeansUtil.parse(resourcePlan.toURL());
-        XmlCursor cursor = plan.newCursor();
-        try {
-        new GenericToSpecificPlanConverter(GerJettyDocument.type.getDocumentElementName().getNamespaceURI(),
-                JettyWebAppDocument.type.getDocumentElementName().getNamespaceURI()).convertToSpecificPlan(cursor);
-        } finally {
-            cursor.dispose();
-        }
+        XmlObject rawPlan = XmlBeansUtil.parse(resourcePlan.toURL());
+        XmlObject webPlan = new GenericToSpecificPlanConverter(GerJettyDocument.type.getDocumentElementName().getNamespaceURI(),
+                JettyWebAppDocument.type.getDocumentElementName().getNamespaceURI(), "jetty").convertToSpecificPlan(rawPlan);
         File ConvertedPlan = new File(basedir, "src/test-resources/plans/plan4-converted.xml");
         assertTrue(ConvertedPlan.exists());
         XmlObject converted = XmlBeansUtil.parse(ConvertedPlan.toURL());
         XmlCursor c = converted.newCursor();
         SchemaConversionUtils.findNestedElement(c, "web-app");
+        c.toFirstChild();
         ArrayList problems = new ArrayList();
-        compareXmlObjects(plan, c, problems);
+        compareXmlObjects(webPlan, c, problems);
         assertEquals("problems: " + problems, 0, problems.size());
     }
 

Modified: geronimo/branches/1.0-M5/modules/tomcat-builder/src/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.0-M5/modules/tomcat-builder/src/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java?rev=292930&r1=292929&r2=292930&view=diff
==============================================================================
--- geronimo/branches/1.0-M5/modules/tomcat-builder/src/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java
(original)
+++ geronimo/branches/1.0-M5/modules/tomcat-builder/src/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java
Fri Sep 30 23:29:22 2005
@@ -129,7 +129,7 @@
                                ObjectName tomcatContainerObjectName,
                                WebServiceBuilder webServiceBuilder,
                                Repository repository) {
-        this.defaultParentId = defaultParentId == null? Collections.EMPTY_LIST: Arrays.asList(defaultParentId);
+        this.defaultParentId = defaultParentId == null ? Collections.EMPTY_LIST : Arrays.asList(defaultParentId);
 
         this.defaultContextPriorityClassloader = defaultContextPriorityClassloader;
         this.tomcatContainerObjectName = tomcatContainerObjectName;
@@ -243,7 +243,7 @@
             // load the geronimo-web.xml from either the supplied plan or from the earFile
             try {
                 if (plan instanceof XmlObject) {
-                    rawPlan = (XmlObject) plan;//SchemaConversionUtils.getNestedObject((XmlObject)
plan, "web-app");
+                    rawPlan = (XmlObject) plan;
                 } else {
                     if (plan != null) {
                         rawPlan = XmlBeansUtil.parse(((File) plan).toURL());
@@ -267,16 +267,10 @@
 
             TomcatWebAppType tomcatWebApp = null;
             if (rawPlan != null) {
-                XmlCursor cursor = rawPlan.newCursor();
-                try {
-                    new GenericToSpecificPlanConverter(GerTomcatDocument.type.getDocumentElementName().getNamespaceURI(),
-                            TomcatWebAppDocument.type.getDocumentElementName().getNamespaceURI()).convertToSpecificPlan(cursor);
-                    SchemaConversionUtils.findNestedElement(cursor, "web-app");
-                    tomcatWebApp = (TomcatWebAppType) cursor.getObject().copy().changeType(TomcatWebAppType.type);
-                    SchemaConversionUtils.validateDD(tomcatWebApp);
-                } finally {
-                    cursor.dispose();
-                }
+                XmlObject webPlan = new GenericToSpecificPlanConverter(GerTomcatDocument.type.getDocumentElementName().getNamespaceURI(),
+                        TomcatWebAppDocument.type.getDocumentElementName().getNamespaceURI(),
"tomcat").convertToSpecificPlan(rawPlan);
+                tomcatWebApp = (TomcatWebAppType) webPlan.changeType(TomcatWebAppType.type);
+                SchemaConversionUtils.validateDD(tomcatWebApp);
             } else {
                 String defaultContextRoot = determineDefaultContextRoot(webApp, standAlone,
moduleFile, targetPath);
                 tomcatWebApp = createDefaultPlan(defaultContextRoot);
@@ -430,23 +424,23 @@
             webModuleData.setReferencePattern("Container", tomcatContainerObjectName);
 
             // Process the Tomcat container-config elements
-                    if (tomcatWebApp.isSetHost()) {
-                        String virtualServer = tomcatWebApp.getHost().trim();
-                        webModuleData.setAttribute("virtualServer", virtualServer);
-                    }
-                    if (tomcatWebApp.isSetCrossContext()) {
-                        webModuleData.setAttribute("crossContext", Boolean.TRUE);
-                    }
-                    if (tomcatWebApp.isSetTomcatRealm()) {
-                        String tomcatRealm = tomcatWebApp.getTomcatRealm().trim();
-                        ObjectName realmName = NameFactory.getComponentName(null, null, null,
null, tomcatRealm, RealmGBean.GBEAN_INFO.getJ2eeType(), moduleJ2eeContext);
-                        webModuleData.setReferencePattern("TomcatRealm", realmName);
-                    }
-                    if (tomcatWebApp.isSetValveChain()) {
-                        String valveChain = tomcatWebApp.getValveChain().trim();
-                        ObjectName valveName = NameFactory.getComponentName(null, null, null,
null, valveChain, ValveGBean.J2EE_TYPE, moduleJ2eeContext);
-                        webModuleData.setReferencePattern("TomcatValveChain", valveName);
-                    }
+            if (tomcatWebApp.isSetHost()) {
+                String virtualServer = tomcatWebApp.getHost().trim();
+                webModuleData.setAttribute("virtualServer", virtualServer);
+            }
+            if (tomcatWebApp.isSetCrossContext()) {
+                webModuleData.setAttribute("crossContext", Boolean.TRUE);
+            }
+            if (tomcatWebApp.isSetTomcatRealm()) {
+                String tomcatRealm = tomcatWebApp.getTomcatRealm().trim();
+                ObjectName realmName = NameFactory.getComponentName(null, null, null, null,
tomcatRealm, RealmGBean.GBEAN_INFO.getJ2eeType(), moduleJ2eeContext);
+                webModuleData.setReferencePattern("TomcatRealm", realmName);
+            }
+            if (tomcatWebApp.isSetValveChain()) {
+                String valveChain = tomcatWebApp.getValveChain().trim();
+                ObjectName valveName = NameFactory.getComponentName(null, null, null, null,
valveChain, ValveGBean.J2EE_TYPE, moduleJ2eeContext);
+                webModuleData.setReferencePattern("TomcatValveChain", valveName);
+            }
 
 
             Map portMap = webModule.getPortMap();
@@ -513,7 +507,7 @@
                 }
                 DefaultPrincipal defaultPrincipal = earContext.getSecurityConfiguration().getDefaultPrincipal();
                 securityHolder.setDefaultPrincipal(defaultPrincipal);
-                if (defaultPrincipal != null){
+                if (defaultPrincipal != null) {
                     securityHolder.setSecurity(true);
                 }
 

Modified: geronimo/branches/1.0-M5/modules/web-builder/src/java/org/apache/geronimo/web/deployment/GenericToSpecificPlanConverter.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.0-M5/modules/web-builder/src/java/org/apache/geronimo/web/deployment/GenericToSpecificPlanConverter.java?rev=292930&r1=292929&r2=292930&view=diff
==============================================================================
--- geronimo/branches/1.0-M5/modules/web-builder/src/java/org/apache/geronimo/web/deployment/GenericToSpecificPlanConverter.java
(original)
+++ geronimo/branches/1.0-M5/modules/web-builder/src/java/org/apache/geronimo/web/deployment/GenericToSpecificPlanConverter.java
Fri Sep 30 23:29:22 2005
@@ -24,6 +24,7 @@
 import org.apache.geronimo.xbeans.geronimo.security.GerSecurityDocument;
 import org.apache.geronimo.xbeans.geronimo.web.GerWebAppDocument;
 import org.apache.xmlbeans.XmlCursor;
+import org.apache.xmlbeans.XmlObject;
 
 /**
  * @version $Rev:  $ $Date:  $
@@ -37,23 +38,29 @@
     private static final QName SECURITY_QNAME = GerSecurityDocument.type.getDocumentElementName();
     private final String configNamespace;
     private final String namespace;
+    private final String element;
 
-    public GenericToSpecificPlanConverter(String configNamespace, String namespace) {
+    public GenericToSpecificPlanConverter(String configNamespace, String namespace, String
element) {
         this.configNamespace = configNamespace;
         this.namespace = namespace;
+        this.element = element;
     }
 
-    public void convertToSpecificPlan(XmlCursor cursor) throws DeploymentException {
-        if (SchemaConversionUtils.findNestedElement(cursor, "web-app")) {
-            cursor.push();
-            if (cursor.getName().equals(GENERIC_QNAME)) {
+    public XmlObject convertToSpecificPlan(XmlObject plan) throws DeploymentException {
+        XmlCursor rawCursor = plan.newCursor();
+        try {
+            if (SchemaConversionUtils.findNestedElement(rawCursor, "web-app")) {
+                XmlObject webPlan = rawCursor.getObject().copy();
+
+                XmlCursor cursor = webPlan.newCursor();
+                cursor.push();
                 if (cursor.toChild(GENERIC_CONFIG_QNAME)) {
                     XmlCursor source = cursor.newCursor();
                     cursor.push();
                     cursor.toEndToken();
                     cursor.toNextToken();
                     try {
-                        if (source.toChild(configNamespace, "jetty")) {
+                        if (source.toChild(configNamespace, element)) {
                             source.copyXmlContents(cursor);
                         }
 
@@ -63,7 +70,8 @@
                     cursor.pop();
                     cursor.removeXml();
                 }
-                cursor.toStartDoc();
+                cursor.pop();
+                cursor.push();
                 while (cursor.hasNextToken()) {
                     if (cursor.isStart()) {
                         if (namespace.equals(cursor.getName().getNamespaceURI())) {
@@ -76,35 +84,38 @@
                         cursor.toNextToken();
                     }
                 }
-            }
-            //move security elements after refs
-            SchemaConversionUtils.convertToGeronimoSubSchemas(cursor);
+                SchemaConversionUtils.convertToGeronimoSubSchemas(cursor);
+                //move security elements after refs
 
-            cursor.pop();
-            cursor.push();
-            if (cursor.toChild(namespace, "security-realm-name")) {
-                XmlCursor other = cursor.newCursor();
-                try {
-                    other.toParent();
-                    if (other.toChild(SYSTEM_NAMESPACE, "gbean")) {
-                        other.toPrevToken();
-                    } else {
-                        other.toEndToken();
-                        other.toPrevToken();
-                    }
-                    cursor.moveXml(other);
-                    cursor.pop();
-                    cursor.push();
-                    if (cursor.toChild(SECURITY_QNAME)) {
+                cursor.pop();
+                cursor.push();
+                if (cursor.toChild(namespace, "security-realm-name")) {
+                    XmlCursor other = cursor.newCursor();
+                    try {
+                        other.toParent();
+                        if (other.toChild(SYSTEM_NAMESPACE, "gbean")) {
+                            other.toPrevToken();
+                        } else {
+                            other.toEndToken();
+                            other.toPrevToken();
+                        }
                         cursor.moveXml(other);
+                        cursor.pop();
+                        cursor.push();
+                        if (cursor.toChild(SECURITY_QNAME)) {
+                            cursor.moveXml(other);
+                        }
+                    } finally {
+                        other.dispose();
                     }
-                } finally {
-                    other.dispose();
                 }
+                cursor.pop();
+                return webPlan;
+            } else {
+                throw new DeploymentException("No web-app element");
             }
-            cursor.pop();
-        } else {
-            throw new DeploymentException("No web-app element");
+        } finally {
+            rawCursor.dispose();
         }
     }
 



Mime
View raw message