geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: rev 47413 - in geronimo/trunk/modules: client-builder/src/java/org/apache/geronimo/client/builder client-builder/src/test/org/apache/geronimo/client/builder connector/src/java/org/apache/geronimo/connector/deployment connector/src/test/org/apache/geronimo/connector/deployment deployment/src/java/org/apache/geronimo/deployment deployment/src/java/org/apache/geronimo/deployment/plugin deployment/src/java/org/apache/geronimo/deployment/plugin/local deployment/src/java/org/apache/geronimo/deployment/service j2ee/src/java/org/apache/geronimo/j2ee/deployment j2ee/src/test/org/apache/geronimo/j2ee/deployment jetty/src/java/org/apache/geronimo/jetty/deployment jetty/src/test/org/apache/geronimo/jetty/deployment
Date Tue, 28 Sep 2004 18:46:40 GMT
Author: dain
Date: Tue Sep 28 11:46:39 2004
New Revision: 47413

Modified:
   geronimo/trunk/modules/client-builder/src/java/org/apache/geronimo/client/builder/AppClientModuleBuilder.java
   geronimo/trunk/modules/client-builder/src/test/org/apache/geronimo/client/builder/PlanParsingTest.java
   geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/deployment/ConnectorModuleBuilder.java
   geronimo/trunk/modules/connector/src/test/org/apache/geronimo/connector/deployment/RAR_1_0ConfigBuilderTest.java
   geronimo/trunk/modules/connector/src/test/org/apache/geronimo/connector/deployment/RAR_1_5ConfigBuilderTest.java
   geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/ConfigurationBuilder.java
   geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/Deployer.java
   geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/plugin/TargetModuleIDImpl.java
   geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/plugin/local/DistributeCommand.java
   geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/service/ServiceConfigBuilder.java
   geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment/AppClientModule.java
   geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment/ConnectorModule.java
   geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilder.java
   geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment/EJBModule.java
   geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment/Module.java
   geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment/ModuleBuilder.java
   geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment/WebModule.java
   geronimo/trunk/modules/j2ee/src/test/org/apache/geronimo/j2ee/deployment/EARConfigBuilderTest.java
   geronimo/trunk/modules/j2ee/src/test/org/apache/geronimo/j2ee/deployment/MockConnectorConfigBuilder.java
   geronimo/trunk/modules/j2ee/src/test/org/apache/geronimo/j2ee/deployment/MockEJBConfigBuilder.java
   geronimo/trunk/modules/j2ee/src/test/org/apache/geronimo/j2ee/deployment/MockWARConfigBuilder.java
   geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java
   geronimo/trunk/modules/jetty/src/test/org/apache/geronimo/jetty/deployment/PlanParsingTest.java
Log:
Modified module builders to return the object name of the module j2ee management object
ObjectNames are used as the basis of the TargetModuleID to create a hierarchy or deployed modules
Split createModule method of module builder into a version for stand alone modules and a version for modules contained in an ear


Modified: geronimo/trunk/modules/client-builder/src/java/org/apache/geronimo/client/builder/AppClientModuleBuilder.java
==============================================================================
--- geronimo/trunk/modules/client-builder/src/java/org/apache/geronimo/client/builder/AppClientModuleBuilder.java	(original)
+++ geronimo/trunk/modules/client-builder/src/java/org/apache/geronimo/client/builder/AppClientModuleBuilder.java	Tue Sep 28 11:46:39 2004
@@ -95,17 +95,31 @@
         this.connectorModuleBuilder = connectorModuleBuilder;
     }
 
-    public Module createModule(String name, Object plan, JarFile moduleFile, URL appClientXmlUrl, String targetPath) throws DeploymentException {
+    public Module createModule(File plan, JarFile moduleFile) throws DeploymentException {
+        return createModule(plan, moduleFile, "app-client", null, true);
+    }
+
+    public Module createModule(Object plan, JarFile moduleFile, String targetPath, URL specDDUrl) throws DeploymentException {
+        return createModule(plan, moduleFile, targetPath, specDDUrl, false);
+    }
+
+    private Module createModule(Object plan, JarFile moduleFile, String targetPath, URL specDDUrl, boolean standAlone) throws DeploymentException {
+        assert moduleFile != null: "moduleFile is null";
+        assert targetPath != null: "targetPath is null";
+        assert !targetPath.endsWith("/"): "targetPath must not end with a '/'";
+
         String specDD;
         ApplicationClientType appClient;
         try {
-            if (appClientXmlUrl == null) {
-                appClientXmlUrl = JarUtil.createJarURL(moduleFile, "META-INF/application-client.xml");
+            if (specDDUrl == null) {
+                specDDUrl = JarUtil.createJarURL(moduleFile, "META-INF/application-client.xml");
             }
 
-            specDD = IOUtil.readAll(appClientXmlUrl);
+            // read in the entire specDD as a string, we need this for getDeploymentDescriptor
+            // on the J2ee management object
+            specDD = IOUtil.readAll(specDDUrl);
 
-            // check if we have an alt spec dd
+            // parse it
             XmlObject xmlObject = SchemaConversionUtils.parse(specDD);
             ApplicationClientDocument appClientDoc = SchemaConversionUtils.convertToApplicationClientSchema(xmlObject);
             appClient = appClientDoc.getApplicationClient();
@@ -115,8 +129,8 @@
             return null;
         }
 
-        GerApplicationClientType gerAppClient = null;
-        gerAppClient = getApplicationClientType(plan, moduleFile, name, appClient);
+        // parse vendor dd
+        GerApplicationClientType gerAppClient = getGeronimoAppClient(plan, moduleFile, standAlone, targetPath, appClient);
 
         // get the ids from either the application plan or for a stand alone module from the specific deployer
         URI configId = null;
@@ -135,21 +149,10 @@
             }
         }
 
-        URI moduleURI;
-        if (targetPath != null) {
-            moduleURI = URI.create(targetPath);
-            if (targetPath.endsWith("/")) {
-                throw new DeploymentException("targetPath must not end with a '/'");
-            }
-        } else {
-            targetPath = "app-client";
-            moduleURI = URI.create("");
-        }
-
-        return new AppClientModule(name, configId, parentId, moduleURI, moduleFile, targetPath, appClient, gerAppClient, specDD);
+        return new AppClientModule(standAlone, configId, parentId, moduleFile, targetPath, appClient, gerAppClient, specDD);
     }
 
-    GerApplicationClientType getApplicationClientType(Object plan, JarFile moduleFile, String name, ApplicationClientType appClient) throws DeploymentException {
+    GerApplicationClientType getGeronimoAppClient(Object plan, JarFile moduleFile, boolean standAlone, String targetPath, ApplicationClientType appClient) throws DeploymentException {
         GerApplicationClientType gerAppClient = null;
         try {
             // load the geronimo-application-client.xml from either the supplied plan or from the earFile
@@ -179,7 +182,15 @@
                 gerAppClient = (GerApplicationClientType) SchemaConversionUtils.convertToGeronimoNamingSchema(gerAppClient);
                 SchemaConversionUtils.validateDD(gerAppClient);
             } else {
-                gerAppClient = createDefaultPlan(name, appClient);
+                String path;
+                if (standAlone) {
+                    // default configId is based on the moduleFile name
+                    path = new File(moduleFile.getName()).getName();
+                } else {
+                    // default configId is based on the module uri from the application.xml
+                    path = targetPath;
+                }
+                gerAppClient = createDefaultPlan(path, appClient);
             }
         } catch (XmlException e) {
             throw new DeploymentException(e);
@@ -225,7 +236,7 @@
         // application clients do not add anything to the shared context
     }
 
-    public void addGBeans(EARContext earContext, Module module, ClassLoader earClassLoader) throws DeploymentException {
+    public String addGBeans(EARContext earContext, Module module, ClassLoader earClassLoader) throws DeploymentException {
         AppClientModule appClientModule = (AppClientModule) module;
 
         ApplicationClientType appClient = (ApplicationClientType) appClientModule.getSpecDD();
@@ -365,7 +376,7 @@
                       connectorFile = new NestedJarFile(appClientModule.getEarFile(), path);
                     }
                     XmlObject connectorPlan = resource.getConnector();
-                    Module connectorModule = connectorModuleBuilder.createModule(path, connectorPlan, connectorFile, null, path);
+                    Module connectorModule = connectorModuleBuilder.createModule(connectorPlan, connectorFile, path, null);
                     resourceModules.add(connectorModule);
                     connectorModuleBuilder.installModule(connectorFile, appClientDeploymentContext, connectorModule);
                 }
@@ -409,6 +420,7 @@
         } catch (Exception e) {
             throw new DeploymentException(e);
         }
