geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r1391947 - in /geronimo/server/branches/3.0: framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/ framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/repository/ framework/modules/geroni...
Date Sun, 30 Sep 2012 03:48:05 GMT
Author: gawor
Date: Sun Sep 30 03:48:05 2012
New Revision: 1391947

URL: http://svn.apache.org/viewvc?rev=1391947&view=rev
Log:
GERONIMO-6370: Unpack application bundles at repository install time to avoid performance
hit of copying directories with lots of files

Added:
    geronimo/server/branches/3.0/plugins/aries/geronimo-aries/src/main/java/org/apache/geronimo/aries/UnpackEBATypeHandler.java
  (with props)
Modified:
    geronimo/server/branches/3.0/framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/Deployer.java
    geronimo/server/branches/3.0/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/repository/AbstractRepository.java
    geronimo/server/branches/3.0/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/repository/ArtifactTypeHandler.java
    geronimo/server/branches/3.0/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/repository/CopyArtifactTypeHandler.java
    geronimo/server/branches/3.0/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/repository/UnpackArtifactTypeHandler.java
    geronimo/server/branches/3.0/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/util/FileUtils.java
    geronimo/server/branches/3.0/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/util/IOUtils.java
    geronimo/server/branches/3.0/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/RepositoryConfigurationStore.java
    geronimo/server/branches/3.0/plugins/aries/geronimo-aries/src/main/java/org/apache/geronimo/aries/ApplicationInstaller.java

