geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gdam...@apache.org
Subject svn commit: r394960 - in /geronimo/branches/1.1/modules: deployment/src/java/org/apache/geronimo/deployment/ deployment/src/java/org/apache/geronimo/deployment/util/ j2ee-builder/src/java/org/apache/geronimo/j2ee/deployment/ web-builder/src/java/org/ap...
Date Tue, 18 Apr 2006 15:02:56 GMT
Author: gdamour
Date: Tue Apr 18 08:02:36 2006
New Revision: 394960

URL: http://svn.apache.org/viewcvs?rev=394960&view=rev
Log:
When an EAR is deployed in-place, packed WAR and RAR defined are automatically unpacked. This
is a requirement for these modules (Jetty and Tomcat
expect a WAR module unpacked and RAR have nested JAR within them).

I think that in-place deployment is now complete.

Modified:
    geronimo/branches/1.1/modules/deployment/src/java/org/apache/geronimo/deployment/CopyResourceContext.java
    geronimo/branches/1.1/modules/deployment/src/java/org/apache/geronimo/deployment/DeploymentContext.java
    geronimo/branches/1.1/modules/deployment/src/java/org/apache/geronimo/deployment/InPlaceResourceContext.java
    geronimo/branches/1.1/modules/deployment/src/java/org/apache/geronimo/deployment/ResourceContext.java
    geronimo/branches/1.1/modules/deployment/src/java/org/apache/geronimo/deployment/util/DeploymentUtil.java
    geronimo/branches/1.1/modules/deployment/src/java/org/apache/geronimo/deployment/util/NestedJarFile.java
    geronimo/branches/1.1/modules/j2ee-builder/src/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilder.java
    geronimo/branches/1.1/modules/web-builder/src/java/org/apache/geronimo/web/deployment/AbstractWebModuleBuilder.java

Modified: geronimo/branches/1.1/modules/deployment/src/java/org/apache/geronimo/deployment/CopyResourceContext.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/deployment/src/java/org/apache/geronimo/deployment/CopyResourceContext.java?rev=394960&r1=394959&r2=394960&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/deployment/src/java/org/apache/geronimo/deployment/CopyResourceContext.java
(original)
+++ geronimo/branches/1.1/modules/deployment/src/java/org/apache/geronimo/deployment/CopyResourceContext.java
Tue Apr 18 08:02:36 2006
@@ -151,6 +151,9 @@
         return new File(baseUri.resolve(targetPath));
     }
 