+        return appClientModuleName.getCanonicalName();
     }
 
     private ReadOnlyContext buildComponentContext(EARContext earContext, AppClientModule appClientModule, ApplicationClientType appClient, GerApplicationClientType geronimoAppClient, ClassLoader cl) throws DeploymentException {

Modified: geronimo/trunk/modules/client-builder/src/test/org/apache/geronimo/client/builder/PlanParsingTest.java
==============================================================================
--- geronimo/trunk/modules/client-builder/src/test/org/apache/geronimo/client/builder/PlanParsingTest.java	(original)
+++ geronimo/trunk/modules/client-builder/src/test/org/apache/geronimo/client/builder/PlanParsingTest.java	Tue Sep 28 11:46:39 2004
@@ -18,7 +18,7 @@
     public void testResourceRef() throws Exception {
         File resourcePlan = new File(basedir, "src/test-resources/plans/plan1.xml");
         assertTrue(resourcePlan.exists());
-        GerApplicationClientType appClient = builder.getApplicationClientType(resourcePlan, null, null, null);
+        GerApplicationClientType appClient = builder.getGeronimoAppClient(resourcePlan, null, true, null, null);
         assertEquals(1, appClient.getResourceRefArray().length);
     }
 
@@ -38,7 +38,7 @@
     public void testConnectorInclude() throws Exception {
         File resourcePlan = new File(basedir, "src/test-resources/plans/plan2.xml");
         assertTrue(resourcePlan.exists());
-        GerApplicationClientType appClient = builder.getApplicationClientType(resourcePlan, null, null, null);
+        GerApplicationClientType appClient = builder.getGeronimoAppClient(resourcePlan, null, true, null, null);
         assertEquals(1, appClient.getResourceRefArray().length);
         assertEquals(1, appClient.getResourceArray().length);
     }

Modified: geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/deployment/ConnectorModuleBuilder.java
==============================================================================
--- geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/deployment/ConnectorModuleBuilder.java	(original)
+++ geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/deployment/ConnectorModuleBuilder.java	Tue Sep 28 11:46:39 2004
@@ -96,16 +96,31 @@
     private static final String BASE_PASSWORD_CREDENTIAL_LOGIN_MODULE_NAME = "geronimo.security:service=Realm,type=PasswordCredential,name=";
     private static final String BASE_WORK_MANAGER_NAME = "geronimo.server:type=WorkManager,name=";
 
-    public Module createModule(String name, Object plan, JarFile moduleFile, URL appClientXmlUrl, String targetPath) throws DeploymentException {
+    public Module createModule(File plan, JarFile moduleFile) throws DeploymentException {
+        return createModule(plan, moduleFile, "war", null, true);
+    }
+
+    public Module createModule(Object plan, JarFile moduleFile, String targetPath, URL specDDUrl) throws DeploymentException {
+        return createModule(plan, moduleFile, targetPath, specDDUrl, false);
+    }
+
+    private Module createModule(Object plan, JarFile moduleFile, String targetPath, URL specDDUrl, boolean standAlone) throws DeploymentException {
+        assert moduleFile != null: "moduleFile is null";
+        assert targetPath != null: "targetPath is null";
+        assert !targetPath.endsWith("/"): "targetPath must not end with a '/'";
+
         String specDD;
         XmlObject connector;
         try {
-            if (appClientXmlUrl == null) {
-                appClientXmlUrl = JarUtil.createJarURL(moduleFile, "META-INF/ra.xml");
+            if (specDDUrl == null) {
+                specDDUrl = JarUtil.createJarURL(moduleFile, "META-INF/ra.xml");
             }
 
-            specDD = IOUtil.readAll(appClientXmlUrl);
+            // read in the entire specDD as a string, we need this for getDeploymentDescriptor
+            // on the J2ee management object
+            specDD = IOUtil.readAll(specDDUrl);
 
+            // parse it
             try {
                 // try 1.0
                 ConnectorDocument10 connectorDoc = ConnectorDocument10.Factory.parse(specDD);
@@ -171,24 +186,12 @@
             }
         }
 
-        URI moduleURI;
-        if (targetPath != null) {
-            moduleURI = URI.create(targetPath);
-            if (targetPath.endsWith("/")) {
-                throw new DeploymentException("targetPath must not end with a '/'");
-            }
-            targetPath += "/";
-        } else {
-            targetPath = "connector/";
-            moduleURI = URI.create("");
-        }
-
-        return new ConnectorModule(name, configId, parentId, moduleURI, moduleFile, targetPath, connector, gerConnector, specDD);
+        return new ConnectorModule(standAlone, configId, parentId, moduleFile, targetPath, connector, gerConnector, specDD);
     }
 
     public void installModule(JarFile earFile, EARContext earContext, Module module) throws DeploymentException {
         try {
-            URI targetURI = URI.create(module.getTargetPath());
+            URI targetURI = URI.create(module.getTargetPath() + "/");
 
             JarFile moduleFile = module.getModuleFile();
 
@@ -226,8 +229,8 @@
         // TODO should the 1.5 ActivationSpecInfos be processed here? YES
     }
 
-    public void addGBeans(EARContext earContext, Module module, ClassLoader cl) throws DeploymentException {
-        addResourceAdapterModuleGBean(earContext, module, cl);
+    public String addGBeans(EARContext earContext, Module module, ClassLoader cl) throws DeploymentException {
+        ObjectName resourceAdapterModuleName = addResourceAdapterModuleGBean(earContext, module, cl);
 
         GerConnectorType geronimoConnector = (GerConnectorType) module.getVendorDD();
         XmlObject specDD = module.getSpecDD();
@@ -241,9 +244,11 @@
         for (int i = 0; i < gbeans.length; i++) {
             GBeanHelper.addGbean(new RARGBeanAdapter(gbeans[i]), cl, earContext);
         }
+
+        return resourceAdapterModuleName.getCanonicalName();
     }
 
-    private void addResourceAdapterModuleGBean(EARContext earContext, Module module, ClassLoader cl) throws DeploymentException {
+    private ObjectName addResourceAdapterModuleGBean(EARContext earContext, Module module, ClassLoader cl) throws DeploymentException {
         // build the objectName
         Properties nameProps = new Properties();
         nameProps.put("j2eeType", "ResourceAdapterModule");
@@ -251,9 +256,9 @@
         nameProps.put("J2EEServer", earContext.getJ2EEServerName());
         nameProps.put("J2EEApplication", earContext.getJ2EEApplicationName());
 
-        ObjectName resourceAdapterModuleObjectName = null;
+        ObjectName resourceAdapterModuleName = null;
         try {
-            resourceAdapterModuleObjectName = new ObjectName(earContext.getJ2EEDomainName(), nameProps);
+            resourceAdapterModuleName = new ObjectName(earContext.getJ2EEDomainName(), nameProps);
         } catch (MalformedObjectNameException e) {
             throw new DeploymentException("Unable to construct ResourceAdapterModule ObjectName", e);
         }
@@ -272,7 +277,9 @@
         }
 
         // add it
-        earContext.addGBean(resourceAdapterModuleObjectName, resourceAdapterModule);
+        earContext.addGBean(resourceAdapterModuleName, resourceAdapterModule);
+
+        return resourceAdapterModuleName;
     }
 
     private void addConnectorGBeans(EARContext context, ConnectorType10 connector, GerConnectorType geronimoConnector, ClassLoader cl) throws DeploymentException {

Modified: geronimo/trunk/modules/connector/src/test/org/apache/geronimo/connector/deployment/RAR_1_0ConfigBuilderTest.java
==============================================================================
--- geronimo/trunk/modules/connector/src/test/org/apache/geronimo/connector/deployment/RAR_1_0ConfigBuilderTest.java	(original)
+++ geronimo/trunk/modules/connector/src/test/org/apache/geronimo/connector/deployment/RAR_1_0ConfigBuilderTest.java	Tue Sep 28 11:46:39 2004
@@ -40,7 +40,6 @@
 import junit.framework.TestCase;
 import org.apache.geronimo.deployment.DeploymentException;
 import org.apache.geronimo.deployment.util.JarUtil;
-import org.apache.geronimo.deployment.util.UnpackedJarFile;
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.jmx.GBeanMBean;
 import org.apache.geronimo.j2ee.deployment.EARConfigBuilder;
@@ -89,22 +88,8 @@
 
     public void testBuildUnpackedModule() throws Exception {
         InstallAction action = new InstallAction() {
-            public File getVendorDD() {
-                return null;
-            }
-
-            public URL getSpecDD() {
-                return null;
-            }
-
-            private File rarFile = new File(basedir, "target/test-rar-10");
-
             public File getRARFile() {
-                return rarFile;
-            }
-
-            public void install(ModuleBuilder moduleBuilder, EARContext earContext, Module module) throws Exception {
-                moduleBuilder.installModule(new UnpackedJarFile(rarFile), earContext, module);
+                return new File(basedir, "target/test-rar-10");
             }
         };
         executeTestBuildModule(action);
@@ -120,14 +105,8 @@
                 return new File(basedir, "target/test-rar-10/dummy.xml").toURL();
             }
 
-            private File rarFile = new File(basedir, "target/test-rar-10");
-
             public File getRARFile() {
-                return rarFile;
-            }
-
-            public void install(ModuleBuilder moduleBuilder, EARContext earContext, Module module) throws Exception {
-                moduleBuilder.installModule(new UnpackedJarFile(rarFile), earContext, module);
+                return new File(basedir, "target/test-rar-10");
             }
         };
         try {
@@ -148,14 +127,8 @@
                 return new File(basedir, "target/test-rar-10/META-INF/ra.xml").toURL();
             }
 
-            private File rarFile = new File(basedir, "target/test-rar-10");
-
             public File getRARFile() {
-                return rarFile;
-            }
-
-            public void install(ModuleBuilder moduleBuilder, EARContext earContext, Module module) throws Exception {
-                moduleBuilder.installModule(new UnpackedJarFile(rarFile), earContext, module);
+                return new File(basedir, "target/test-rar-10");
             }
         };
         try {
@@ -176,37 +149,17 @@
                 return new File(basedir, "target/test-rar-10/META-INF/ra.xml").toURL();
             }
 
-            private File rarFile = new File(basedir, "target/test-rar-10");
-
             public File getRARFile() {
-                return rarFile;
-            }
-
-            public void install(ModuleBuilder moduleBuilder, EARContext earContext, Module module) throws Exception {
-                moduleBuilder.installModule(new UnpackedJarFile(rarFile), earContext, module);
+                return new File(basedir, "target/test-rar-10");
             }
-        };
+       };
         executeTestBuildModule(action);
     }
 
     public void testBuildPackedModule() throws Exception {
         InstallAction action = new InstallAction() {
-            public File getVendorDD() {
-                return null;
-            }
-
-            public URL getSpecDD() {
-                return null;
-            }
-
-            private File rarFile = new File(basedir, "target/test-rar-10.rar");
-
             public File getRARFile() {
-                return rarFile;
-            }
-
-            public void install(ModuleBuilder moduleBuilder, EARContext earContext, Module module) throws Exception {
-                moduleBuilder.installModule(JarUtil.createJarFile(rarFile), earContext, module);
+                return new File(basedir, "target/test-rar-10.rar");
             }
         };
         executeTestBuildModule(action);
@@ -215,8 +168,8 @@
     private void executeTestBuildModule(InstallAction action) throws Exception {
         String j2eeDomainName = "geronimo.server";
         String j2eeServerName = "TestGeronimoServer";
-        String j2eeApplicationName = "null";
         String j2eeModuleName = "org/apache/geronimo/j2ee/deployment/test";
+        String j2eeApplicationName = "null";
         ObjectName connectionTrackerName = new ObjectName("geronimo.connector:service=ConnectionTracker");
 
         ConnectorModuleBuilder moduleBuilder = new ConnectorModuleBuilder();
@@ -228,7 +181,7 @@
         Thread.currentThread().setContextClassLoader(cl);
 
         JarFile rarJarFile = JarUtil.createJarFile(rarFile);
-        Module module = moduleBuilder.createModule(j2eeModuleName, action.getVendorDD(), rarJarFile, action.getSpecDD(), "connector");
+        Module module = moduleBuilder.createModule(action.getVendorDD(), rarJarFile, j2eeModuleName, action.getSpecDD());
         if (module == null) {
             throw new DeploymentException("Was not a connector module");
         }
@@ -280,7 +233,6 @@
                 File planFile = new File(basedir, "src/test-data/data/external-application-plan.xml");
                 Object plan = configBuilder.getDeploymentPlan(planFile, rarFile);
                 configBuilder.buildConfiguration(outFile, null, plan, rarFile);
-
             } finally {
                 outFile.delete();
             }
@@ -449,14 +401,20 @@
         xmlOptions.setErrorListener(errors);
     }
 
-    private interface InstallAction {
-        File getRARFile();
+    private abstract class InstallAction {
+        public File getVendorDD() {
+            return null;
+        }
 
-        void install(ModuleBuilder moduleBuilder, EARContext earContext, Module module) throws Exception;
+        public URL getSpecDD() throws MalformedURLException {
+            return null;
+        }
 
-        File getVendorDD() throws MalformedURLException;
+        public abstract File getRARFile();
 
-        URL getSpecDD() throws MalformedURLException;
+        public void install(ModuleBuilder moduleBuilder, EARContext earContext, Module module) throws Exception {
+            moduleBuilder.installModule(JarUtil.createJarFile(getRARFile()), earContext, module);
+        }
     }
 
 }

Modified: geronimo/trunk/modules/connector/src/test/org/apache/geronimo/connector/deployment/RAR_1_5ConfigBuilderTest.java
==============================================================================
--- geronimo/trunk/modules/connector/src/test/org/apache/geronimo/connector/deployment/RAR_1_5ConfigBuilderTest.java	(original)
+++ geronimo/trunk/modules/connector/src/test/org/apache/geronimo/connector/deployment/RAR_1_5ConfigBuilderTest.java	Tue Sep 28 11:46:39 2004
@@ -126,7 +126,7 @@
 
         Thread.currentThread().setContextClassLoader(cl);
 
-        Module module = moduleBuilder.createModule(j2eeModuleName, null, JarUtil.createJarFile(action.getRARFile()), null, null);
+        Module module = moduleBuilder.createModule(null, JarUtil.createJarFile(action.getRARFile()));
         assertEquals(j2eeModuleName, module.getConfigId().toString());
 
         File carFile = File.createTempFile("RARTest", ".car");

Modified: geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/ConfigurationBuilder.java
==============================================================================
--- geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/ConfigurationBuilder.java	(original)
+++ geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/ConfigurationBuilder.java	Tue Sep 28 11:46:39 2004
@@ -21,6 +21,7 @@
 import java.io.IOException;
 import java.util.jar.JarFile;
 import java.util.jar.Manifest;
+import java.util.List;
 
 /**
  * @version $Rev$ $Date$
@@ -46,5 +47,5 @@
      * @throws IOException if there was a problem reading or writing the files
      * @throws DeploymentException if there was a problem with the configuration
      */
-    void buildConfiguration(File outfile, Manifest manifest, Object plan, JarFile module) throws IOException, DeploymentException;
+    List buildConfiguration(File outfile, Manifest manifest, Object plan, JarFile module) throws IOException, DeploymentException;
 }