Modified: geronimo/server/branches/3.0/framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/Deployer.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/3.0/framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/Deployer.java?rev=1391947&r1=1391946&r2=1391947&view=diff
==============================================================================
--- geronimo/server/branches/3.0/framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/Deployer.java
(original)
+++ geronimo/server/branches/3.0/framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/Deployer.java
Sun Sep 30 03:48:05 2012
@@ -112,6 +112,7 @@ public class Deployer implements GBeanLi
     public List<String> deploy(boolean inPlace, File moduleFile, File planFile, String
targetConfigStore) throws DeploymentException {
         File originalModuleFile = moduleFile;
         File tmpDir = null;
+        log.debug("Deployment start: module=" + originalModuleFile + ", plan=" + planFile
+ ", inPlace=" + inPlace);
         if (moduleFile != null && !moduleFile.isDirectory()) {
             // todo jar url handling with Sun's VM on Windows leaves a lock on the module
file preventing rebuilds
             // to address this we use a gross hack and copy the file to a temporary directory
@@ -137,9 +138,11 @@ public class Deployer implements GBeanLi
         }
 
         try {
-            return deploy(inPlace, moduleFile, planFile, null, true, null, null, null, null,
null, null, null, targetConfigStore);
+            List<String> moduleNames = deploy(inPlace, moduleFile, planFile, null,
true, null, null, null, null, null, null, null, targetConfigStore);
+            log.debug("Deployment successful: module=" + originalModuleFile + ", plan=" +
planFile);
+            return moduleNames;
         } catch (DeploymentException e) {
-            log.debug("Deployment failed: plan=" + planFile + ", module=" + originalModuleFile,
e);
+            log.debug("Deployment failed: module=" + originalModuleFile + ", plan=" + planFile,
e);
             throw e.cleanse();
         } finally {
             if (tmpDir != null) {

Modified: geronimo/server/branches/3.0/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/repository/AbstractRepository.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/3.0/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/repository/AbstractRepository.java?rev=1391947&r1=1391946&r2=1391947&view=diff
==============================================================================
--- geronimo/server/branches/3.0/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/repository/AbstractRepository.java
(original)
+++ geronimo/server/branches/3.0/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/repository/AbstractRepository.java
Sun Sep 30 03:48:05 2012
@@ -17,20 +17,13 @@
 package org.apache.geronimo.kernel.repository;
 
 import java.io.File;
-import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.Arrays;
-import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.Map;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipException;
-import java.util.zip.ZipFile;
 
-import org.apache.geronimo.kernel.util.IOUtils;
 import org.apache.geronimo.kernel.util.InputUtils;
-import org.apache.geronimo.kernel.util.JarUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -67,45 +60,49 @@ public abstract class AbstractRepository
     }
 
     public void copyToRepository(File source, Artifact destination, FileWriteMonitor monitor)
throws IOException {
-
-        // ensure there are no illegal chars in destination elements
-        InputUtils.validateSafeInput(Arrays.asList(destination.getGroupId(), destination.getArtifactId(),
destination.getVersion().toString(), destination.getType()));
-
-        if(!destination.isResolved()) {
-            throw new IllegalArgumentException("Artifact "+destination+" is not fully resolved");
-        }
-        if (!source.exists() || !source.canRead() || source.isDirectory()) {
+        File location = verifyDestination(destination);
+        
+        if (!source.exists() || !source.canRead()) {
             throw new IllegalArgumentException("Cannot read source file at " + source.getAbsolutePath());
         }
-        int size = 0;
-        ZipFile zip = null;
-        try {
-            zip = new ZipFile(source);
-            for (Enumeration<? extends ZipEntry> entries=zip.entries(); entries.hasMoreElements();)
{
-            	ZipEntry entry = entries.nextElement();
-            	size += entry.getSize();
-            }
-        } catch (ZipException ze) {
-            size = (int)source.length();
-        } finally {
-            JarUtils.close(zip);
-        }
-        FileInputStream is = new FileInputStream(source);
-        try {
-            copyToRepository(is, size, destination, monitor);
-        } finally {
-            IOUtils.close(is);
+        
+        ArtifactTypeHandler typeHandler = typeHandlers.get(destination.getType());
+        if (typeHandler == null) {
+            typeHandler = DEFAULT_TYPE_HANDLER;
+        }
+        typeHandler.install(source, destination, monitor, location);
+
+        if (destination.getType().equalsIgnoreCase("car")) {
+            log.debug("Installed module configuration; id={}; location={}", destination,
location);
         }
     }
 
     public void copyToRepository(InputStream source, int size, Artifact destination, FileWriteMonitor
monitor) throws IOException {
-        if(!destination.isResolved()) {
-            throw new IllegalArgumentException("Artifact "+destination+" is not fully resolved");
+        File location = verifyDestination(destination);
+        
+        ArtifactTypeHandler typeHandler = typeHandlers.get(destination.getType());
+        if (typeHandler == null) {
+            typeHandler = DEFAULT_TYPE_HANDLER;
+        }
+        typeHandler.install(source, size, destination, monitor, location);
+
+        if (destination.getType().equalsIgnoreCase("car")) {
+            log.debug("Installed module configuration; id={}; location={}", destination,
location);
         }
+    }
+    
+    private File verifyDestination(Artifact destination) {
         // is this a writable repository
         if (!rootFile.canWrite()) {
-            throw new IllegalStateException("This repository is not writable: " + rootFile.getAbsolutePath()
+ ")");
+            throw new IllegalStateException("This repository is not writable");
         }
+                
+        if (!destination.isResolved()) {
+            throw new IllegalArgumentException("Artifact "+destination+" is not fully resolved");
+        }
+        
+        // ensure there are no illegal chars in destination elements
+        InputUtils.validateSafeInput(Arrays.asList(destination.getGroupId(), destination.getArtifactId(),
destination.getVersion().toString(), destination.getType()));
 
         // where are we going to install the file
         File location = getLocation(destination);
@@ -114,14 +111,7 @@ public abstract class AbstractRepository
         if (location.exists()) {
             throw new IllegalArgumentException("Destination " + location.getAbsolutePath()
+ " already exists!");
         }
-
-        ArtifactTypeHandler typeHandler = typeHandlers.get(destination.getType());
-        if (typeHandler == null) typeHandler = DEFAULT_TYPE_HANDLER;
-        typeHandler.install(source, size, destination, monitor, location);
-
-        if (destination.getType().equalsIgnoreCase("car")) {
-            log.debug("Installed module configuration; id={}; location={}", destination,
location);
-        }
+        return location;
     }
 
     public File getRootFile() {

Modified: geronimo/server/branches/3.0/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/repository/ArtifactTypeHandler.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/3.0/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/repository/ArtifactTypeHandler.java?rev=1391947&r1=1391946&r2=1391947&view=diff
==============================================================================
--- geronimo/server/branches/3.0/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/repository/ArtifactTypeHandler.java
(original)
+++ geronimo/server/branches/3.0/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/repository/ArtifactTypeHandler.java
Sun Sep 30 03:48:05 2012
@@ -24,5 +24,17 @@ import java.io.IOException;
  * @version $Rev$ $Date$
  */
 public interface ArtifactTypeHandler {
+    
     void install(InputStream source, int size, Artifact artifactId, FileWriteMonitor monitor,
File target) throws IOException;
+    
+    /**
+     * 
+     * @param source a file or a directory
+     * @param artifactId
+     * @param monitor
+     * @param target
+     * @throws IOException
+     */
+    void install(File source, Artifact artifactId, FileWriteMonitor monitor, File target)
throws IOException;
+
 }

Modified: geronimo/server/branches/3.0/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/repository/CopyArtifactTypeHandler.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/3.0/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/repository/CopyArtifactTypeHandler.java?rev=1391947&r1=1391946&r2=1391947&view=diff
==============================================================================
--- geronimo/server/branches/3.0/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/repository/CopyArtifactTypeHandler.java
(original)
+++ geronimo/server/branches/3.0/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/repository/CopyArtifactTypeHandler.java
Sun Sep 30 03:48:05 2012
@@ -16,6 +16,7 @@
  */
 package org.apache.geronimo.kernel.repository;
 
+import java.io.FileInputStream;
 import java.io.InputStream;
 import java.io.File;
 import java.io.IOException;
@@ -26,12 +27,14 @@ import java.io.BufferedInputStream;
 import org.apache.geronimo.kernel.repository.ArtifactTypeHandler;
 import org.apache.geronimo.kernel.repository.Artifact;
 import org.apache.geronimo.kernel.repository.FileWriteMonitor;
+import org.apache.geronimo.kernel.util.FileUtils;
 import org.apache.geronimo.kernel.util.IOUtils;
 
 /**
  * @version $Rev: 476049 $ $Date: 2006-11-17 15:35:17 +1100 (Fri, 17 Nov 2006) $
  */
 public class CopyArtifactTypeHandler implements ArtifactTypeHandler {
+    
     private final static int TRANSFER_NOTIFICATION_SIZE = 10240;  // announce every this
many bytes
     private final static int TRANSFER_BUF_SIZE = 10240;  // try this many bytes at a time
 
@@ -73,4 +76,19 @@ public class CopyArtifactTypeHandler imp
             }
         }
     }
+
+    @Override
+    public void install(File source, Artifact artifactId, FileWriteMonitor monitor, File
target) throws IOException {
+        if (source.isFile()) {
+            long size = (monitor == null) ? -1 : source.length();
+            FileInputStream is = new FileInputStream(source);
+            try {
+                install(is, (int) size, artifactId, monitor, target);
+            } finally {
+                IOUtils.close(is);
+            }
+        } else {
+            FileUtils.recursiveCopy(source, target);
+        }        
+    }
 }

Modified: geronimo/server/branches/3.0/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/repository/UnpackArtifactTypeHandler.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/3.0/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/repository/UnpackArtifactTypeHandler.java?rev=1391947&r1=1391946&r2=1391947&view=diff
==============================================================================
--- geronimo/server/branches/3.0/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/repository/UnpackArtifactTypeHandler.java
(original)
+++ geronimo/server/branches/3.0/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/repository/UnpackArtifactTypeHandler.java
Sun Sep 30 03:48:05 2012
@@ -17,20 +17,26 @@
 package org.apache.geronimo.kernel.repository;
 
 import java.io.File;
+import java.io.FileInputStream;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
+import java.util.Enumeration;
 import java.util.zip.ZipEntry;
+import java.util.zip.ZipException;
+import java.util.zip.ZipFile;
 import java.util.zip.ZipInputStream;
 
 import org.apache.geronimo.kernel.util.FileUtils;
 import org.apache.geronimo.kernel.util.IOUtils;
+import org.apache.geronimo.kernel.util.JarUtils;
 
 /**
  * @version $Rev: 476049 $ $Date: 2006-11-17 15:35:17 +1100 (Fri, 17 Nov 2006) $
  */
 public class UnpackArtifactTypeHandler implements ArtifactTypeHandler {
+    
     private final static int TRANSFER_NOTIFICATION_SIZE = 10240;  // announce every this
many bytes
     private final static int TRANSFER_BUF_SIZE = 10240;  // try this many bytes at a time
 
@@ -49,7 +55,6 @@ public class UnpackArtifactTypeHandler i
         int total = 0;
         ZipInputStream in = new ZipInputStream(source);
         try {
-
             int threshold = UnpackArtifactTypeHandler.TRANSFER_NOTIFICATION_SIZE;
             byte[] buffer = new byte[TRANSFER_BUF_SIZE];
 
@@ -91,4 +96,36 @@ public class UnpackArtifactTypeHandler i
             }
         }
     }
+
+    @Override
+    public void install(File source, Artifact artifactId, FileWriteMonitor monitor, File
target) throws IOException {
+        if (source.isFile()) {
+            long size = (monitor == null) ? -1 : getJarSize(source);
+            FileInputStream is = new FileInputStream(source);
+            try {
+                install(is, (int) size, artifactId, monitor, target);
+            } finally {
+                IOUtils.close(is);
+            }
+        } else {
+            FileUtils.recursiveCopy(source, target);
+        }        
+    }
+    
+    private long getJarSize(File source) throws IOException {
+        long size = 0;
+        ZipFile zip = null;
+        try {
+            zip = new ZipFile(source);
+            for (Enumeration<? extends ZipEntry> entries=zip.entries(); entries.hasMoreElements();)
{
+                ZipEntry entry = entries.nextElement();
+                size += entry.getSize();
+            }
+        } catch (ZipException ze) {
+            size = (int)source.length();
+        } finally {
+            JarUtils.close(zip);
+        }
+        return size;
+    }
 }

Modified: geronimo/server/branches/3.0/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/util/FileUtils.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/3.0/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/util/FileUtils.java?rev=1391947&r1=1391946&r2=1391947&view=diff
==============================================================================
--- geronimo/server/branches/3.0/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/util/FileUtils.java
(original)
+++ geronimo/server/branches/3.0/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/util/FileUtils.java
Sun Sep 30 03:48:05 2012
@@ -88,19 +88,23 @@ public class FileUtils {
     }
     
     public static void copyFile(File source, File destination, int bufferSizeInBytes) throws
IOException {
+        copyFile(source, destination, new byte[bufferSizeInBytes]);
+    }
+    
+    public static void copyFile(File source, File destination, byte[] buffer) throws IOException
{
         if (!source.exists() || source.isDirectory()) {
             throw new IllegalArgumentException("Source does not exist or it is not a file");
         }
         File destinationDir = destination.getParentFile();
         if (!destinationDir.exists() && !destinationDir.mkdirs()) {
-            throw new java.io.IOException("Cannot create directory : " + destinationDir);
+            throw new IOException("Cannot create directory : " + destinationDir);
         }
         InputStream in = null;
         OutputStream out = null;
         try {
             in = new FileInputStream(source);
             out = new FileOutputStream(destination);
-            IOUtils.copy(in, out, bufferSizeInBytes);
+            IOUtils.copy(in, out, buffer);
         } finally {
             IOUtils.close(in);
             IOUtils.close(out);
@@ -188,6 +192,10 @@ public class FileUtils {
     }
 
     public static void recursiveCopy(File srcDir, File destDir) throws IOException {
+        recursiveCopy(srcDir, destDir, new byte[IOUtils.DEFAULT_COPY_BUFFER_SIZE]);
+    }
+    
+    public static void recursiveCopy(File srcDir, File destDir, byte[] buffer) throws IOException
{
         if (srcDir == null)
             throw new NullPointerException("sourceDir is null");
         if (destDir == null)
@@ -211,9 +219,9 @@ public class FileUtils {
                 File srcFile = srcFiles[i];
                 File destFile = new File(destDir, srcFile.getName());
                 if (srcFile.isDirectory()) {
-                    recursiveCopy(srcFile, destFile);
+                    recursiveCopy(srcFile, destFile, buffer);
                 } else {
-                    copyFile(srcFile, destFile);
+                    copyFile(srcFile, destFile, buffer);
                 }
             }
         }

Modified: geronimo/server/branches/3.0/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/util/IOUtils.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/3.0/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/util/IOUtils.java?rev=1391947&r1=1391946&r2=1391947&view=diff
==============================================================================
--- geronimo/server/branches/3.0/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/util/IOUtils.java
(original)
+++ geronimo/server/branches/3.0/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/util/IOUtils.java
Sun Sep 30 03:48:05 2012
@@ -41,7 +41,10 @@ public class IOUtils {
     }
 
     public static void copy(InputStream in, OutputStream out, int bufferSizeInBytes) throws
IOException {
-        byte[] buffer = new byte[bufferSizeInBytes];
+        copy(in, out, new byte[bufferSizeInBytes]);
+    }
+    
+    public static void copy(InputStream in, OutputStream out, byte[] buffer) throws IOException
{
         int count;
         while ((count = in.read(buffer)) > 0) {
             out.write(buffer, 0, count);

Modified: geronimo/server/branches/3.0/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/RepositoryConfigurationStore.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/3.0/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/RepositoryConfigurationStore.java?rev=1391947&r1=1391946&r2=1391947&view=diff
==============================================================================
--- geronimo/server/branches/3.0/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/RepositoryConfigurationStore.java
(original)
+++ geronimo/server/branches/3.0/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/RepositoryConfigurationStore.java
Sun Sep 30 03:48:05 2012
@@ -358,17 +358,10 @@ public class RepositoryConfigurationStor
         Artifact configId = configurationData.getId();
         File destination = repository.getLocation(configId);
         if (!source.equals(destination)) {
-            if (source.isFile()) {
-                if (log.isDebugEnabled()) {
-                    log.debug("copying packed bundle from " + source + " to destination "
+ destination);
-                }
-                repository.copyToRepository(source, configId, null);
-            } else {
-                if (log.isDebugEnabled()) {
-                    log.debug("Packing bundle from " + source + " to destination " + destination);
-                }
-                FileUtils.recursiveCopy(source, destination);
+            if (log.isDebugEnabled()) {
+                log.debug("Copying data from " + source + " to destination " + destination);
             }
+            repository.copyToRepository(source, configId, null); 
         } else {
             if (log.isDebugEnabled()) {
                 log.debug("Plugin is already in location " + source);

Modified: geronimo/server/branches/3.0/plugins/aries/geronimo-aries/src/main/java/org/apache/geronimo/aries/ApplicationInstaller.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/3.0/plugins/aries/geronimo-aries/src/main/java/org/apache/geronimo/aries/ApplicationInstaller.java?rev=1391947&r1=1391946&r2=1391947&view=diff
==============================================================================
--- geronimo/server/branches/3.0/plugins/aries/geronimo-aries/src/main/java/org/apache/geronimo/aries/ApplicationInstaller.java
(original)
+++ geronimo/server/branches/3.0/plugins/aries/geronimo-aries/src/main/java/org/apache/geronimo/aries/ApplicationInstaller.java
Sun Sep 30 03:48:05 2012
@@ -51,6 +51,7 @@ import org.apache.geronimo.kernel.config
 import org.apache.geronimo.kernel.config.ConfigurationModuleType;
 import org.apache.geronimo.kernel.config.ConfigurationStore;
 import org.apache.geronimo.kernel.config.ConfigurationUtil;
+import org.apache.geronimo.kernel.repository.AbstractRepository;
 import org.apache.geronimo.kernel.repository.Artifact;
 import org.apache.geronimo.kernel.repository.Environment;
 import org.apache.geronimo.kernel.repository.Repository;
@@ -103,6 +104,14 @@ public class ApplicationInstaller implem
     public void doStart() throws Exception {
         registration = bundleContext.registerService(ApplicationInstaller.class.getName(),
this, null);
         webApplicationTracker.start();
+        
+        if (getUnpackApplicationBundles()) {
+            for (Repository repository : repositories) {
+                if (repository instanceof AbstractRepository) {
+                    ((AbstractRepository) repository).setTypeHandler("eba", new UnpackEBATypeHandler());
+                }
+            }
+        }        
     }
 
     public void doStop() {
@@ -154,7 +163,8 @@ public class ApplicationInstaller implem
             context.flush();
             context.initializeConfiguration();
 
-            storeApplication(app, tempDirectory, getUnpackApplicationBundles());
+            // UnpackEBATypeHandler will unpack the application bundles if necessary at install
time 
+            storeApplication(app, tempDirectory, false);
             
             AbstractName name = naming.createChildName(moduleName, "AriesApplication", "GBean");
             GBeanData data = new GBeanData(name, ApplicationGBean.class);

Added: geronimo/server/branches/3.0/plugins/aries/geronimo-aries/src/main/java/org/apache/geronimo/aries/UnpackEBATypeHandler.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/3.0/plugins/aries/geronimo-aries/src/main/java/org/apache/geronimo/aries/UnpackEBATypeHandler.java?rev=1391947&view=auto
==============================================================================
--- geronimo/server/branches/3.0/plugins/aries/geronimo-aries/src/main/java/org/apache/geronimo/aries/UnpackEBATypeHandler.java
(added)
+++ geronimo/server/branches/3.0/plugins/aries/geronimo-aries/src/main/java/org/apache/geronimo/aries/UnpackEBATypeHandler.java
Sun Sep 30 03:48:05 2012
@@ -0,0 +1,72 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.aries;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.zip.ZipFile;
+
+import org.apache.geronimo.kernel.repository.Artifact;
+import org.apache.geronimo.kernel.repository.ArtifactTypeHandler;
+import org.apache.geronimo.kernel.repository.FileWriteMonitor;
+import org.apache.geronimo.kernel.util.FileUtils;
+import org.apache.geronimo.kernel.util.IOUtils;
+import org.apache.geronimo.kernel.util.JarUtils;
+
+/**
+ * @version $Rev:385232 $ $Date$
+ */
+public class UnpackEBATypeHandler implements ArtifactTypeHandler {
+
+    @Override
+    public void install(InputStream source, int size, Artifact artifactId, FileWriteMonitor
monitor, File target) throws IOException {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void install(File source, Artifact artifactId, FileWriteMonitor monitor, File
target) throws IOException {
+        if (source.isFile()) {
+            throw new IllegalStateException("Source must be a directory");
+        }
+                
+        unpack(source, target, new byte[IOUtils.DEFAULT_COPY_BUFFER_SIZE]);
+    }
+    
+    private void unpack(File srcDir, File dstDir, byte[] buffer) throws IOException {
+        File[] children = srcDir.listFiles();
+        for (File child : children) {
+            File destination = new File(dstDir, child.getName());
+            if (child.isDirectory()) {
+                if ("META-INF".equals(child.getName())) {
+                    FileUtils.recursiveCopy(child, destination, buffer);
+                } else {
+                    unpack(child, destination, buffer);
+                }
+            } else {               
+                ZipFile zipIn = new ZipFile(child);
+                try {
+                    JarUtils.unzipToDirectory(zipIn, destination);
+                } catch (Exception e) {
+                    FileUtils.copyFile(child, destination, buffer);
+                } finally {
+                    JarUtils.close(zipIn);
+                }
+            }
+        }
+    }
+}

Propchange: geronimo/server/branches/3.0/plugins/aries/geronimo-aries/src/main/java/org/apache/geronimo/aries/UnpackEBATypeHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/branches/3.0/plugins/aries/geronimo-aries/src/main/java/org/apache/geronimo/aries/UnpackEBATypeHandler.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/branches/3.0/plugins/aries/geronimo-aries/src/main/java/org/apache/geronimo/aries/UnpackEBATypeHandler.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message