+    public void flush() throws IOException {
+    }
+    
     private void addFile(File targetFile, ZipFile zipFile, ZipEntry zipEntry) throws IOException
{
         if (zipEntry.isDirectory()) {
             targetFile.mkdirs();

Modified: geronimo/branches/1.1/modules/deployment/src/java/org/apache/geronimo/deployment/DeploymentContext.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/deployment/src/java/org/apache/geronimo/deployment/DeploymentContext.java?rev=394960&r1=394959&r2=394960&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/deployment/src/java/org/apache/geronimo/deployment/DeploymentContext.java
(original)
+++ geronimo/branches/1.1/modules/deployment/src/java/org/apache/geronimo/deployment/DeploymentContext.java
Tue Apr 18 08:02:36 2006
@@ -396,6 +396,10 @@
         return configuration;
     }
 
+    public void flush() throws IOException{
+        resourceContext.flush();
+    }
+
     public void close() throws IOException, DeploymentException {
         if (configurationManager != null) {
             try {

Modified: geronimo/branches/1.1/modules/deployment/src/java/org/apache/geronimo/deployment/InPlaceResourceContext.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/deployment/src/java/org/apache/geronimo/deployment/InPlaceResourceContext.java?rev=394960&r1=394959&r2=394960&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/deployment/src/java/org/apache/geronimo/deployment/InPlaceResourceContext.java
(original)
+++ geronimo/branches/1.1/modules/deployment/src/java/org/apache/geronimo/deployment/InPlaceResourceContext.java
Tue Apr 18 08:02:36 2006
@@ -19,17 +19,26 @@
 import java.io.File;
 import java.io.IOException;
 import java.net.URI;
+import java.net.URISyntaxException;
 import java.net.URL;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
 import java.util.jar.JarFile;
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipFile;
 
 import org.apache.geronimo.common.DeploymentException;
+import org.apache.geronimo.deployment.util.DeploymentUtil;
+import org.apache.geronimo.deployment.util.NestedJarFile;
 import org.apache.geronimo.kernel.config.Configuration;
 
 class InPlaceResourceContext implements ResourceContext {
+    private static final String PACKED_MODULED_SAVED_SUFFIX = ".saved";
+    
     private final Configuration configuration;
     private final URI inPlaceBaseConfigurationUri;
+    private final Set zipFilesToExpand = new HashSet();
     
     public InPlaceResourceContext(Configuration configuration, File inPlaceBaseConfigurationDir)
throws DeploymentException {
         this.configuration = configuration;
@@ -49,6 +58,13 @@
     }
 
     public void addInclude(URI targetPath, ZipFile zipFile, ZipEntry zipEntry) throws IOException
{
+        if (zipFile instanceof NestedJarFile) {
+            NestedJarFile nestedJarFile = (NestedJarFile) zipFile;
+            if (nestedJarFile.isPacked()) {
+                zipFilesToExpand.add(zipFile);
+            }
+        }
+        
         configuration.addToClassPath(targetPath.toString());
     }
 
@@ -61,6 +77,12 @@
     }
 
     public void addFile(URI targetPath, ZipFile zipFile, ZipEntry zipEntry) throws IOException
{
+        if (zipFile instanceof NestedJarFile) {
+            NestedJarFile nestedJarFile = (NestedJarFile) zipFile;
+            if (nestedJarFile.isPacked()) {
+                zipFilesToExpand.add(zipFile);
+            }
+        }
     }
 
     public void addFile(URI targetPath, URL source) throws IOException {
@@ -78,4 +100,33 @@
         if (targetPath.isOpaque()) throw new IllegalArgumentException("targetPath is opaque");
         return new File(inPlaceBaseConfigurationUri.resolve(targetPath));
     }
+    
+    public void flush() throws IOException {
+        for (Iterator iter = zipFilesToExpand.iterator(); iter.hasNext();) {
+            ZipFile zipFile = (ZipFile) iter.next();
+            String name = zipFile.getName();
+            zipFile.close();
+            File srcFile = new File(name);
+            File targetFile;
+            if (!srcFile.isAbsolute()) {
+                srcFile = new File(inPlaceBaseConfigurationUri.resolve(name));
+                try {
+                    targetFile = getTargetFile(new URI(name + PACKED_MODULED_SAVED_SUFFIX));
+                } catch (URISyntaxException e) {
+                    throw new AssertionError(e);
+                }
+            } else {
+                targetFile = new File(name + PACKED_MODULED_SAVED_SUFFIX);              
 
+            }
+            boolean success = new File(name).renameTo(targetFile);
+            if (!success) {
+                throw new IOException("Cannot rename file " + 
+                        name + " to " + targetFile.getAbsolutePath());
+            }
+            
+            DeploymentUtil.unzipToDirectory(new ZipFile(targetFile), srcFile);
+        }
+    }
+    
+    
 }

Modified: geronimo/branches/1.1/modules/deployment/src/java/org/apache/geronimo/deployment/ResourceContext.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/deployment/src/java/org/apache/geronimo/deployment/ResourceContext.java?rev=394960&r1=394959&r2=394960&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/deployment/src/java/org/apache/geronimo/deployment/ResourceContext.java
(original)
+++ geronimo/branches/1.1/modules/deployment/src/java/org/apache/geronimo/deployment/ResourceContext.java
Tue Apr 18 08:02:36 2006
@@ -42,4 +42,6 @@
     void addFile(URI targetPath, String source) throws IOException;
     
     File getTargetFile(URI targetPath);
+    
+    void flush() throws IOException;
 }

Modified: geronimo/branches/1.1/modules/deployment/src/java/org/apache/geronimo/deployment/util/DeploymentUtil.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/deployment/src/java/org/apache/geronimo/deployment/util/DeploymentUtil.java?rev=394960&r1=394959&r2=394960&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/deployment/src/java/org/apache/geronimo/deployment/util/DeploymentUtil.java
(original)
+++ geronimo/branches/1.1/modules/deployment/src/java/org/apache/geronimo/deployment/util/DeploymentUtil.java
Tue Apr 18 08:02:36 2006
@@ -16,6 +16,7 @@
  */
 package org.apache.geronimo.deployment.util;
 
+import java.io.BufferedOutputStream;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
@@ -35,6 +36,7 @@
 import java.util.jar.JarOutputStream;
 import java.util.jar.Manifest;
 import java.util.zip.ZipEntry;
+import java.util.zip.ZipFile;
 
 /**
  * @version $Rev$ $Date$
@@ -241,6 +243,40 @@
         }
     }
 
+    public static void unzipToDirectory(ZipFile zipFile, File destDir) throws IOException
{
+        Enumeration entries = zipFile.entries();
+        try {
+            while (entries.hasMoreElements()) {
+                ZipEntry entry = (ZipEntry) entries.nextElement();
+                if (entry.isDirectory()) {
+                    File dir = new File(destDir, entry.getName());
+                    boolean success = dir.mkdirs();
+                    if (!success) {
+                        throw new IOException("Cannot create directory " + dir.getAbsolutePath());
+                    }
+                } else {
+                    File file = new File(destDir, entry.getName());
+                    OutputStream out = null;
+                    InputStream in = null;
+                    try {
+                        out = new BufferedOutputStream(new FileOutputStream(file));
+                        in = zipFile.getInputStream(entry);
+                        writeAll(in, out);
+                    } finally {
+                        if (null != out) {
+                            out.close();
+                        }
+                        if (null != in) {
+                            in.close();
+                        }
+                    }
+                }
+            }
+        } finally {
+            zipFile.close();
+        }
+    }
+    
     public static boolean recursiveDelete(File root) {
         if (root == null) {
             return true;

Modified: geronimo/branches/1.1/modules/deployment/src/java/org/apache/geronimo/deployment/util/NestedJarFile.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/deployment/src/java/org/apache/geronimo/deployment/util/NestedJarFile.java?rev=394960&r1=394959&r2=394960&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/deployment/src/java/org/apache/geronimo/deployment/util/NestedJarFile.java
(original)
+++ geronimo/branches/1.1/modules/deployment/src/java/org/apache/geronimo/deployment/util/NestedJarFile.java
Tue Apr 18 08:02:36 2006
@@ -215,12 +215,12 @@
             return;
         }
 
-        isClosed = true;
         try {
             if (baseJar != null && isPacked()) {
                 baseJar.close();
             }
         } finally {
+            isClosed = true;
             baseJar = null;
             basePath = null;
             manifestLoaded = false;

Modified: geronimo/branches/1.1/modules/j2ee-builder/src/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilder.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/j2ee-builder/src/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilder.java?rev=394960&r1=394959&r2=394960&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/j2ee-builder/src/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilder.java
(original)
+++ geronimo/branches/1.1/modules/j2ee-builder/src/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilder.java
Tue Apr 18 08:02:36 2006
@@ -397,6 +397,8 @@
                 getBuilder(module).installModule(earFile, earContext, module, configurationStores,
targetConfigurationStore, repositories);
             }
 
+            earContext.flush();
+            
             // give each module a chance to populate the earContext now that a classloader
is available
             ClassLoader cl = earContext.getClassLoader();
             for (Iterator iterator = modules.iterator(); iterator.hasNext();) {

Modified: geronimo/branches/1.1/modules/web-builder/src/java/org/apache/geronimo/web/deployment/AbstractWebModuleBuilder.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/web-builder/src/java/org/apache/geronimo/web/deployment/AbstractWebModuleBuilder.java?rev=394960&r1=394959&r2=394960&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/web-builder/src/java/org/apache/geronimo/web/deployment/AbstractWebModuleBuilder.java
(original)
+++ geronimo/branches/1.1/modules/web-builder/src/java/org/apache/geronimo/web/deployment/AbstractWebModuleBuilder.java
Tue Apr 18 08:02:36 2006
@@ -226,8 +226,15 @@
             throw new DeploymentException("Problem deploying war", e);
         } catch (URISyntaxException e) {
             throw new DeploymentException("Could not construct URI for location of war entry",
e);
+        } finally {
+            if (!module.isStandAlone()) {
+                try {
+                    moduleContext.flush();
+                } catch (IOException e) {
+                    throw new DeploymentException("Problem closing war context", e);
+                }
+            }
         }
-
     }
 
     protected void addUnmappedJSPPermissions(Set securityRoles, Map rolePermissions) {



Mime
View raw message