You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by da...@apache.org on 2004/09/19 03:57:18 UTC

svn commit: rev 46308 - in geronimo/trunk/modules: client-builder/src/java/org/apache/geronimo/client/builder deployment/src/java/org/apache/geronimo/deployment deployment/src/java/org/apache/geronimo/deployment/service deployment/src/java/org/apache/geronimo/deployment/util j2ee/src/java/org/apache/geronimo/j2ee/deployment

Author: dain
Date: Sat Sep 18 18:57:18 2004
New Revision: 46308

Modified:
   geronimo/trunk/modules/client-builder/src/java/org/apache/geronimo/client/builder/AppClientModuleBuilder.java
   geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/Bootstrap.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/service/ServiceConfigBuilder.java
   geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/util/UnpackedJarEntry.java
   geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/util/UnpackedJarFile.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/Module.java
Log:
Simplify deployment system before adding app client moduel builder.

Removed stream based deploy method since it was not being used.
Replaced deployment that delt with unpacked deployments directly with UnpackedJarFile.


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	Sat Sep 18 18:57:18 2004
@@ -25,11 +25,8 @@
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.Map;
 import java.util.Properties;
 import java.util.jar.Attributes;
@@ -43,6 +40,7 @@
 import javax.management.ObjectName;
 
 import org.apache.geronimo.client.AppClientContainer;
+import org.apache.geronimo.client.AppClientJNDIProvider;
 import org.apache.geronimo.common.xml.XmlBeansUtil;
 import org.apache.geronimo.deployment.DeploymentContext;
 import org.apache.geronimo.deployment.DeploymentException;
@@ -198,19 +196,13 @@
     public void installModule(File earFolder, EARContext earContext, Module appClientModule) throws DeploymentException {
         File appClientFolder = new File(earFolder, appClientModule.getURI().toString());
 
-        InstallCallback callback;
-        if (appClientFolder.isDirectory()) {
-            callback = new UnPackedInstallCallback(appClientModule, appClientFolder);
-        } else {
-            JarFile appClientFile;
-            try {
-                appClientFile = new JarFile(appClientFolder);
-            } catch (IOException e) {
-                throw new DeploymentException("Can not create application File file " + appClientFolder, e);
-            }
-            callback = new PackedInstallCallback(appClientModule, appClientFile);
+        JarFile appClientFile;
+        try {
+            appClientFile = new JarFile(appClientFolder);
+        } catch (IOException e) {
+            throw new DeploymentException("Can not create application File file " + appClientFolder, e);
         }
-        installModule(callback, earContext, appClientModule);
+        installModule(appClientFile, appClientModule);
     }
 
     public void installModule(JarFile earFile, EARContext earContext, Module appClientModule) throws DeploymentException {
@@ -230,24 +222,30 @@
         } catch (IOException e) {
             throw new DeploymentException("Problem deploying applicaiton client", e);
         }
-        InstallCallback callback = new PackedInstallCallback(appClientModule, appClientFile);
-        installModule(callback, earContext, appClientModule);
+        installModule(appClientFile, appClientModule);
     }
 