Modified: geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/Deployer.java
==============================================================================
--- geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/Deployer.java	(original)
+++ geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/Deployer.java	Tue Sep 28 11:46:39 2004
@@ -22,6 +22,8 @@
 import java.net.URI;
 import java.util.Collection;
 import java.util.Iterator;
+import java.util.List;
+import java.util.Collections;
 import java.util.jar.Attributes;
 import java.util.jar.JarFile;
 import java.util.jar.Manifest;
@@ -53,7 +55,7 @@
         this.store = store;
     }
 
-    public URI deploy(File moduleFile, File planFile) throws DeploymentException {
+    public List deploy(File moduleFile, File planFile) throws DeploymentException {
         return deploy(planFile, moduleFile, null, true, null, null);
     }
 
@@ -76,11 +78,17 @@
         String classPath = cmd.classPath;
 
 
-        URI uri = deploy(planFile, module, carfile, install, mainClass, classPath);
-        System.out.println("Deployment uri is " + uri);
+        List objectNames = deploy(planFile, module, carfile, install, mainClass, classPath);
+        if (!objectNames.isEmpty()) {
+            Iterator iterator = objectNames.iterator();
+            System.out.println("Deployed " + iterator.next());
+            while (iterator.hasNext()) {
+                System.out.println("    " + iterator.next());
+            }
+        }
     }
 