-    private void installModule(InstallCallback callback, EARContext earContext, Module appClientModule) throws DeploymentException {
+    private void installModule(JarFile appClientFile, Module appClientModule) throws DeploymentException {
         URI moduleBase;
         if (!appClientModule.getURI().equals(URI.create("/"))) {
             moduleBase = URI.create(appClientModule.getURI() + "/");
         } else {
-            moduleBase = URI.create("war/");
+            moduleBase = URI.create("client/");
         }
         try {
             // load the application-client.xml file
             ApplicationClientType appClient;
             try {
-                // todo what is this install callback stuff
-                InputStream ddInputStream = callback.getWebDD();
-                appClient = getAppClientDocument(ddInputStream).getApplicationClient();
+                // check if we have an alt spec dd
+                InputStream in = appClientModule.openAltSpecDD();
+                if (in == null) {
+                    JarEntry entry = appClientFile.getJarEntry("META-INF/application-client.xml");
+                    if (entry == null) {
+                        throw new DeploymentException("No META-INF/application-client.xml in module [" + appClientModule.getName() + "]");
+                    }
+                    in = appClientFile.getInputStream(entry);
+                }
+                appClient = getAppClientDocument(in).getApplicationClient();
                 appClientModule.setSpecDD(appClient);
             } catch (XmlException e) {
                 throw new DeploymentException("Unable to parse " +
@@ -260,11 +258,17 @@
             GerApplicationClientType geronimoAppClient = (GerApplicationClientType) appClientModule.getVendorDD();
             if (geronimoAppClient == null) {
                 try {
-                    // todo what is this install callback stuff
-                    InputStream geronimoAppClientDDInputStream = callback.getGeronimoJettyDD();
+                    InputStream in = appClientModule.openAltVendorDD();
+                    if (null == in) {
+                        JarEntry entry = appClientFile.getJarEntry("META-INF/geronimo-application-client.xml");
+                        if (entry == null) {
+                            throw new DeploymentException("No META-INF/geronimo-application-client.xml in module [" + appClientModule.getName() + "]");
+                        }
+                        in = appClientFile.getInputStream(entry);
+                    }
                     GerApplicationClientDocument geronimoAppClientDoc;
-                    if (geronimoAppClientDDInputStream != null) {
-                        geronimoAppClientDoc = (GerApplicationClientDocument) XmlBeansUtil.parse(geronimoAppClientDDInputStream, GerApplicationClientDocument.type);
+                    if (in != null) {
+                        geronimoAppClientDoc = (GerApplicationClientDocument) XmlBeansUtil.parse(in, GerApplicationClientDocument.type);
                     } else {
                         geronimoAppClientDoc = newGerApplicationClientDocument(appClient, moduleBase.toString());
                     }
@@ -277,15 +281,6 @@
                             appClientModule.getAltVendorDD().toString()), e);
                 }
             }
-
-            // add the applicationClient's content to the configuration
-            callback.installInEARContext(earContext, moduleBase);
-
-            // add the dependencies declared in the geronimo-jetty.xml file
-            GerDependencyType[] dependencies = geronimoAppClient.getDependencyArray();
-            for (int i = 0; i < dependencies.length; i++) {
-                earContext.addDependency(getDependencyURI(dependencies[i]));
-            }
         } catch (IOException e) {
             throw new DeploymentException("Problem deploying war", e);
         }
@@ -295,8 +290,12 @@
         // application clients do not add anything to the shared context
     }
 
-    public void addGBeans(EARContext earContext, Module module, ClassLoader cl) throws DeploymentException {
+    public void addGBeans(EARContext earContext, Module module, ClassLoader earClassLoader) throws DeploymentException {
         AppClientModule appClientModule = (AppClientModule) module;
+
+        ApplicationClientType appClient = (ApplicationClientType) appClientModule.getSpecDD();
+        GerApplicationClientType geronimoAppClient = (GerApplicationClientType) appClientModule.getVendorDD();
+
         URI appClientModuleLocation;
         if (!appClientModule.getURI().equals(URI.create("/"))) {
             appClientModuleLocation = appClientModule.getURI();
@@ -310,36 +309,36 @@
         nameProps.put("J2EEApplication", earContext.getJ2EEApplicationName());
         nameProps.put("j2eeType", "AppClientModule");
         nameProps.put("name", appClientModule.getName());
-        ObjectName appClientModuleObjectName;
+        ObjectName appClientModuleName;
         try {
-            appClientModuleObjectName = new ObjectName(earContext.getJ2EEDomainName(), nameProps);
+            appClientModuleName = new ObjectName(earContext.getJ2EEDomainName(), nameProps);
         } catch (MalformedObjectNameException e) {
             throw new DeploymentException("Unable to construct ObjectName", e);
         }
 
-        GBeanMBean appClientModuleGBean = new GBeanMBean(J2EEAppClientModuleImpl.GBEAN_INFO, cl);
+        GBeanMBean appClientModuleGBean = new GBeanMBean(J2EEAppClientModuleImpl.GBEAN_INFO, earClassLoader);
         try {
             appClientModuleGBean.setReferencePatterns("J2EEServer", Collections.singleton(earContext.getServerObjectName()));
             if (!earContext.getJ2EEApplicationName().equals("null")) {
                 appClientModuleGBean.setReferencePatterns("J2EEApplication", Collections.singleton(earContext.getApplicationObjectName()));
             }
             appClientModuleGBean.setAttribute("deploymentDescriptor", null);
+
+            ReadOnlyContext componentContext = buildComponentContext(earContext, appClientModule, appClient, geronimoAppClient, earClassLoader);
+            appClientModuleGBean.setAttribute("componentContext", componentContext);
         } catch (Exception e) {
             throw new DeploymentException("Unable to initialize AppClientModule GBean", e);
         }
-        earContext.addGBean(appClientModuleObjectName, appClientModuleGBean);
-
-        // Create a new executable jar within the earcontext
-        ApplicationClientType appClient = (ApplicationClientType) appClientModule.getSpecDD();
-        GerApplicationClientType geronimoAppClient = (GerApplicationClientType) appClientModule.getVendorDD();
+        earContext.addGBean(appClientModuleName, appClientModuleGBean);
 
+        // Create a new executable jar within the ear context
         JarOutputStream earOutputStream = earContext.getJos();
         try {
             Manifest manifest = new Manifest();
             Attributes mainAttributes = manifest.getMainAttributes();
             mainAttributes.putValue(Attributes.Name.MANIFEST_VERSION.toString(), "1.0");
             mainAttributes.putValue(Attributes.Name.MAIN_CLASS.toString(), "org.apache.geronimo.system.main.CommandLine");
-            mainAttributes.putValue(CommandLineManifest.MAIN_GBEAN.toString(), appClientModuleObjectName.getCanonicalName());
+            mainAttributes.putValue(CommandLineManifest.MAIN_GBEAN.toString(), appClientModuleName.getCanonicalName());
             mainAttributes.putValue(CommandLineManifest.MAIN_METHOD.toString(), "deploy");
             mainAttributes.putValue(CommandLineManifest.CONFIGURATIONS.toString(), CONFIG_ID.toString());
 
@@ -387,6 +386,10 @@
                 appClientDeploymentContext.addDependency(getDependencyURI(dependencies[i]));
             }
 
+//            // add the application client jar content to the configuration
+//            callback.installInEARContext(earContext, moduleBase);
+
+
             ClassLoader appClientClassLoader = appClientDeploymentContext.getClassLoader(repository);
 
             if (geronimoAppClient != null) {
@@ -396,17 +399,29 @@
                 }
             }
 
-            ReadOnlyContext componentContext = buildComponentContext(earContext, appClientModule, appClient, geronimoAppClient, appClientClassLoader);
-            GBeanMBean appClienContainerGBean = new GBeanMBean(AppClientContainer.GBEAN_INFO, cl);
+            ObjectName jndiProviderName = ObjectName.getInstance("client:type=JNDIProvider");
+            GBeanMBean jndiProvicerGBean = new GBeanMBean(AppClientJNDIProvider.GBEAN_INFO, earClassLoader);
             try {
-                appClientModuleGBean.setAttribute("componentContext", componentContext);
+                jndiProvicerGBean.setAttribute("host", "localhost");
+                jndiProvicerGBean.setAttribute("port", new Integer(4201));
             } catch (Exception e) {
                 throw new DeploymentException("Unable to initialize AppClientModule GBean", e);
             }
-            appClientDeploymentContext.addGBean(appClientModuleObjectName, appClienContainerGBean);
+            appClientDeploymentContext.addGBean(jndiProviderName, jndiProvicerGBean);
+
+            ObjectName appClienContainerName = ObjectName.getInstance("client:type=ClientContainer");
+            GBeanMBean appClienContainerGBean = new GBeanMBean(AppClientContainer.GBEAN_INFO, earClassLoader);
+            try {
+                appClienContainerGBean.setAttribute("mainClassName", null);
+                appClienContainerGBean.setAttribute("appClientModuleName", appClientModuleName);
+                appClienContainerGBean.setReferencePattern("JNDIProvider", jndiProviderName);
+            } catch (Exception e) {
+                throw new DeploymentException("Unable to initialize AppClientModule GBean", e);
+            }
+            appClientDeploymentContext.addGBean(appClienContainerName, appClienContainerGBean);
 
             appClientDeploymentContext.close();
-        } catch (IOException e) {
+        } catch (Exception e) {
             throw new DeploymentException(e);
         } finally {
             try {
@@ -484,131 +499,51 @@
         return uri;
     }
 
-    private static abstract class InstallCallback {
+    private static final class PackedInstallCallback {
 
-        protected final Module webModule;
-
-        private InstallCallback(Module webModule) {
-            this.webModule = webModule;
-        }
+        private final JarFile appClientFile;
+        private final Module appClientModule;
 
-        public abstract void installInEARContext(EARContext earContext, URI moduleBase) throws DeploymentException, IOException;
-
-        public InputStream getWebDD() throws DeploymentException, IOException {
-            if (null == webModule.getAltSpecDD()) {
-                return null;
-            }
-            return webModule.getAltSpecDD().openStream();
-        }
-
-        public InputStream getGeronimoJettyDD() throws DeploymentException, IOException {
-            if (null == webModule.getAltVendorDD()) {
-                return null;
-            }
-            return webModule.getAltVendorDD().openStream();
-        }
-
-    }
-
-    private static final class UnPackedInstallCallback extends InstallCallback {
-
-        private final File webFolder;
-
-        private UnPackedInstallCallback(Module webModule, File webFolder) {
-            super(webModule);
-            this.webFolder = webFolder;
-        }
-
-        public void installInEARContext(EARContext earContext, URI moduleBase) throws IOException {
-            URI warRoot = webFolder.toURI();
-            // add the warfile's content to the configuration
-            Collection files = new ArrayList();
-            FileUtil.listRecursiveFiles(webFolder, files);
-            for (Iterator iter = files.iterator(); iter.hasNext();) {
-                File file = (File) iter.next();
-                URI fileURI = warRoot.relativize(file.toURI());
-                URI target = moduleBase.resolve(fileURI);
-                // TODO gets rid of these tests when Jetty will use the
-                // serialized Geronimo DD.
-                if (fileURI.equals("WEB-INF/web.xml") &&
-                        null != webModule.getAltSpecDD()) {
-                } else {
-                    earContext.addFile(target, file);
-                }
-            }
-        }
-
-        public InputStream getWebDD() throws DeploymentException, IOException {
-            InputStream in = super.getWebDD();
-            if (null != in) {
-                return in;
-            }
-            File webAppFile = new File(webFolder, "WEB-INF/web.xml");
-            if (!webAppFile.exists()) {
-                throw new DeploymentException("No WEB-INF/web.xml in module [" + webModule.getName() + "]");
-            }
-            return new FileInputStream(webAppFile);
-        }
-
-        public InputStream getGeronimoJettyDD() throws DeploymentException, IOException {
-            InputStream in = super.getGeronimoJettyDD();
-            if (null != in) {
-                return in;
-            }
-            File jettyWebAppFile = new File(webFolder, "WEB-INF/geronimo-jetty.xml");
-            if (jettyWebAppFile.exists()) {
-                return new FileInputStream(jettyWebAppFile);
-            }
-            return null;
-        }
-
-    }
-
-    private static final class PackedInstallCallback extends InstallCallback {
-
-        private final JarFile webAppFile;
 
         private PackedInstallCallback(Module webModule, JarFile webAppFile) {
-            super(webModule);
-            this.webAppFile = webAppFile;
+            this.appClientModule = webModule;
+            this.appClientFile = webAppFile;
         }
 
         public void installInEARContext(EARContext earContext, URI moduleBase) throws IOException {
-            JarInputStream jarIS = new JarInputStream(new FileInputStream(webAppFile.getName()));
+            JarInputStream jarIS = new JarInputStream(new FileInputStream(appClientFile.getName()));
+
             for (JarEntry entry; (entry = jarIS.getNextJarEntry()) != null; jarIS.closeEntry()) {
                 URI target = moduleBase.resolve(entry.getName());
-                // TODO gets rid of these tests when Jetty will use the
-                // serialized Geronimo DD.
-                if (entry.getName().equals("WEB-INF/web.xml") &&
-                        null != webModule.getAltSpecDD()) {
-                } else {
-                    earContext.addFile(target, jarIS);
-                }
+                earContext.addFile(target, jarIS);
             }
         }
 
-        public InputStream getWebDD() throws DeploymentException, IOException {
-            InputStream in = super.getWebDD();
-            if (null != in) {
+        public InputStream openSpecDD() throws DeploymentException, IOException {
+            // check if we have an alt spec dd
+            InputStream in = appClientModule.openAltSpecDD();
+            if (in != null) {
                 return in;
             }
-            JarEntry entry = webAppFile.getJarEntry("WEB-INF/web.xml");
+
+            JarEntry entry = appClientFile.getJarEntry("META-INF/application-client.xml");
             if (entry == null) {
-                throw new DeploymentException("No WEB-INF/web.xml in module [" + webModule.getName() + "]");
+                throw new DeploymentException("No META-INF/application-client.xml in module [" + appClientModule.getName() + "]");
             }
-            return webAppFile.getInputStream(entry);
+            return appClientFile.getInputStream(entry);
         }
 
-        public InputStream getGeronimoJettyDD() throws DeploymentException, IOException {
-            InputStream in = super.getGeronimoJettyDD();
+        public InputStream openVendoDD() throws DeploymentException, IOException {
+            InputStream in = appClientModule.openAltVendorDD();
             if (null != in) {
                 return in;
             }
-            JarEntry entry = webAppFile.getJarEntry("WEB-INF/geronimo-jetty.xml");
-            if (entry != null) {
-                return webAppFile.getInputStream(entry);
+
+            JarEntry entry = appClientFile.getJarEntry("META-INF/geronimo-application-client.xml");
+            if (entry == null) {
+                throw new DeploymentException("No META-INF/geronimo-application-client.xml in module [" + appClientModule.getName() + "]");
             }
-            return null;
+            return appClientFile.getInputStream(entry);
         }
     }
 

Modified: geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/Bootstrap.java
==============================================================================
--- geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/Bootstrap.java	(original)
+++ geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/Bootstrap.java	Sat Sep 18 18:57:18 2004
@@ -20,7 +20,6 @@
 import java.io.BufferedOutputStream;
 import java.io.File;
 import java.io.FileOutputStream;
-import java.io.InputStream;
 import java.util.jar.Attributes;
 import java.util.jar.JarOutputStream;
 import java.util.jar.Manifest;
@@ -160,7 +159,7 @@
             // build and install the j2ee-deployer configuration
             File tempFile = File.createTempFile("j2ee-deployer", ".car");
             try {
-                builder.buildConfiguration(tempFile, manifest, (InputStream)null, j2eeDeployerXML);
+                builder.buildConfiguration(tempFile, manifest, null, j2eeDeployerXML);
                 configStore.install(tempFile.toURL());
             } finally {
                 tempFile.delete();

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	Sat Sep 18 18:57:18 2004
@@ -19,8 +19,8 @@
 
 import java.io.File;
 import java.io.IOException;
-import java.io.InputStream;
 import java.net.URL;
+import java.util.jar.Manifest;
 
 import org.apache.xmlbeans.SchemaTypeLoader;
 import org.apache.xmlbeans.XmlException;
@@ -57,15 +57,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, java.util.jar.Manifest manifest, File module, XmlObject plan) throws IOException, DeploymentException;
-
-    /**
-     * Build a configuration from an arbitrary input stream
-     * @param outfile the file to write the configuration to
-     * @param module the module to build
-     * @param plan the deployment plan
-     * @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, java.util.jar.Manifest manifest, InputStream module, XmlObject plan) throws IOException, DeploymentException;
+    void buildConfiguration(File outfile, Manifest manifest, File module, XmlObject plan) 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	Sat Sep 18 18:57:18 2004
@@ -44,6 +44,7 @@
 import org.apache.geronimo.gbean.GBeanInfoFactory;
 import org.apache.geronimo.kernel.config.ConfigurationStore;
 import org.apache.geronimo.kernel.config.InvalidConfigException;
+import org.apache.geronimo.deployment.util.FileUtil;
 import org.apache.xmlbeans.SchemaTypeLoader;
 import org.apache.xmlbeans.XmlBeans;
 import org.apache.xmlbeans.XmlObject;
@@ -192,16 +193,17 @@
 
         try {
             if (cmd.module == null) {
-                builder.buildConfiguration(cmd.carfile, manifest, (InputStream) null, plan);
+                builder.buildConfiguration(cmd.carfile, manifest, null, plan);
             } else if ("file".equals(cmd.module.getProtocol())) {
                 File module = new File(new URI(cmd.module.toString()));
                 builder.buildConfiguration(cmd.carfile, manifest, module, plan);
             } else if (cmd.module.toString().endsWith("/")) {
                 throw new DeploymentException("Unpacked modules must be files");
             } else {
+                File tempFile;
                 InputStream moduleStream = cmd.module.openStream();
                 try {
-                    builder.buildConfiguration(cmd.carfile, manifest, moduleStream, plan);
+                    tempFile = FileUtil.toTempFile(moduleStream);
                 } finally {
                     try {
                         moduleStream.close();
@@ -209,6 +211,7 @@
                         // ignore
                     }
                 }
+                builder.buildConfiguration(cmd.carfile, manifest, tempFile, plan);
             }
 
             try {

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	Sat Sep 18 18:57:18 2004
@@ -78,11 +78,7 @@
         return null;
     }
 
-    public void buildConfiguration(File outfile, Manifest manifest, File module, XmlObject plan) throws IOException, DeploymentException {
-        buildConfiguration(outfile, manifest, (InputStream) null, plan);
-    }
-
-    public void buildConfiguration(File outfile, Manifest manifest, InputStream ignored, XmlObject plan) throws IOException, DeploymentException {
+    public void buildConfiguration(File outfile, Manifest manifest, File unused, XmlObject plan) throws IOException, DeploymentException {
         FileOutputStream fos = new FileOutputStream(outfile);
         try {
             JarOutputStream os = new JarOutputStream(new BufferedOutputStream(fos), manifest);

Modified: geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/util/UnpackedJarEntry.java
==============================================================================
--- geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/util/UnpackedJarEntry.java	(original)
+++ geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/util/UnpackedJarEntry.java	Sat Sep 18 18:57:18 2004
@@ -25,7 +25,7 @@
 import java.security.cert.Certificate;
 
 /**
- * @version $Revision$ $Date$
+ * @version $Rev$ $Date$
  */
 public class UnpackedJarEntry extends JarEntry {
     private final File file;

Modified: geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/util/UnpackedJarFile.java
==============================================================================
--- geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/util/UnpackedJarFile.java	(original)
+++ geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/util/UnpackedJarFile.java	Sat Sep 18 18:57:18 2004
@@ -34,7 +34,7 @@
 import java.net.URI;
 
 /**
- * @version $Revision$ $Date$
+ * @version $Rev$ $Date$
  */
 public class UnpackedJarFile extends JarFile {
     private static final File dummyJarFile;
@@ -64,6 +64,10 @@
         }
     }
 
+    public File getBaseDir() {
+        return baseDir;
+    }
+
     public Manifest getManifest() throws IOException {
         if (manifestLoaded) {
             File manifestFile = getFile("META-INF/MANIFEST.MF");
@@ -88,7 +92,7 @@
         return manifest;
     }
 
-    public JarEntry getJarEntry(String name) {
+    public UnpackedJarEntry getUnpackedJarEntry(String name) {
         File file = getFile(name);
         if (file == null) {
             return null;
@@ -96,8 +100,12 @@
         return new UnpackedJarEntry(name, file, getManifestSafe());
     }
 
+    public JarEntry getJarEntry(String name) {
+        return getUnpackedJarEntry(name);
+    }
+
     public ZipEntry getEntry(String name) {
-        return getJarEntry(name);
+        return getUnpackedJarEntry(name);
     }
 
     public Enumeration entries() {

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	Sat Sep 18 18:57:18 2004
@@ -18,7 +18,6 @@
 
 import java.io.BufferedOutputStream;
 import java.io.File;
-import java.io.FileInputStream;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
@@ -27,7 +26,6 @@
 import java.net.URISyntaxException;
 import java.net.URL;
 import java.util.ArrayList;
-import java.util.Collection;
 import java.util.Collections;
 import java.util.Enumeration;
 import java.util.HashMap;
@@ -49,7 +47,7 @@
 import org.apache.geronimo.deployment.ConfigurationBuilder;
 import org.apache.geronimo.deployment.DeploymentException;
 import org.apache.geronimo.deployment.service.GBeanHelper;
-import org.apache.geronimo.deployment.util.FileUtil;
+import org.apache.geronimo.deployment.util.UnpackedJarFile;
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoFactory;
 import org.apache.geronimo.gbean.jmx.GBeanMBean;
@@ -146,14 +144,13 @@
         return (SchemaTypeLoader[]) typeLoaders.toArray(new SchemaTypeLoader[typeLoaders.size()]);
     }
 
-    public XmlObject getDeploymentPlan(URL module) throws XmlException {
-
+    public XmlObject getDeploymentPlan(URL deploymentURL) throws XmlException {
         try {
             URL moduleBase;
-            if (module.toString().endsWith("/")) {
-                moduleBase = module;
+            if (deploymentURL.toString().endsWith("/")) {
+                moduleBase = deploymentURL;
             } else {
-                moduleBase = new URL("jar:" + module.toString() + "!/");
+                moduleBase = new URL("jar:" + deploymentURL.toString() + "!/");
             }
             GerApplicationDocument gerAppDoc = (GerApplicationDocument) XmlBeansUtil.getXmlObject(new URL(moduleBase, "META-INF/geronimo-application.xml"), GerApplicationDocument.type);
             if (gerAppDoc != null) {
@@ -170,21 +167,21 @@
 
         // support a naked modules
         if (webConfigBuilder != null) {
-            XmlObject plan = webConfigBuilder.getDeploymentPlan(module);
+            XmlObject plan = webConfigBuilder.getDeploymentPlan(deploymentURL);
             if (plan != null) {
                 return plan;
             }
         }
 
         if (ejbConfigBuilder != null) {
-            XmlObject plan = ejbConfigBuilder.getDeploymentPlan(module);
+            XmlObject plan = ejbConfigBuilder.getDeploymentPlan(deploymentURL);
             if (plan != null) {
                 return plan;
             }
         }
 
         if (connectorConfigBuilder != null) {
-            XmlObject plan = connectorConfigBuilder.getDeploymentPlan(module);
+            XmlObject plan = connectorConfigBuilder.getDeploymentPlan(deploymentURL);
             if (plan != null) {
                 return plan;
             }
@@ -193,11 +190,11 @@
         return null;
     }
 
-    private GerApplicationDocument createDefaultPlan(URL moduleBase) throws XmlException {
+    private GerApplicationDocument createDefaultPlan(URL deploymentURL) throws XmlException {
         // load the web.xml
         URL applicationXmlUrl = null;
         try {
-            applicationXmlUrl = new URL(moduleBase, "META-INF/application.xml");
+            applicationXmlUrl = new URL(deploymentURL, "META-INF/application.xml");
         } catch (MalformedURLException e) {
             return null;
         }
@@ -222,14 +219,14 @@
         gerApplication.setParentId(PARENT_ID);
         String id = applicationDoc.getApplication().getId();
         if (id == null) {
-            id = moduleBase.getFile();
+            id = deploymentURL.getFile();
             if (id.endsWith("!/")) {
                 id = id.substring(0, id.length() - 2);
             }
             if (id.endsWith(".ear")) {
                 id = id.substring(0, id.length() - 4);
             }
-            if ( id.endsWith("/") ) {
+            if (id.endsWith("/")) {
                 id = id.substring(0, id.length() - 1);
             }
             id = id.substring(id.lastIndexOf('/') + 1);
@@ -239,120 +236,14 @@
         return gerApplicationDocument;
     }
 
-    public void buildConfiguration(File outfile, Manifest manifest, InputStream is, XmlObject plan) throws IOException, DeploymentException {
-        File tmp = FileUtil.toTempFile(is);
-        buildConfiguration(outfile, manifest, new JarFile(tmp), plan);
-    }
-
     public void buildConfiguration(File outfile, Manifest manifest, final File earFolder, final XmlObject plan) throws IOException, DeploymentException {
-        if (!earFolder.isDirectory()) {
-            buildConfiguration(outfile, manifest, new JarFile(earFolder), plan);
-            return;
-        }
-        BuildConfigurationCallback callback = new BuildConfigurationCallback() {
-            public ApplicationType addModules(URI configID, Set moduleLocations, Set modules) throws IOException, DeploymentException {
-                ApplicationTypeLocator locator = new ApplicationTypeLocator() {
-                    public InputStream getApplication() throws DeploymentException, IOException {
-                        File appXMLFile = new File(earFolder, "META-INF/application.xml");
-                        if (!appXMLFile.isFile()) {
-                            throw new DeploymentException("Did not find META-INF/application.xml in earFile");
-                        }
-                        return new FileInputStream(appXMLFile);
-                    }
-                    public URL toURL(String uri) throws DeploymentException {
-                        try {
-                            return new File(earFolder, uri).toURL();
-                        } catch (MalformedURLException e) {
-                            throw new DeploymentException("Can not create URL", e);
-                        }
-                    }
-                };
-                return EARConfigBuilder.this.addModules(configID, plan, locator, moduleLocations, modules);
-            }
-
-            public void copyOverContent(EARContext earContext, Set moduleLocations) throws IOException {
-                URI baseURI = earFolder.toURI();
-                Collection files = new ArrayList();
-                FileUtil.listRecursiveFiles(earFolder, files);
-                for (Iterator iter = files.iterator(); iter.hasNext();) {
-                    File file = (File) iter.next();
-                    URI path = baseURI.relativize(file.toURI());
-                    boolean isNestedModuleFile = false;
-                    // skips the files contained by a nested module.
-                    for (Iterator iter2 = moduleLocations.iterator(); iter2.hasNext();) {
-                        String moduleLocation = (String) iter2.next();
-                        if ( path.toString().startsWith(moduleLocation) ) {
-                            isNestedModuleFile = true;
-                            break;
-                        }
-                    }
-                    if ( isNestedModuleFile ) {
-                        continue;
-                    }
-                    earContext.addFile(path, file);
-                }
-            }
-
-            public void installModule(ModuleBuilder moduleBuilder, EARContext earContext, Module module) throws IOException, DeploymentException {
-                moduleBuilder.installModule(earFolder, earContext, module);
-            }
-
-            public void release() {
-            }
-        };
-        buildConfiguration(outfile, manifest, callback, plan);
-    }
-
-    public void buildConfiguration(File outfile, Manifest manifest, final JarFile earFile, final XmlObject plan) throws IOException, DeploymentException {
-        BuildConfigurationCallback callback = new BuildConfigurationCallback() {
-            public ApplicationType addModules(URI configID, Set moduleLocations, Set modules) throws IOException, DeploymentException {
-                ApplicationTypeLocator locator = new ApplicationTypeLocator() {
-                    public InputStream getApplication() throws DeploymentException, IOException {
-                        JarEntry appXMLEntry = earFile.getJarEntry("META-INF/application.xml");
-                        if (appXMLEntry == null) {
-                            throw new DeploymentException("Did not find META-INF/application.xml in earFile");
-                        }
-                        return earFile.getInputStream(appXMLEntry);
-                    }
-                    public URL toURL(String uri) throws DeploymentException {
-                        try {
-                            String urlString = "jar:" + new File(earFile.getName()).toURL() + "!/" + uri;
-                            return new URL(urlString);
-                        } catch (MalformedURLException e) {
-                            throw new DeploymentException("Can not create URL", e);
-                        }
-                    }
-                };
-                return EARConfigBuilder.this.addModules(configID, plan, locator, moduleLocations, modules);
-            }
-
-            public void copyOverContent(EARContext earContext, Set moduleLocations) throws IOException {
-                for (Enumeration e = earFile.entries(); e.hasMoreElements();) {
-                    ZipEntry entry = (ZipEntry) e.nextElement();
-                    if (!moduleLocations.contains(entry.getName())) {
-                        earContext.addFile(URI.create(entry.getName()), earFile.getInputStream(entry));
-                    }
-                }
-            }
-
-            public void installModule(ModuleBuilder moduleBuilder, EARContext earContext, Module module) throws DeploymentException {
-                moduleBuilder.installModule(earFile, earContext, module);
-            }
-
-            public void release() {
-                if (null != earFile) {
-                    try {
-                        earFile.close();
-                    } catch (IOException e) {
-                    }
-                }
-            }
-        };
-        buildConfiguration(outfile, manifest, callback, plan);
-    }
+        JarFile earFile = null;
+        if (earFolder.isDirectory()) {
+            earFile = new UnpackedJarFile(earFolder);
+        } else {
+            earFile = new JarFile(earFolder);
+        }
 
-    //TODO use the manifest
-    private void buildConfiguration(File outfile, Manifest manifest, BuildConfigurationCallback callback, XmlObject plan) throws IOException, DeploymentException {
         FileOutputStream fos = new FileOutputStream(outfile);
         try {
             // get the ids from either the application plan or for a stand alone module from the specific deployer
@@ -363,7 +254,7 @@
             // get the modules either the application plan or for a stand alone module from the specific deployer
             Set moduleLocations = new HashSet();
             Set modules = new LinkedHashSet();
-            ApplicationType application = callback.addModules(configId, moduleLocations, modules);
+            ApplicationType application = addModules(earFile, plan, configId, moduleLocations, modules);
             // if this is an ear, the application name is the configId; otherwise application name is "null"
             String applicationName;
             if (application != null) {
@@ -394,7 +285,12 @@
 
             // Copy over all files that are _NOT_ modules
             if (application != null) {
-                callback.copyOverContent(earContext, moduleLocations);
+                for (Enumeration e = earFile.entries(); e.hasMoreElements();) {
+                    ZipEntry entry = (ZipEntry) e.nextElement();
+                    if (!moduleLocations.contains(entry.getName())) {
+                        earContext.addFile(URI.create(entry.getName()), earFile.getInputStream(entry));
+                    }
+                }
             }
 
             // add dependencies declared in the geronimo-application.xml
@@ -410,7 +306,7 @@
             // each module installs it's files into the output context.. this is differenct for each module type
             for (Iterator iterator = modules.iterator(); iterator.hasNext();) {
                 Module module = (Module) iterator.next();
-                callback.installModule(getBuilder(module), earContext, module);
+                getBuilder(module).installModule(earFile, earContext, module);
             }
 
             // give each module a chance to populate the earContext now that a classloader is available
@@ -441,6 +337,7 @@
                 gbean.setReferencePatterns("j2eeServer", Collections.singleton(j2eeServer));
                 earContext.addGBean(earContext.getApplicationObjectName(), gbean);
             }
+
             // each module can now add it's GBeans
             for (Iterator iterator = modules.iterator(); iterator.hasNext();) {
                 Module module = (Module) iterator.next();
@@ -450,16 +347,25 @@
             earContext.close();
             os.flush();
         } finally {
-            callback.release();
+            if (earFile != null) {
+                try {
+                    earFile.close();
+                } catch (IOException ignored) {
+                }
+            }
             fos.close();
         }
     }
 
-    private ApplicationType addModules(URI configId, XmlObject plan, ApplicationTypeLocator appLocator, Set moduleLocations, Set modules) throws DeploymentException, IOException {
+    private ApplicationType addModules(final JarFile earFile, XmlObject plan, URI configId, Set moduleLocations, Set modules) throws IOException, DeploymentException {
         ApplicationType application;
         if (plan instanceof GerApplicationDocument) {
             try {
-                InputStream ddInputStream = appLocator.getApplication();
+                JarEntry appXMLEntry = earFile.getJarEntry("META-INF/application.xml");
+                if (appXMLEntry == null) {
+                    throw new DeploymentException("Did not find META-INF/application.xml in earFile");
+                }
+                InputStream ddInputStream = earFile.getInputStream(appXMLEntry);
                 application = getApplicationDocument(ddInputStream).getApplication();
             } catch (XmlException e) {
                 throw new DeploymentException("Unable to parse application.xml", e);
@@ -504,34 +410,32 @@
                     connectorModules.add(currentModule);
                 }
                 // TODO remove test against null when application clients will be supported.
-                if ( null != currentModule ) {
+                if (null != currentModule) {
                     moduleMap.put(currentModule.getName(), currentModule);
-                    if ( module.isSetAltDd() ) {
-                        URL altDDURL = appLocator.toURL(module.getAltDd().getStringValue());
-                        currentModule.setAltSpecDD(altDDURL);
+                    if (module.isSetAltDd()) {
+                        currentModule.setAltSpecDD(createJarURL(earFile, module.getAltDd().getStringValue()));
                     }
                 }
             }
-            
+
             GerApplicationDocument gerApplication = (GerApplicationDocument) plan;
             GerModuleType gerModuleTypes[] = gerApplication.getApplication().getModuleArray();
             for (int i = 0; i < gerModuleTypes.length; i++) {
                 GerModuleType gerModuleType = gerModuleTypes[i];
                 Module currentModule = null;
-                if ( gerModuleType.isSetEjb() ) {
+                if (gerModuleType.isSetEjb()) {
                     currentModule = (Module) moduleMap.get(gerModuleType.getEjb().getStringValue());
-                } else if ( gerModuleType.isSetWeb() ) {
+                } else if (gerModuleType.isSetWeb()) {
                     currentModule = (Module) moduleMap.get(gerModuleType.getWeb().getStringValue());
-                } else if ( gerModuleType.isSetConnector() ) {
+                } else if (gerModuleType.isSetConnector()) {
                     currentModule = (Module) moduleMap.get(gerModuleType.getConnector().getStringValue());
                 }
                 // TODO remove test against null when application clients will be supported.
-                if ( gerModuleType.isSetAltDd() && null != currentModule ) {
-                    URL altDDURL = appLocator.toURL(gerModuleType.getAltDd().getStringValue());
-                    currentModule.setAltVendorDD(altDDURL);
+                if (gerModuleType.isSetAltDd() && null != currentModule) {
+                    currentModule.setAltVendorDD(createJarURL(earFile, gerModuleType.getAltDd().getStringValue()));
                 }
             }
-            
+
             modules.addAll(connectorModules);
             modules.addAll(ejbModules);
             modules.addAll(webModules);
@@ -550,6 +454,20 @@
         return application;
     }
 
+    private static URL createJarURL(JarFile jarFile, String path) throws DeploymentException {
+        try {
+            if (jarFile instanceof UnpackedJarFile) {
+                File baseDir = ((UnpackedJarFile) jarFile).getBaseDir();
+                return new File(baseDir, path).toURL();
+            } else {
+                String urlString = "jar:" + new File(jarFile.getName()).toURL() + "!/" + path;
+                return new URL(urlString);
+            }
+        } catch (MalformedURLException e) {
+            throw new DeploymentException("Can not create URL", e);
+        }
+    }
+
     private ModuleBuilder getBuilder(Module module) {
         if (module instanceof EJBModule) {
             return ejbConfigBuilder;
@@ -684,25 +602,6 @@
             }
         }
         return uri;
-    }
-
-    private interface BuildConfigurationCallback {
-
-        public ApplicationType addModules(URI configID, Set moduleLocations, Set modules) throws IOException, DeploymentException;
-
-        public void copyOverContent(EARContext earContext, Set moduleLocations) throws IOException, DeploymentException;
-
-        public void installModule(ModuleBuilder moduleBuilder, EARContext earContext, Module module) throws IOException, DeploymentException;
-
-        public void release();
-    }
-
-    private interface ApplicationTypeLocator {
-
-        public InputStream getApplication() throws DeploymentException, IOException;
-
-        public URL toURL(String uri) throws DeploymentException;
-        
     }
 
     public static final GBeanInfo GBEAN_INFO;

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	Sat Sep 18 18:57:18 2004
@@ -18,6 +18,8 @@
 
 import java.net.URI;
 import java.net.URL;
+import java.io.InputStream;
+import java.io.IOException;
 
 import org.apache.xmlbeans.XmlObject;
 
@@ -49,7 +51,11 @@
     public URL getAltSpecDD() {
         return altSpecDD;
     }
-    
+
+    public InputStream openAltSpecDD() throws IOException {
+        return openURL(altSpecDD);
+    }
+
     public void setAltSpecDD(URL altSpecDD) {
         this.altSpecDD = altSpecDD;
     }
@@ -66,6 +72,10 @@
         return altVendorDD;
     }
     
+    public InputStream openAltVendorDD() throws IOException {
+        return openURL(altVendorDD);
+    }
+
     public void setAltVendorDD(URL altVendorDD) {
         this.altVendorDD = altVendorDD;
     }
@@ -93,4 +103,13 @@
         return false;
     }
     
+    private InputStream openURL(URL url) throws IOException {
+        if (url != null) {
+            InputStream in = url.openStream();
+            if (in != null) {
+                return in;
+            }
+        }
+        return null;
+    }
 }