-    public URI deploy(File planFile, File moduleFile, File carfile, boolean install, String mainClass, String classPath) throws DeploymentException {
+    public List deploy(File planFile, File moduleFile, File carfile, boolean install, String mainClass, String classPath) throws DeploymentException {
         if (planFile == null && moduleFile == null) {
             throw new DeploymentException("No plan or module specified");
         }
@@ -132,13 +140,14 @@
 
 
         try {
-            builder.buildConfiguration(carfile, manifest, plan, module);
+            List objectNames = builder.buildConfiguration(carfile, manifest, plan, module);
 
             try {
                 if (install) {
-                    return store.install(carfile.toURL());
+                    store.install(carfile.toURL());
+                    return objectNames;
                 }
-                return null;
+                return Collections.EMPTY_LIST;
             } catch (InvalidConfigException e) {
                 // unlikely as we just built this
                 throw new DeploymentException(e);

Modified: geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/plugin/TargetModuleIDImpl.java
==============================================================================
--- geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/plugin/TargetModuleIDImpl.java	(original)
+++ geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/plugin/TargetModuleIDImpl.java	Tue Sep 28 11:46:39 2004
@@ -28,10 +28,32 @@
 public class TargetModuleIDImpl implements TargetModuleID {
     private final Target target;
     private final String moduleID;
+    private final TargetModuleID parentTargetModuleID;
+    private final TargetModuleID[] childTargetModuleID;
 
     public TargetModuleIDImpl(Target target, String moduleID) {
         this.target = target;
         this.moduleID = moduleID;
+        parentTargetModuleID = null;
+        childTargetModuleID = null;
+    }
+
+    public TargetModuleIDImpl(Target target, String moduleID, String[] childIDs) {
+        this.target = target;
+        this.moduleID = moduleID;
+        parentTargetModuleID = null;
+        childTargetModuleID = new TargetModuleID[childIDs.length];
+        for (int i = 0; i < childIDs.length; i++) {
+            String childID = childIDs[i];
+            childTargetModuleID[i] = new TargetModuleIDImpl(target, childID, this);
+        }
+    }
+
+    private TargetModuleIDImpl(Target target, String moduleID, TargetModuleID parent) {
+        this.target = target;
+        this.moduleID = moduleID;
+        this.parentTargetModuleID = parent;
+        childTargetModuleID = null;
     }
 
     public Target getTarget() {
@@ -43,11 +65,11 @@
     }
 
     public TargetModuleID getParentTargetModuleID() {
-        return null;
+        return parentTargetModuleID;
     }
 
     public TargetModuleID[] getChildTargetModuleID() {
-        return null;
+        return childTargetModuleID;
     }
 
     public String getWebURL() {

Modified: geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/plugin/local/DistributeCommand.java
==============================================================================
--- geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/plugin/local/DistributeCommand.java	(original)
+++ geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/plugin/local/DistributeCommand.java	Tue Sep 28 11:46:39 2004
@@ -22,8 +22,8 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
-import java.net.URI;
 import java.util.Iterator;
+import java.util.List;
 import java.util.Set;
 import javax.enterprise.deploy.shared.CommandType;
 import javax.enterprise.deploy.spi.Target;
@@ -91,9 +91,16 @@
             }
 
             Object[] args = {moduleArchive, deploymentPlan};
-            URI configId = (URI) kernel.invoke(deployer, "deploy", args, DEPLOY_SIG);
-            TargetModuleID moduleID = new TargetModuleIDImpl(targetList[0], configId.toString());
-            addModule(moduleID);
+            List objectNames = (List) kernel.invoke(deployer, "deploy", args, DEPLOY_SIG);
+            if (objectNames != null && !objectNames.isEmpty()) {
+                String parentName = (String) objectNames.get(0);
+
+                List childNames = objectNames.subList(1, objectNames.size());
+                String[] childIDs = (String[]) childNames.toArray(new String[childNames.size()]);
+
+                TargetModuleID moduleID = new TargetModuleIDImpl(targetList[0], parentName.toString(), childIDs);
+                addModule(moduleID);
+            }
             complete("Completed");
         } catch (Exception e) {
             doFail(e);

Modified: geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/service/ServiceConfigBuilder.java
==============================================================================
--- geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/service/ServiceConfigBuilder.java	(original)
+++ geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/service/ServiceConfigBuilder.java	Tue Sep 28 11:46:39 2004
@@ -32,6 +32,8 @@
 import java.util.jar.JarOutputStream;
 import java.util.jar.Manifest;
 import java.util.zip.ZipEntry;
+import java.util.List;
+import java.util.Collections;
 import javax.management.MalformedObjectNameException;
 
 import org.apache.geronimo.deployment.ConfigurationBuilder;
@@ -82,7 +84,7 @@
         }
     }
 
-    public void buildConfiguration(File outfile, Manifest manifest, Object plan, JarFile unused) throws IOException, DeploymentException {
+    public List buildConfiguration(File outfile, Manifest manifest, Object plan, JarFile unused) throws IOException, DeploymentException {
         FileOutputStream fos = new FileOutputStream(outfile);
         try {
             JarOutputStream os = new JarOutputStream(new BufferedOutputStream(fos), manifest);
@@ -94,7 +96,7 @@
             }
 
             buildConfiguration(os, (XmlObject) plan);
-
+            return Collections.EMPTY_LIST;
         } finally {
             fos.close();
         }

Modified: geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment/AppClientModule.java
==============================================================================
--- geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment/AppClientModule.java	(original)
+++ geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment/AppClientModule.java	Tue Sep 28 11:46:39 2004
@@ -16,14 +16,13 @@
  */
 package org.apache.geronimo.j2ee.deployment;
 
-import java.util.jar.JarFile;
-import java.util.Set;
-import java.util.HashSet;
-import java.util.Collection;
 import java.net.URI;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.jar.JarFile;
 
-import org.apache.xmlbeans.XmlObject;
 import org.apache.geronimo.kernel.config.ConfigurationModuleType;
+import org.apache.xmlbeans.XmlObject;
 
 /**
  * @version $Rev: 46019 $ $Date: 2004-09-14 02:56:06 -0700 (Tue, 14 Sep 2004) $
@@ -34,8 +33,8 @@
 
     private JarFile earFile;
 
-    public AppClientModule(String name, URI configId, URI parentId, URI moduleURI, JarFile moduleFile, String targetPath, XmlObject specDD, XmlObject vendorDD, String originalSpecDD) {
-        super(name, configId, parentId, moduleURI, moduleFile, targetPath, specDD, vendorDD, originalSpecDD);
+    public AppClientModule(boolean standAlone, URI configId, URI parentId, JarFile moduleFile, String targetPath, XmlObject specDD, XmlObject vendorDD, String originalSpecDD) {
+        super(standAlone, configId, parentId, moduleFile, targetPath, specDD, vendorDD, originalSpecDD);
     }
 
     public ConfigurationModuleType getType() {

Modified: geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment/ConnectorModule.java
==============================================================================
--- geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment/ConnectorModule.java	(original)
+++ geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment/ConnectorModule.java	Tue Sep 28 11:46:39 2004
@@ -26,8 +26,8 @@
  * @version $Rev$ $Date$
  */
 public class ConnectorModule extends Module {
-    public ConnectorModule(String name, URI configId, URI parentId, URI moduleURI, JarFile moduleFile, String targetPath, XmlObject specDD, XmlObject vendorDD, String originalSpecDD) {
-        super(name, configId, parentId, moduleURI, moduleFile, targetPath, specDD, vendorDD, originalSpecDD);
+    public ConnectorModule(boolean standAlone, URI configId, URI parentId, JarFile moduleFile, String targetPath, XmlObject specDD, XmlObject vendorDD, String originalSpecDD) {
+        super(standAlone, configId, parentId, moduleFile, targetPath, specDD, vendorDD, originalSpecDD);
     }
 
     public ConfigurationModuleType getType() {

Modified: geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilder.java
==============================================================================
--- geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilder.java	(original)
+++ geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilder.java	Tue Sep 28 11:46:39 2004
@@ -29,8 +29,10 @@
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.LinkedHashSet;
+import java.util.LinkedList;
 import java.util.Map;
 import java.util.Set;
+import java.util.List;
 import java.util.jar.JarFile;
 import java.util.jar.JarOutputStream;
 import java.util.jar.Manifest;
@@ -113,31 +115,24 @@
             return plan;
         }
 
-        // give the module the default name of the module file
-        String name = new File(jarFile.getName()).getName();
-
         // get the modules either the application plan or for a stand alone module from the specific deployer
         Module module = null;
         if (webConfigBuilder != null) {
-            module = webConfigBuilder.createModule(name, planFile, jarFile, null, null);
+            module = webConfigBuilder.createModule(planFile, jarFile);
         }
         if (module == null && ejbConfigBuilder != null) {
-            module = ejbConfigBuilder.createModule(name, planFile, jarFile, null, null);
+            module = ejbConfigBuilder.createModule(planFile, jarFile);
         }
         if (module == null && connectorConfigBuilder != null) {
-            module = connectorConfigBuilder.createModule(name, planFile, jarFile, null, null);
+            module = connectorConfigBuilder.createModule(planFile, jarFile);
         }
         if (module == null && appClientConfigBuilder != null) {
-            module = appClientConfigBuilder.createModule(name, planFile, jarFile, null, null);
+            module = appClientConfigBuilder.createModule(planFile, jarFile);
         }
         if (module == null) {
             return null;
         }
 
-        // in the case of a stand alone module we actually want the name to be the
-        // config id, which may be derived from the module file name set above
-        module.setName(module.getConfigId().toString());
-
         return new ApplicationInfo(module.getType(),
                 module.getConfigId(),
                 module.getParentId(),
@@ -248,10 +243,12 @@
         return gerApplication;
     }
 
-    public void buildConfiguration(File outfile, Manifest manifest, Object plan, JarFile earFile) throws IOException, DeploymentException {
+    public List buildConfiguration(File outfile, Manifest manifest, Object plan, JarFile earFile) throws IOException, DeploymentException {
         ApplicationInfo applicationInfo = (ApplicationInfo) plan;
         FileOutputStream fos = new FileOutputStream(outfile);
         try {
+            List moduleIDs = new LinkedList();
+
             // Create the output ear context
             JarOutputStream os = new JarOutputStream(new BufferedOutputStream(fos));
             EARContext earContext = null;
@@ -324,17 +321,21 @@
                     throw new DeploymentException("Error initializing J2EEApplication managed object");
                 }
                 gbean.setReferencePatterns("j2eeServer", Collections.singleton(j2eeServer));
-                earContext.addGBean(earContext.getApplicationObjectName(), gbean);
+                ObjectName applicationName = earContext.getApplicationObjectName();
+                earContext.addGBean(applicationName, gbean);
+                moduleIDs.add(applicationName.getCanonicalName());
             }
 
             // each module can now add it's GBeans
             for (Iterator iterator = modules.iterator(); iterator.hasNext();) {
                 Module module = (Module) iterator.next();
-                getBuilder(module).addGBeans(earContext, module, cl);
+                String moduleID = getBuilder(module).addGBeans(earContext, module, cl);
+                moduleIDs.add(moduleID);
             }
 
             earContext.close();
             os.flush();
+            return moduleIDs;
         } finally {
             fos.close();
         }
@@ -424,11 +425,10 @@
                 altSpecDD = JarUtil.createJarURL(earFile, moduleXml.getAltDd().getStringValue());
             }
 
-            Module module = builder.createModule(modulePath,
-                    altVendorDDs.get(modulePath),
+            Module module = builder.createModule(altVendorDDs.get(modulePath),
                     new NestedJarFile(earFile, modulePath),
-                    altSpecDD,
-                    modulePath);
+                    modulePath,
+                    altSpecDD);
 
             if (module == null) {
                 throw new DeploymentException("Module was not " + moduleTypeName + ": " + modulePath);

Modified: geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment/EJBModule.java
==============================================================================
--- geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment/EJBModule.java	(original)
+++ geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment/EJBModule.java	Tue Sep 28 11:46:39 2004
@@ -26,8 +26,8 @@
  * @version $Rev$ $Date$
  */
 public class EJBModule extends Module {
-    public EJBModule(String name, URI configId, URI parentId, URI moduleURI, JarFile moduleFile, String targetPath, XmlObject specDD, XmlObject vendorDD, String originalSpecDD) {
-        super(name, configId, parentId, moduleURI, moduleFile, targetPath, specDD, vendorDD, originalSpecDD);
+    public EJBModule(boolean standAlone, URI configId, URI parentId, JarFile moduleFile, String targetPath, XmlObject specDD, XmlObject vendorDD, String originalSpecDD) {
+        super(standAlone, configId, parentId, moduleFile, targetPath, specDD, vendorDD, originalSpecDD);
     }
 
     public ConfigurationModuleType getType() {

Modified: geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment/Module.java
==============================================================================
--- geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment/Module.java	(original)
+++ geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment/Module.java	Tue Sep 28 11:46:39 2004
@@ -26,7 +26,8 @@
  * @version $Rev$ $Date$
  */
 public abstract class Module {
-    private String name;
+    private final boolean standAlone;
+    private final String name;
     private final URI configId;
     private final URI parentId;
     private final URI moduleURI;
@@ -36,16 +37,23 @@
     private final XmlObject vendorDD;
     private final String originalSpecDD;
 
-    public Module(String name, URI configId, URI parentId, URI moduleURI, JarFile moduleFile, String targetPath, XmlObject specDD, XmlObject vendorDD, String originalSpecDD) {
-        this.name = name;
+    protected Module(boolean standAlone, URI configId, URI parentId, JarFile moduleFile, String targetPath, XmlObject specDD, XmlObject vendorDD, String originalSpecDD) {
+        this.standAlone = standAlone;
         this.configId = configId;
         this.parentId = parentId;
-        this.moduleURI = moduleURI;
         this.moduleFile = moduleFile;
         this.targetPath = targetPath;
         this.specDD = specDD;
         this.vendorDD = vendorDD;
         this.originalSpecDD = originalSpecDD;
+
+        if (standAlone) {
+            name = configId.toString();
+            moduleURI = URI.create("");
+        } else {
+            name = targetPath;
+            moduleURI = URI.create(targetPath);
+        }
     }
 
     public abstract ConfigurationModuleType  getType();
@@ -54,8 +62,8 @@
         return name;
     }
 
-    public void setName(String name) {
-        this.name = name;
+    public boolean isStandAlone() {
+        return standAlone;
     }
 
     public URI getConfigId() {

Modified: geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment/ModuleBuilder.java
==============================================================================
--- geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment/ModuleBuilder.java	(original)
+++ geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment/ModuleBuilder.java	Tue Sep 28 11:46:39 2004
@@ -16,6 +16,7 @@
  */
 package org.apache.geronimo.j2ee.deployment;
 
+import java.io.File;
 import java.net.URL;
 import java.util.jar.JarFile;
 
@@ -25,12 +26,13 @@
  * @version $Rev$ $Date$
  */
 public interface ModuleBuilder {
-    Module createModule(String name, Object planFile, JarFile moduleFile, URL specDDUrl, String targetPath) throws DeploymentException;
+    Module createModule(File plan, JarFile moduleFile) throws DeploymentException;
+
+    Module createModule(Object plan, JarFile moduleFile, String targetPath, URL specDDUrl) throws DeploymentException;
 
     void installModule(JarFile earFile, EARContext earContext, Module module) throws DeploymentException;
 
     void initContext(EARContext earContext, Module module, ClassLoader cl) throws DeploymentException;
 
-    void addGBeans(EARContext earContext, Module module, ClassLoader cl) throws DeploymentException;
-
+    String addGBeans(EARContext earContext, Module module, ClassLoader cl) throws DeploymentException;
 }

Modified: geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment/WebModule.java
==============================================================================
--- geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment/WebModule.java	(original)
+++ geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment/WebModule.java	Tue Sep 28 11:46:39 2004
@@ -28,8 +28,8 @@
 public class WebModule extends Module {
     private String contextRoot;
 
-    public WebModule(String name, URI configId, URI parentId, URI moduleURI, JarFile moduleFile, String targetPath, XmlObject specDD, XmlObject vendorDD, String originalSpecDD) {
-        super(name, configId, parentId, moduleURI, moduleFile, targetPath, specDD, vendorDD, originalSpecDD);
+    public WebModule(boolean standAlone, URI configId, URI parentId, JarFile moduleFile, String targetPath, XmlObject specDD, XmlObject vendorDD, String originalSpecDD) {
+        super(standAlone, configId, parentId, moduleFile, targetPath, specDD, vendorDD, originalSpecDD);
     }
 
     public String getContextRoot() {

Modified: geronimo/trunk/modules/j2ee/src/test/org/apache/geronimo/j2ee/deployment/EARConfigBuilderTest.java
==============================================================================
--- geronimo/trunk/modules/j2ee/src/test/org/apache/geronimo/j2ee/deployment/EARConfigBuilderTest.java	(original)
+++ geronimo/trunk/modules/j2ee/src/test/org/apache/geronimo/j2ee/deployment/EARConfigBuilderTest.java	Tue Sep 28 11:46:39 2004
@@ -18,7 +18,6 @@
 package org.apache.geronimo.j2ee.deployment;
 
 import java.io.File;
-import java.net.URI;
 import java.util.jar.JarFile;
 import javax.management.ObjectName;
 
@@ -54,11 +53,11 @@
         TestSetup setup14 = new TestSetup(inner) {
             protected void setUp() throws Exception {
                 earFile = JarUtil.createJarFile(new File(basedir,  "target/test-ear14/test-ear.ear"));
-                ejbConfigBuilder.ejbModule = new EJBModule("test-ejb-jar.jar", null, null, URI.create("test-ejb-jar.jar"), null, "test-ejb-jar.jar", null, null, null);
+                ejbConfigBuilder.ejbModule = new EJBModule(false, null, null, null, "test-ejb-jar.jar", null, null, null);
                 webConfigBuilder.contextRoot = "test";
-                webConfigBuilder.webModule = new WebModule("test-war.war", null, null, URI.create("test-war.war"), null, "test-war.war", null, null, null);
+                webConfigBuilder.webModule = new WebModule(false, null, null, null, "test-war.war", null, null, null);
                 webConfigBuilder.webModule.setContextRoot("test");
-                connectorConfigBuilder.connectorModule = new ConnectorModule("test-rar.rar", null, null, URI.create("test-rar.rar"), null, "test-rar.rar", null, null, null);
+                connectorConfigBuilder.connectorModule = new ConnectorModule(false, null, null, null, "test-rar.rar", null, null, null);
             }
 
             protected void tearDown() {
@@ -67,11 +66,11 @@
         TestSetup setupNaked14 = new TestSetup(inner) {
             protected void setUp() throws Exception {
                 earFile = JarUtil.createJarFile(new File(basedir,  "target/test-ear14/test-naked-ear.ear"));
-                ejbConfigBuilder.ejbModule = new EJBModule("test-ejb-jar.jar", null, null, URI.create("test-ejb-jar.jar"), null, "test-ejb-jar.jar", null, null, null);
+                ejbConfigBuilder.ejbModule = new EJBModule(false, null, null, null, "test-ejb-jar.jar", null, null, null);
                 webConfigBuilder.contextRoot = "test";
-                webConfigBuilder.webModule = new WebModule("test-war.war", null, null, URI.create("test-war.war"), null, "test-war.war", null, null, null);
+                webConfigBuilder.webModule = new WebModule(false, null, null, null, "test-war.war", null, null, null);
                 webConfigBuilder.webModule.setContextRoot("test");
-                connectorConfigBuilder.connectorModule = new ConnectorModule("test-rar.rar", null, null, URI.create("test-rar.rar"), null, "test-rar.rar", null, null, null);
+                connectorConfigBuilder.connectorModule = new ConnectorModule(false, null, null, null, "test-rar.rar", null, null, null);
             }
 
             protected void tearDown() {
@@ -80,11 +79,11 @@
         TestSetup setup13 = new TestSetup(inner) {
             protected void setUp() throws Exception {
                 earFile = JarUtil.createJarFile(new File(basedir,  "target/test-ear13/test-ear.ear"));
-                ejbConfigBuilder.ejbModule = new EJBModule("test-ejb-jar.jar", null, null, URI.create("test-ejb-jar.jar"), null, "test-ejb-jar.jar", null, null, null);
+                ejbConfigBuilder.ejbModule = new EJBModule(false, null, null, null, "test-ejb-jar.jar", null, null, null);
                 webConfigBuilder.contextRoot = "test";
-                webConfigBuilder.webModule = new WebModule("test-war.war", null, null, URI.create("test-war.war"), null, "test-war.war", null, null, null);
+                webConfigBuilder.webModule = new WebModule(false, null, null, null, "test-war.war", null, null, null);
                 webConfigBuilder.webModule.setContextRoot("test");
-                connectorConfigBuilder.connectorModule = new ConnectorModule("test-rar.rar", null, null, URI.create("test-rar.rar"), null, "test-rar.rar", null, null, null);
+                connectorConfigBuilder.connectorModule = new ConnectorModule(false, null, null, null, "test-rar.rar", null, null, null);
             }
 
             protected void tearDown() {
@@ -93,11 +92,11 @@
         TestSetup setupNaked13 = new TestSetup(inner) {
             protected void setUp() throws Exception {
                 earFile = JarUtil.createJarFile(new File(basedir, "target/test-ear13/test-naked-ear.ear"));
-                ejbConfigBuilder.ejbModule = new EJBModule("test-ejb-jar.jar", null, null, URI.create("test-ejb-jar.jar"), null, "test-ejb-jar.jar", null, null, null);
+                ejbConfigBuilder.ejbModule = new EJBModule(false, null, null, null, "test-ejb-jar.jar", null, null, null);
                 webConfigBuilder.contextRoot = "test";
-                webConfigBuilder.webModule = new WebModule("test-war.war", null, null, URI.create("test-war.war"), null, "test-war.war", null, null, null);
+                webConfigBuilder.webModule = new WebModule(false, null, null, null, "test-war.war", null, null, null);
                 webConfigBuilder.webModule.setContextRoot("test");
-                connectorConfigBuilder.connectorModule = new ConnectorModule("test-rar.rar", null, null, URI.create("test-rar.rar"), null, "test-rar.rar", null, null, null);
+                connectorConfigBuilder.connectorModule = new ConnectorModule(false, null, null, null, "test-rar.rar", null, null, null);
             }
 
             protected void tearDown() {
@@ -106,11 +105,11 @@
         TestSetup setupUnpacked = new TestSetup(inner) {
             protected void setUp() throws Exception {
                 earFile = JarUtil.createJarFile(new File(basedir,  "target/test-unpacked-ear/full/"));
-                ejbConfigBuilder.ejbModule = new EJBModule("test-ejb-jar.jar/", null, null, URI.create("test-ejb-jar.jar/"), null, "test-ejb-jar.jar/", null, null, null);
+                ejbConfigBuilder.ejbModule = new EJBModule(false, null, null, null, "test-ejb-jar.jar/", null, null, null);
                 webConfigBuilder.contextRoot = "test";
-                webConfigBuilder.webModule = new WebModule("test-war.war/", null, null, URI.create("test-war.war/"), null, "test-war.war/", null, null, null);
+                webConfigBuilder.webModule = new WebModule(false, null, null, null, "test-war.war/", null, null, null);
                 webConfigBuilder.webModule.setContextRoot("test");
-                connectorConfigBuilder.connectorModule = new ConnectorModule("test-rar.rar", null, null, URI.create("test-rar.rar"), null, "test-rar.rar", null, null, null);
+                connectorConfigBuilder.connectorModule = new ConnectorModule(false, null, null, null, "test-rar.rar", null, null, null);
             }
 
             protected void tearDown() {
@@ -119,11 +118,11 @@
         TestSetup setupUnpackedNaked = new TestSetup(inner) {
             protected void setUp() throws Exception {
                 earFile = JarUtil.createJarFile(new File(basedir,  "target/test-unpacked-ear/naked/"));
-                ejbConfigBuilder.ejbModule = new EJBModule("test-ejb-jar.jar/", null, null, URI.create("test-ejb-jar.jar/"), null, "test-ejb-jar.jar/", null, null, null);
+                ejbConfigBuilder.ejbModule = new EJBModule(false, null, null, null, "test-ejb-jar.jar/", null, null, null);
                 webConfigBuilder.contextRoot = "test";
-                webConfigBuilder.webModule = new WebModule("test-war.war/", null, null, URI.create("test-war.war/"), null, "test-war.war", null, null, null);
+                webConfigBuilder.webModule = new WebModule(false, null, null, null, "test-war.war", null, null, null);
                 webConfigBuilder.webModule.setContextRoot("test");
-                connectorConfigBuilder.connectorModule = new ConnectorModule("test-rar.rar", null, null, URI.create("test-rar.rar"), null, "test-rar.rar", null, null, null);
+                connectorConfigBuilder.connectorModule = new ConnectorModule(false, null, null, null, "test-rar.rar", null, null, null);
             }
 
             protected void tearDown() {
@@ -132,11 +131,11 @@
         TestSetup setupUnpackedAltDD = new TestSetup(inner) {
             protected void setUp() throws Exception {
                 earFile = JarUtil.createJarFile(new File(basedir,  "target/test-unpacked-ear/alt-dd/"));
-                ejbConfigBuilder.ejbModule = new EJBModule("test-ejb-jar.jar/", null, null, URI.create("test-ejb-jar.jar/"), null, "test-ejb-jar.jar/", null, null, null);
+                ejbConfigBuilder.ejbModule = new EJBModule(false, null, null, null, "test-ejb-jar.jar/", null, null, null);
                 webConfigBuilder.contextRoot = "test";
-                webConfigBuilder.webModule = new WebModule("test-war.war/", null, null, URI.create("test-war.war/"), null, "test-war.war/", null, null, null);
+                webConfigBuilder.webModule = new WebModule(false, null, null, null, "test-war.war/", null, null, null);
                 webConfigBuilder.webModule.setContextRoot("test");
-                connectorConfigBuilder.connectorModule = new ConnectorModule("test-rar.rar", null, null, URI.create("test-rar.rar"), null, "test-rar.rar", null, null, null);
+                connectorConfigBuilder.connectorModule = new ConnectorModule(false, null, null, null, "test-rar.rar", null, null, null);
             }
 
             protected void tearDown() {
@@ -145,11 +144,11 @@
         TestSetup setupPackedAltDD = new TestSetup(inner) {
             protected void setUp() throws Exception {
                 earFile = JarUtil.createJarFile(new File(basedir,  "target/test-unpacked-ear/alt-dd.ear"));
-                ejbConfigBuilder.ejbModule = new EJBModule("test-ejb-jar.jar/", null, null, URI.create("test-ejb-jar.jar/"), null, "test-ejb-jar.jar/", null, null, null);
+                ejbConfigBuilder.ejbModule = new EJBModule(false, null, null, null, "test-ejb-jar.jar/", null, null, null);
                 webConfigBuilder.contextRoot = "test";
-                webConfigBuilder.webModule = new WebModule("test-war.war/", null, null, URI.create("test-war.war/"), null, "test-war.war/", null, null, null);
+                webConfigBuilder.webModule = new WebModule(false, null, null, null, "test-war.war/", null, null, null);
                 webConfigBuilder.webModule.setContextRoot("test");
-                connectorConfigBuilder.connectorModule = new ConnectorModule("test-rar.rar", null, null, URI.create("test-rar.rar"), null, "test-rar.rar", null, null, null);
+                connectorConfigBuilder.connectorModule = new ConnectorModule(false, null, null, null, "test-rar.rar", null, null, null);
             }
 
             protected void tearDown() {

Modified: geronimo/trunk/modules/j2ee/src/test/org/apache/geronimo/j2ee/deployment/MockConnectorConfigBuilder.java
==============================================================================
--- geronimo/trunk/modules/j2ee/src/test/org/apache/geronimo/j2ee/deployment/MockConnectorConfigBuilder.java	(original)
+++ geronimo/trunk/modules/j2ee/src/test/org/apache/geronimo/j2ee/deployment/MockConnectorConfigBuilder.java	Tue Sep 28 11:46:39 2004
@@ -16,8 +16,8 @@
  */
 package org.apache.geronimo.j2ee.deployment;
 
+import java.io.File;
 import java.net.URL;
-import java.net.URI;
 import java.util.jar.JarFile;
 
 import junit.framework.Assert;
@@ -31,8 +31,12 @@
     public Module connectorModule;
     public ClassLoader cl;
 
-    public Module createModule(String name, Object planFile, JarFile moduleFile, URL specDDUrl, String targetPath) throws DeploymentException {
-        return new ConnectorModule(name, null, null, URI.create(targetPath), moduleFile, targetPath, null, null, null);
+    public Module createModule(File plan, JarFile moduleFile) throws DeploymentException {
+        return new ConnectorModule(true, null, null, moduleFile, "connector", null, null, null);
+    }
+
+    public Module createModule(Object plan, JarFile moduleFile, String targetPath, URL specDDUrl) throws DeploymentException {
+        return new ConnectorModule(false, null, null, moduleFile, targetPath, null, null, null);
     }
 
     public void installModule(JarFile earFile, EARContext earContext, Module connectorModule) {
@@ -55,10 +59,11 @@
         this.cl = cl;
     }
 
-    public void addGBeans(EARContext earContext, Module connectorModule, ClassLoader cl) {
+    public String addGBeans(EARContext earContext, Module connectorModule, ClassLoader cl) {
         assertEquals(this.earContext, earContext);
 //        assertEquals(this.connectorModule, connectorModule);
         assertEquals(this.cl, cl);
+        return null;
     }
 
 }

Modified: geronimo/trunk/modules/j2ee/src/test/org/apache/geronimo/j2ee/deployment/MockEJBConfigBuilder.java
==============================================================================
--- geronimo/trunk/modules/j2ee/src/test/org/apache/geronimo/j2ee/deployment/MockEJBConfigBuilder.java	(original)
+++ geronimo/trunk/modules/j2ee/src/test/org/apache/geronimo/j2ee/deployment/MockEJBConfigBuilder.java	Tue Sep 28 11:46:39 2004
@@ -16,8 +16,8 @@
  */
 package org.apache.geronimo.j2ee.deployment;
 
+import java.io.File;
 import java.net.URL;
-import java.net.URI;
 import java.util.jar.JarFile;
 
 import junit.framework.Assert;
@@ -31,8 +31,12 @@
     public EJBModule ejbModule;
     public ClassLoader cl;
 
-    public Module createModule(String name, Object planFile, JarFile moduleFile, URL specDDUrl, String targetPath) throws DeploymentException {
-        return new EJBModule(name, null, null, URI.create(targetPath), moduleFile, targetPath, null, null, null);
+    public Module createModule(File plan, JarFile moduleFile) throws DeploymentException {
+        return new EJBModule(true, null, null, moduleFile, "ejb.jar", null, null, null);
+    }
+
+    public Module createModule(Object plan, JarFile moduleFile, String targetPath, URL specDDUrl) throws DeploymentException {
+        return new EJBModule(false, null, null, moduleFile, targetPath, null, null, null);
     }
 
     public void installModule(JarFile earFile, EARContext earContext, Module ejbModule) {
@@ -55,10 +59,11 @@
         this.cl = cl;
     }
 
-    public void addGBeans(EARContext earContext, Module ejbModule, ClassLoader cl) {
+    public String addGBeans(EARContext earContext, Module ejbModule, ClassLoader cl) {
         assertEquals(this.earContext, earContext);
 //        assertEquals(this.ejbModule, ejbModule);
         assertEquals(this.cl, cl);
+        return null;
     }
 
 }

Modified: geronimo/trunk/modules/j2ee/src/test/org/apache/geronimo/j2ee/deployment/MockWARConfigBuilder.java
==============================================================================
--- geronimo/trunk/modules/j2ee/src/test/org/apache/geronimo/j2ee/deployment/MockWARConfigBuilder.java	(original)
+++ geronimo/trunk/modules/j2ee/src/test/org/apache/geronimo/j2ee/deployment/MockWARConfigBuilder.java	Tue Sep 28 11:46:39 2004
@@ -16,10 +16,12 @@
  */
 package org.apache.geronimo.j2ee.deployment;
 
+import java.io.File;
 import java.net.URL;
-import java.net.URI;
 import java.util.jar.JarFile;
 
+import javax.management.ObjectName;
+
 import junit.framework.Assert;
 import org.apache.geronimo.deployment.DeploymentException;
 
@@ -32,8 +34,12 @@
     public ClassLoader cl;
     public String contextRoot;
 
-    public Module createModule(String name, Object planFile, JarFile moduleFile, URL specDDUrl, String targetPath) throws DeploymentException {
-        return new WebModule(name, null, null, URI.create(targetPath), moduleFile, targetPath, null, null, null);
+    public Module createModule(File plan, JarFile moduleFile) throws DeploymentException {
+        return new WebModule(true, null, null, moduleFile, "war", null, null, null);
+    }
+
+    public Module createModule(Object plan, JarFile moduleFile, String targetPath, URL specDDUrl) throws DeploymentException {
+        return new WebModule(false, null, null, moduleFile, targetPath, null, null, null);
     }
 
     public void installModule(JarFile earFile, EARContext earContext, Module webModule) throws DeploymentException {
@@ -56,12 +62,13 @@
         this.cl = cl;
     }
 
-    public void addGBeans(EARContext earContext, Module webModule, ClassLoader cl) throws DeploymentException {
+    public String addGBeans(EARContext earContext, Module webModule, ClassLoader cl) throws DeploymentException {
         assertEquals(this.earContext, earContext);
 //        assertEquals(this.webModule, webModule);
         assertEquals(this.cl, cl);
         assertNotNull(contextRoot);
         this.contextRoot = ((WebModule) webModule).getContextRoot();
+        return null;
     }
 
 }

Modified: geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java
==============================================================================
--- geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java	(original)
+++ geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java	Tue Sep 28 11:46:39 2004
@@ -85,17 +85,32 @@
 public class JettyModuleBuilder implements ModuleBuilder {
     private static final String PARENT_ID = "org/apache/geronimo/Server";
 
-    public Module createModule(String name, Object plan, JarFile moduleFile, URL webXmlUrl, String targetPath) throws DeploymentException {
+    public Module createModule(File plan, JarFile moduleFile) throws DeploymentException {
+        return createModule(plan, moduleFile, "war", null, true);
+    }
+
+    public Module createModule(Object plan, JarFile moduleFile, String targetPath, URL specDDUrl) throws DeploymentException {
+        return createModule(plan, moduleFile, targetPath, specDDUrl, false);
+    }
+
+    private Module createModule(Object plan, JarFile moduleFile, String targetPath, URL specDDUrl, boolean standAlone) throws DeploymentException {
+        assert moduleFile != null: "moduleFile is null";
+        assert targetPath != null: "targetPath is null";
+        assert !targetPath.endsWith("/"): "targetPath must not end with a '/'";
+
+        // parse the spec dd
         String specDD;
         WebAppType webApp;
         try {
-            if (webXmlUrl == null) {
-                webXmlUrl = JarUtil.createJarURL(moduleFile, "WEB-INF/web.xml");
+            if (specDDUrl == null) {
+                specDDUrl = JarUtil.createJarURL(moduleFile, "WEB-INF/web.xml");
             }
 
-            specDD = IOUtil.readAll(webXmlUrl);
+            // read in the entire specDD as a string, we need this for getDeploymentDescriptor
+            // on the J2ee management object
+            specDD = IOUtil.readAll(specDDUrl);
 
-            // check if we have an alt spec dd
+            // parse it
             WebAppDocument webAppDoc = SchemaConversionUtils.convertToServletSchema(SchemaConversionUtils.parse(specDD));
             webApp = webAppDoc.getWebApp();
         } catch (Exception e) {
@@ -103,7 +118,8 @@
         }
 
 
-        JettyWebAppType jettyWebApp = getJettyWebApp(plan, moduleFile, name, webApp);
+        // parse vendor dd
+        JettyWebAppType jettyWebApp = getJettyWebApp(plan, moduleFile, standAlone, targetPath, webApp);
 
         // get the ids from either the application plan or for a stand alone module from the specific deployer
         URI configId = null;
@@ -122,24 +138,12 @@
             }
         }
 
-        URI moduleURI;
-        if (targetPath != null) {
-            moduleURI = URI.create(targetPath);
-            if (targetPath.endsWith("/")) {
-                throw new DeploymentException("targetPath must not end with a '/'");
-            }
-            targetPath += "/";
-        } else {
-            targetPath = "war/";
-            moduleURI = URI.create("");
-        }
-
-        WebModule module = new WebModule(name, configId, parentId, moduleURI, moduleFile, targetPath, webApp, jettyWebApp, specDD);
+        WebModule module = new WebModule(standAlone, configId, parentId, moduleFile, targetPath, webApp, jettyWebApp, specDD);
         module.setContextRoot(jettyWebApp.getContextRoot());
         return module;
     }
 
-    JettyWebAppType getJettyWebApp(Object plan, JarFile moduleFile, String name, WebAppType webApp) throws DeploymentException {
+    JettyWebAppType getJettyWebApp(Object plan, JarFile moduleFile, boolean standAlone, String targetPath, WebAppType webApp) throws DeploymentException {
         JettyWebAppType jettyWebApp = null;
         try {
             // load the geronimo-jetty.xml from either the supplied plan or from the earFile
@@ -164,12 +168,20 @@
             } catch (IOException e) {
             }
 
-            // if we got one extract the validate it otherwise create a default one
+            // if we got one extract and validate it otherwise create a default one
             if (jettyWebApp != null) {
                 jettyWebApp = (JettyWebAppType) SchemaConversionUtils.convertToGeronimoNamingSchema(jettyWebApp);
                 SchemaConversionUtils.validateDD(jettyWebApp);
             } else {
-                jettyWebApp = createDefaultPlan(name, webApp);
+                String path;
+                if (standAlone) {
+                    // default configId is based on the moduleFile name
+                    path = new File(moduleFile.getName()).getName();
+                } else {
+                    // default configId is based on the module uri from the application.xml
+                    path = targetPath;
+                }
+                jettyWebApp = createDefaultPlan(path, webApp);
             }
         } catch (XmlException e) {
             throw new DeploymentException(e);
@@ -177,10 +189,10 @@
         return jettyWebApp;
     }
 
-    private JettyWebAppType createDefaultPlan(String name, WebAppType webApp) {
+    private JettyWebAppType createDefaultPlan(String path, WebAppType webApp) {
         String id = webApp.getId();
         if (id == null) {
-            id = name;
+            id = path;
             if (id.endsWith(".war")) {
                 id = id.substring(0, id.length() - 4);
             }
@@ -203,7 +215,7 @@
 
     public void installModule(JarFile earFile, EARContext earContext, Module module) throws DeploymentException {
         try {
-            URI targetURI = URI.create(module.getTargetPath());
+            URI targetURI = URI.create(module.getTargetPath() + "/");
 
             // add the warfile's content to the configuration
             JarFile warFile = module.getModuleFile();
@@ -239,7 +251,7 @@
         // web application do not add anything to the shared context
     }
 
-    public void addGBeans(EARContext earContext, Module module, ClassLoader cl) throws DeploymentException {
+    public String addGBeans(EARContext earContext, Module module, ClassLoader cl) throws DeploymentException {
         WebModule webModule = (WebModule) module;
 
         WebAppType webApp = (WebAppType) webModule.getSpecDD();
@@ -259,9 +271,9 @@
         nameProps.put("J2EEApplication", earContext.getJ2EEApplicationName());
         nameProps.put("j2eeType", "WebModule");
         nameProps.put("name", webModule.getName());
-        ObjectName name;
+        ObjectName webModuleName;
         try {
-            name = new ObjectName(earContext.getJ2EEDomainName(), nameProps);
+            webModuleName = new ObjectName(earContext.getJ2EEDomainName(), nameProps);
         } catch (MalformedObjectNameException e) {
             throw new DeploymentException("Unable to construct ObjectName", e);
         }
@@ -279,7 +291,7 @@
                 gbean = new GBeanMBean(JettyWebAppJACCContext.GBEAN_INFO, cl);
             }
 
-            gbean.setAttribute("uri", URI.create(module.getTargetPath()));
+            gbean.setAttribute("uri", URI.create(module.getTargetPath() + "/"));
             gbean.setAttribute("contextPath", webModule.getContextRoot());
             gbean.setAttribute("contextPriorityClassLoader", Boolean.valueOf(jettyWebApp.getContextPriorityClassloader()));
             if (security != null) {
@@ -303,7 +315,8 @@
         } catch (Exception e) {
             throw new DeploymentException("Unable to initialize webapp GBean", e);
         }
-        earContext.addGBean(name, gbean);
+        earContext.addGBean(webModuleName, gbean);
+        return webModuleName.getCanonicalName();
     }
 
     private ReadOnlyContext buildComponentContext(EARContext earContext, WebModule webModule, WebAppType webApp, JettyWebAppType jettyWebApp, UserTransaction userTransaction, ClassLoader cl) throws DeploymentException {

Modified: geronimo/trunk/modules/jetty/src/test/org/apache/geronimo/jetty/deployment/PlanParsingTest.java
==============================================================================
--- geronimo/trunk/modules/jetty/src/test/org/apache/geronimo/jetty/deployment/PlanParsingTest.java	(original)
+++ geronimo/trunk/modules/jetty/src/test/org/apache/geronimo/jetty/deployment/PlanParsingTest.java	Tue Sep 28 11:46:39 2004
@@ -11,14 +11,13 @@
 /**
  */
 public class PlanParsingTest extends TestCase {
-
     private JettyModuleBuilder builder = new JettyModuleBuilder();
-    File basedir = new File(System.getProperty("basedir", "."));
+    private File basedir = new File(System.getProperty("basedir", "."));
 
     public void testResourceRef() throws Exception {
         File resourcePlan = new File(basedir, "src/test-resources/plans/plan1.xml");
         assertTrue(resourcePlan.exists());
-        JettyWebAppType jettyWebApp = builder.getJettyWebApp(resourcePlan, null, null, null);
+        JettyWebAppType jettyWebApp = builder.getJettyWebApp(resourcePlan, null, true, null, null);
         assertEquals(1, jettyWebApp.getResourceRefArray().length);
     }
 

Mime
View raw message