geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From xuhaih...@apache.org
Subject svn commit: r896339 [2/4] - in /geronimo/server/trunk: framework/modules/geronimo-common/src/main/java/org/apache/geronimo/common/ framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/ framework/modules/geronimo-deplo...
Date Wed, 06 Jan 2010 07:30:40 GMT
Modified: geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/util/IOUtils.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/util/IOUtils.java?rev=896339&r1=896338&r2=896339&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/util/IOUtils.java (original)
+++ geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/util/IOUtils.java Wed Jan  6 07:29:20 2010
@@ -14,28 +14,15 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
+
 package org.apache.geronimo.kernel.util;
 
 import java.io.ByteArrayOutputStream;
 import java.io.Closeable;
-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.io.Writer;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.LinkedHashSet;
-import java.util.Map;
-import java.util.Set;
-import java.util.jar.JarFile;
-import java.util.zip.ZipEntry;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -44,61 +31,17 @@
  * @version $Rev$ $Date$
  */
 public class IOUtils {
-    private static final Logger log = LoggerFactory.getLogger(IOUtils.class);
-
-    public static void recursiveCopy(File srcDir, File destDir) throws IOException {
-        if (srcDir == null) throw new NullPointerException("sourceDir is null");
-        if (destDir == null) throw new NullPointerException("destDir is null");
-        if (!srcDir.isDirectory() || !srcDir.canRead()) {
-            throw new IllegalArgumentException("Source directory must be a readable directory " + srcDir);
-        }
-        if (destDir.exists()) {
-            throw new IllegalArgumentException("Destination directory already exists " + destDir);
-        }
-        if (srcDir.equals(destDir)) {
-            throw new IllegalArgumentException("Source and destination directory are the same " + srcDir);
-        }
-
-        destDir.mkdirs();
-        if (!destDir.exists()) {
-            throw new IOException("Could not create destination directory " + destDir);
-        }
-
 
-        File[] srcFiles = srcDir.listFiles();
-        if (srcFiles != null) {
-            for (int i = 0; i < srcFiles.length; i++) {
-                File srcFile = srcFiles[i];
-                File destFile = new File(destDir, srcFile.getName());
-                if (srcFile.isDirectory()) {
-                    recursiveCopy(srcFile, destFile);
-                } else {
-                    copyFile(srcFile, destFile);
-                }
-            }
-        }
-    }
+    private static final Logger logger = LoggerFactory.getLogger(IOUtils.class);
 
-    public static void copyFile(File source, File destination) throws IOException {
-        File destinationDir = destination.getParentFile();
-        if (!destinationDir.exists() && !destinationDir.mkdirs()) {
-            throw new IOException("Cannot create directory : " + destinationDir);
-        }
+    public static final int DEFAULT_COPY_BUFFER_SIZE = 4096;
 
-        InputStream in = null;
-        OutputStream out = null;
-        try {
-            in = new FileInputStream(source);
-            out = new FileOutputStream(destination);
-            writeAll(in, out);
-        } finally {
-            close(in);
-            close(out);
-        }
+    public static void copy(InputStream in, OutputStream out) throws IOException {
+        copy(in, out, DEFAULT_COPY_BUFFER_SIZE);
     }
 
-    public static void writeAll(InputStream in, OutputStream out) throws IOException {
-        byte[] buffer = new byte[4096];
+    public static void copy(InputStream in, OutputStream out, int bufferSizeInBytes) throws IOException {
+        byte[] buffer = new byte[bufferSizeInBytes];
         int count;
         while ((count = in.read(buffer)) > 0) {
             out.write(buffer, 0, count);
@@ -106,78 +49,6 @@
         out.flush();
     }
 
-    private static void listFiles(File directory) {
-        if (!log.isDebugEnabled() || !directory.isDirectory()) {
-            return;
-        }
-        File[] files = directory.listFiles();
-        log.debug(directory.getPath() + " has " + files.length + " files:");
-        for (File file : files) {
-            log.debug(file.getPath());
-        }
-    }
-
-    private static boolean deleteFile(File file) {
-        boolean fileDeleted = file.delete();
-        if (fileDeleted) {
-            return true;
-        }
-
-        // special retry code to handle occasional Windows JDK and Unix NFS timing failures
-        int retryLimit = 5;
-        int retries;
-        int interruptions = 0;
-        for (retries = 1; !fileDeleted && retries <= retryLimit; retries++) {
-            if (log.isDebugEnabled()) {
-                listFiles(file);
-            }
-            System.runFinalization();
-            try {
-                Thread.sleep(1000);
-            } catch (InterruptedException ie) {
-                interruptions++;
-            }
-            System.gc();
-            try {
-                Thread.sleep(1000);
-            } catch (InterruptedException ie) {
-                interruptions++;
-            }
-            fileDeleted = file.delete();
-        }
-        if (fileDeleted) {
-            if (log.isDebugEnabled()) {
-                log.debug(file.getPath() + " deleted after " + retries
-                        + " retries, with " + interruptions + " interruptions.");
-            }
-        } else {
-            log.warn(file.getPath() + " not deleted after " + retryLimit
-                    + " retries, with " + interruptions + " interruptions.");
-        }
-        return fileDeleted;
-    }
-
-    public static boolean recursiveDelete(File root) {
-        if (root == null) {
-            return true;
-        }
-
-        if (root.isDirectory()) {
-            File[] files = root.listFiles();
-            if (files != null) {
-                for (int i = 0; i < files.length; i++) {
-                    File file = files[i];
-                    if (file.isDirectory()) {
-                        recursiveDelete(file);
-                    } else {
-                        deleteFile(file);
-                    }
-                }
-            }
-        }
-        return deleteFile(root);
-    }
-
     public static void close(Closeable thing) {
         if (thing != null) {
             try {
@@ -187,115 +58,6 @@
         }
     }
 
-    public static Map<String, File> find(File root, String pattern) {
-        Map<String, File> matches = new HashMap<String, File>();
-        find(root, pattern, matches);
-        return matches;
-    }
-    
-    public static void find(File root, String pattern, Map<String, File> matches) {   
-        if (!SelectorUtils.hasWildcards(pattern)) {
-            File match = new File(root, pattern);
-            if (match.exists() && match.canRead()) {
-                matches.put(pattern, match);
-            }
-        } else {
-            Map<String, File> files = IOUtils.listAllFileNames(root);
-            for (Map.Entry<String, File> entry : files.entrySet()) {
-                String fileName = entry.getKey();
-                if (SelectorUtils.matchPath(pattern, fileName)) {
-                    matches.put(fileName, entry.getValue());
-                }
-            }
-        }
-    }
-    
-    public static Set<URL> search(File root, String pattern) throws MalformedURLException {
-        if (root.isDirectory()) {
-            if (pattern == null || pattern.length() == 0) {
-                return Collections.singleton(new URL("file:" + root.toURI().normalize().getPath()));
-            }
-            if (!SelectorUtils.hasWildcards(pattern)) {
-                File match = new File(root, pattern);
-                if (match.exists() && match.canRead()) {
-                    return Collections.singleton(new URL("file:" + match.toURI().normalize().getPath()));
-                } else {
-                    return Collections.emptySet();
-                }
-            } else {
-                Set<URL> matches = new LinkedHashSet<URL>();
-                Map<String, File> files = listAllFileNames(root);
-                for (Map.Entry<String, File> entry : files.entrySet()) {
-                    String fileName = entry.getKey();
-                    if (SelectorUtils.matchPath(pattern, fileName)) {
-                        File file = entry.getValue();
-                        matches.add(new URL("file:" + file.toURI().normalize().getPath()));
-                    }
-                }
-                return matches;
-            }
-        } else {
-            JarFile jarFile = null;
-            try {
-                jarFile = new JarFile(root);
-                URL baseURL = new URL("jar:" + root.toURI().toURL().toString() + "!/");
-                if (pattern == null || pattern.length() == 0) {
-                    return Collections.singleton(baseURL);
-                }
-                if (!SelectorUtils.hasWildcards(pattern)) {
-                    ZipEntry entry = jarFile.getEntry(pattern);
-                    if (entry != null) {
-                        URL match = new URL(baseURL, entry.getName());
-                        return Collections.singleton(match);
-                    } else {
-                        return Collections.emptySet();
-                    }
-                } else {
-                    Set<URL> matches = new LinkedHashSet<URL>();
-                    Enumeration entries = jarFile.entries();
-                    while (entries.hasMoreElements()) {
-                        ZipEntry entry = (ZipEntry) entries.nextElement();
-                        String fileName = entry.getName();
-                        if (SelectorUtils.matchPath(pattern, fileName)) {
-                            URL url = new URL(baseURL, fileName);
-                            matches.add(url);
-                        }
-                    }
-                    return matches;
-                }
-            } catch (MalformedURLException e) {
-                throw e;
-            } catch (IOException e) {
-                return Collections.emptySet();
-            } finally {
-                close(jarFile);
-            }
-        }
-    }
-
-    public static Map<String, File> listAllFileNames(File base) {
-        return listAllFileNames(base, "");
-    }
-
-    private static Map<String, File> listAllFileNames(File base, String prefix) {
-        if (!base.canRead() || !base.isDirectory()) {
-            throw new IllegalArgumentException(base.getAbsolutePath());
-        }
-        Map<String, File> map = new LinkedHashMap<String, File>();
-        File[] hits = base.listFiles();
-        for (File hit : hits) {
-            if (hit.canRead()) {
-                if (hit.isDirectory()) {
-                    map.putAll(listAllFileNames(hit, prefix.equals("") ? hit.getName() : prefix + "/" + hit.getName()));
-                } else {
-                    map.put(prefix.equals("") ? hit.getName() : prefix + "/" + hit.getName(), hit);
-                }
-            }
-        }
-        map.put(prefix, base);
-        return map;
-    }
-    
     public static byte[] getBytes(InputStream inputStream) throws IOException {
         try {
             byte[] buffer = new byte[4096];
@@ -314,7 +76,7 @@
         if (thing != null) {
             try {
                 thing.flush();
-            } catch(Exception ignored) {
+            } catch (Exception ignored) {
             }
         }
     }
@@ -323,26 +85,18 @@
         if (thing != null) {
             try {
                 thing.flush();
-            } catch(Exception ignored) {
-            }
-        }
-    }
-
-    public static void close(JarFile thing) {
-        if (thing != null) {
-            try {
-                thing.close();
-            } catch(Exception ignored) {
+            } catch (Exception ignored) {
             }
         }
     }
 
     public static final class EmptyInputStream extends InputStream {
+
         public int read() {
             return -1;
         }
 
-        public int read(byte b[])  {
+        public int read(byte b[]) {
             return -1;
         }
 

Modified: geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/util/InputUtils.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/util/InputUtils.java?rev=896339&r1=896338&r2=896339&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/util/InputUtils.java (original)
+++ geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/util/InputUtils.java Wed Jan  6 07:29:20 2010
@@ -18,7 +18,6 @@
 
 // import java.io.IOException;
 import java.util.ArrayList;
-import java.util.List;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
@@ -39,7 +38,7 @@
         // look for illegal chars in input
         if (input != null) {
             Matcher inputMatcher = ILLEGAL_CHARS.matcher(input);
-            if (inputMatcher.find()) 
+            if (inputMatcher.find())
             {
                 log.warn("Illegal characters detected in input" + input);
                 throw new IllegalArgumentException("input  "+input+" contains illegal characters: .. < > : / \\ \' \" | ");

Added: geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/util/JarUtils.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/util/JarUtils.java?rev=896339&view=auto
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/util/JarUtils.java (added)
+++ geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/util/JarUtils.java Wed Jan  6 07:29:20 2010
@@ -0,0 +1,339 @@
+/**
+ *  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.kernel.util;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.DataInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.Reader;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Enumeration;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+import java.util.jar.JarOutputStream;
+import java.util.jar.Manifest;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipFile;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public final class JarUtils {
+
+    private JarUtils() {
+    }
+
+    public static final File DUMMY_JAR_FILE;
+
+    private static final boolean jarUrlRewrite;
+    static {
+        //TODO Change the property name ?
+        jarUrlRewrite = new Boolean(System.getProperty("org.apache.geronimo.deployment.util.DeploymentUtil.jarUrlRewrite", "false"));
+        try {
+            DUMMY_JAR_FILE = FileUtils.createTempFile();
+            new JarOutputStream(new FileOutputStream(JarUtils.DUMMY_JAR_FILE), new Manifest()).close();
+        } catch (IOException e) {
+            throw new ExceptionInInitializerError(e);
+        }
+    }
+
+    public static File toTempFile(JarFile jarFile, String path) throws IOException {
+        return toTempFile(createJarURL(jarFile, path));
+    }
+
+    public static File toTempFile(URL url) throws IOException {
+        InputStream in = null;
+        OutputStream out = null;
+        JarFile jarFile = null;
+        try {
+            if (url.getProtocol().equalsIgnoreCase("jar")) {
+                // url.openStream() locks the jar file and does not release the lock even after the stream is closed.
+                // This problem is avoided by using JarFile APIs.
+                File file = new File(url.getFile().substring(5, url.getFile().indexOf("!/")));
+                String path = url.getFile().substring(url.getFile().indexOf("!/") + 2);
+                jarFile = new JarFile(file);
+                JarEntry jarEntry = jarFile.getJarEntry(path);
+                if (jarEntry != null) {
+                    in = jarFile.getInputStream(jarEntry);
+                } else {
+                    throw new FileNotFoundException("JarEntry " + path + " not found in " + file);
+                }
+            } else {
+                in = url.openStream();
+            }
+            int index = url.getPath().lastIndexOf(".");
+            String extension = null;
+            if (index > 0) {
+                extension = url.getPath().substring(index);
+            }
+            File tempFile = FileUtils.createTempFile(extension);
+            out = new FileOutputStream(tempFile);
+            IOUtils.copy(in, out);
+            return tempFile;
+        } finally {
+            IOUtils.close(out);
+            IOUtils.close(in);
+            close(jarFile);
+        }
+    }
+
+    public static String readAll(URL url) throws IOException {
+        Reader reader = null;
+        JarFile jarFile = null;
+        try {
+            if (url.getProtocol().equalsIgnoreCase("jar")) {
+                // url.openStream() locks the jar file and does not release the lock even after the stream is closed.
+                // This problem is avoided by using JarFile APIs.
+                File file = new File(url.getFile().substring(5, url.getFile().indexOf("!/")));
+                String path = url.getFile().substring(url.getFile().indexOf("!/") + 2);
+                jarFile = new JarFile(file);
+                JarEntry jarEntry = jarFile.getJarEntry(path);
+                if (jarEntry != null) {
+                    reader = new InputStreamReader(jarFile.getInputStream(jarEntry));
+                } else {
+                    throw new FileNotFoundException("JarEntry " + path + " not found in " + file);
+                }
+            } else {
+                reader = new InputStreamReader(url.openStream());
+            }
+            char[] buffer = new char[4000];
+            StringBuffer out = new StringBuffer();
+            for (int count = reader.read(buffer); count >= 0; count = reader.read(buffer)) {
+                out.append(buffer, 0, count);
+            }
+            return out.toString();
+        } finally {
+            IOUtils.close(reader);
+            close(jarFile);
+        }
+    }
+
+    public static File toFile(JarFile jarFile) throws IOException {
+        if (jarFile instanceof UnpackedJarFile) {
+            return ((UnpackedJarFile) jarFile).getBaseDir();
+        } else {
+            throw new IOException("jarFile is not a directory");
+        }
+    }
+
+    // be careful with this method as it can leave a temp lying around
+    public static File toFile(JarFile jarFile, String path) throws IOException {
+        if (jarFile instanceof UnpackedJarFile) {
+            File baseDir = ((UnpackedJarFile) jarFile).getBaseDir();
+            File file = new File(baseDir, path);
+            if (!file.isFile()) {
+                throw new IOException("No such file: " + file.getAbsolutePath());
+            }
+            return file;
+        } else {
+            String urlString = "jar:" + new File(jarFile.getName()).toURI().toURL() + "!/" + path;
+            return toTempFile(new URL(urlString));
+        }
+    }
+
+    public static URL createJarURL(JarFile jarFile, String path) throws MalformedURLException {
+        if (jarFile instanceof NestedJarFile) {
+            NestedJarFile nestedJar = (NestedJarFile) jarFile;
+            if (nestedJar.isUnpacked()) {
+                JarFile baseJar = nestedJar.getBaseJar();
+                String basePath = nestedJar.getBasePath();
+                if (baseJar instanceof UnpackedJarFile) {
+                    File baseDir = ((UnpackedJarFile) baseJar).getBaseDir();
+                    baseDir = new File(baseDir, basePath);
+                    return new File(baseDir, path).toURI().toURL();
+                }
+            }
+        }
+        if (jarFile instanceof UnpackedJarFile) {
+            File baseDir = ((UnpackedJarFile) jarFile).getBaseDir();
+            return new File(baseDir, path).toURI().toURL();
+        } else {
+            String urlString = "jar:" + new File(jarFile.getName()).toURI().toURL() + "!/" + path;
+            if (jarUrlRewrite) {
+                // To prevent the lockout of archive, instead of returning a jar url, write the content to a
+                // temp file and return the url of that file.
+                File tempFile = null;
+                try {
+                    tempFile = toTempFile(new URL(urlString));
+                } catch (IOException e) {
+                    // The JarEntry does not exist!
+                    // Return url of a file that does not exist.
+                    try {
+                        tempFile = FileUtils.createTempFile();
+                        tempFile.delete();
+                    } catch (IOException ignored) {
+                    }
+                }
+                return tempFile.toURI().toURL();
+            } else {
+                return new URL(urlString);
+            }
+        }
+    }
+
+    public static JarFile createJarFile(File jarFile) throws IOException {
+        if (jarFile.isDirectory()) {
+            return new UnpackedJarFile(jarFile);
+        } else {
+            return new JarFile(jarFile);
+        }
+    }
+
+    public static void copyToPackedJar(JarFile inputJar, File outputFile) throws IOException {
+        if (inputJar.getClass() == JarFile.class) {
+            // this is a plain old jar... nothign special
+            FileUtils.copyFile(new File(inputJar.getName()), outputFile);
+        } else if (inputJar instanceof NestedJarFile && ((NestedJarFile) inputJar).isPacked()) {
+            NestedJarFile nestedJarFile = (NestedJarFile) inputJar;
+            JarFile baseJar = nestedJarFile.getBaseJar();
+            String basePath = nestedJarFile.getBasePath();
+            if (baseJar instanceof UnpackedJarFile) {
+                // our target jar is just a file in upacked jar (a plain old directory)... now
+                // we just need to find where it is and copy it to the outptu
+                FileUtils.copyFile(((UnpackedJarFile) baseJar).getFile(basePath), outputFile);
+            } else {
+                // out target is just a plain old jar file directly accessabel from the file system
+                FileUtils.copyFile(new File(baseJar.getName()), outputFile);
+            }
+        } else {
+            // copy out the module contents to a standalone jar file (entry by entry)
+            JarOutputStream out = null;
+            try {
+                out = new JarOutputStream(new FileOutputStream(outputFile));
+                byte[] buffer = new byte[4096];
+                Enumeration entries = inputJar.entries();
+                while (entries.hasMoreElements()) {
+                    ZipEntry entry = (ZipEntry) entries.nextElement();
+                    InputStream in = inputJar.getInputStream(entry);
+                    try {
+                        out.putNextEntry(new ZipEntry(entry.getName()));
+                        try {
+                            int count;
+                            while ((count = in.read(buffer)) > 0) {
+                                out.write(buffer, 0, count);
+                            }
+                        } finally {
+                            out.closeEntry();
+                        }
+                    } finally {
+                        IOUtils.close(in);
+                    }
+                }
+            } finally {
+                IOUtils.close(out);
+            }
+        }
+    }
+
+    public static void jarDirectory(File sourceDirecotry, File destinationFile) throws IOException {
+        JarFile inputJar = new UnpackedJarFile(sourceDirecotry);
+        try {
+            copyToPackedJar(inputJar, destinationFile);
+        } finally {
+            close(inputJar);
+        }
+    }
+
+    private static void createDirectory(File dir) throws IOException {
+        if (dir != null && !dir.exists()) {
+            boolean success = dir.mkdirs();
+            if (!success) {
+                throw new IOException("Cannot create directory " + dir.getAbsolutePath());
+            }
+        }
+    }
+
+    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());
+                    createDirectory(dir);
+                } else {
+                    File file = new File(destDir, entry.getName());
+                    createDirectory(file.getParentFile());
+                    OutputStream out = null;
+                    InputStream in = null;
+                    try {
+                        out = new BufferedOutputStream(new FileOutputStream(file));
+                        in = zipFile.getInputStream(entry);
+                        IOUtils.copy(in, out);
+                    } finally {
+                        IOUtils.close(in);
+                        IOUtils.close(out);
+                    }
+                }
+            }
+        } finally {
+            zipFile.close();
+        }
+    }
+
+    public static void close(JarFile thing) {
+        if (thing != null) {
+            try {
+                thing.close();
+            } catch (Exception ignored) {
+            }
+        }
+    }
+
+    /**
+     * Determine whether a file is a JAR File.
+     *
+     * Note: Jar file is a zip file with an *optional* META-INF directory.
+     * Therefore, there is no reliable way to check if a file is a Jar file.
+     * So this functions returns the same as calling isZipFile(File).
+     */
+    public static boolean isJarFile(File file) throws IOException {
+        return isZipFile(file);
+    }
+
+    /**
+     * Determine whether a file is a ZIP File.
+     */
+    public static boolean isZipFile(File file) throws IOException {
+        if (file.isDirectory()) {
+            return false;
+        }
+        if (!file.canRead()) {
+            throw new IOException("Cannot read file " + file.getAbsolutePath());
+        }
+        if (file.length() < 4) {
+            return false;
+        }
+        DataInputStream in = null;
+        try {
+            in = new DataInputStream(new BufferedInputStream(new FileInputStream(file)));
+            return in.readInt() == 0x504b0304;
+        } finally {
+            IOUtils.close(in);
+        }
+    }
+}

Propchange: geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/util/JarUtils.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/util/JarUtils.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/util/JarUtils.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/util/NestedJarEntry.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/util/NestedJarEntry.java?rev=896339&view=auto
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/util/NestedJarEntry.java (added)
+++ geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/util/NestedJarEntry.java Wed Jan  6 07:29:20 2010
@@ -0,0 +1,130 @@
+/**
+ *  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.kernel.util;
+
+import java.io.IOException;
+import java.security.cert.Certificate;
+import java.util.jar.Attributes;
+import java.util.jar.JarEntry;
+import java.util.jar.Manifest;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class NestedJarEntry extends JarEntry {
+    private final JarEntry baseEntry;
+    private final Manifest manifest;
+
+    public NestedJarEntry(String name, JarEntry baseEntry, Manifest manifest) {
+        super(name);
+        this.baseEntry = baseEntry;
+        this.manifest = manifest;
+    }
+
+    public JarEntry getBaseEntry() {
+        return baseEntry;
+    }
+
+    public Attributes getAttributes() throws IOException {
+        if (manifest == null) {
+            return null;
+        }
+        return manifest.getAttributes(getName());
+    }
+
+    /**
+     * Always return null.  This could be implementd by verifing the signatures
+     * in the manifest file against the actual file, but we don't need this for
+     * Geronimo.
+     * @return null
+     */
+    public Certificate[] getCertificates() {
+        return null;
+    }
+
+    public long getTime() {
+        return baseEntry.getTime();
+    }
+
+    public void setTime(long time) {
+        baseEntry.setTime(time);
+    }
+
+    public long getSize() {
+        return baseEntry.getSize();
+    }
+
+    public void setSize(long size) {
+        baseEntry.setSize(size);
+    }
+
+    public long getCompressedSize() {
+        return baseEntry.getCompressedSize();
+    }
+
+    public void setCompressedSize(long csize) {
+        baseEntry.setCompressedSize(csize);
+    }
+
+    public long getCrc() {
+        return baseEntry.getCrc();
+    }
+
+    public void setCrc(long crc) {
+        baseEntry.setCrc(crc);
+    }
+
+    public int getMethod() {
+        return baseEntry.getMethod();
+    }
+
+    public void setMethod(int method) {
+        baseEntry.setMethod(method);
+    }
+
+    public byte[] getExtra() {
+        return baseEntry.getExtra();
+    }
+
+    public void setExtra(byte[] extra) {
+        baseEntry.setExtra(extra);
+    }
+
+    public String getComment() {
+        return baseEntry.getComment();
+    }
+
+    public void setComment(String comment) {
+        baseEntry.setComment(comment);
+    }
+
+    public boolean isDirectory() {
+        return baseEntry.isDirectory();
+    }
+
+    public String toString() {
+        return baseEntry.toString();
+    }
+
+    public int hashCode() {
+        return baseEntry.hashCode();
+    }
+
+    public Object clone() {
+        return new NestedJarEntry(getName(), baseEntry, manifest);
+    }
+}

Propchange: geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/util/NestedJarEntry.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/util/NestedJarEntry.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/util/NestedJarEntry.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/util/NestedJarFile.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/util/NestedJarFile.java?rev=896339&view=auto
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/util/NestedJarFile.java (added)
+++ geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/util/NestedJarFile.java Wed Jan  6 07:29:20 2010
@@ -0,0 +1,269 @@
+/**
+ *  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.kernel.util;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+import java.util.jar.Manifest;
+import java.util.zip.ZipEntry;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class NestedJarFile extends JarFile {
+    private JarFile baseJar;
+    private String basePath;
+    private boolean isClosed = false;
+    private boolean manifestLoaded = false;
+    private Manifest manifest;
+    private File tempFile;
+
+    public NestedJarFile(JarFile jarFile, String path) throws IOException {
+        super(JarUtils.DUMMY_JAR_FILE);
+
+        // verify that the jar actually contains that path
+        JarEntry targetEntry = jarFile.getJarEntry(path + "/");
+        if (targetEntry == null) {
+            targetEntry = jarFile.getJarEntry(path);
+            if (targetEntry == null) {
+                throw new IOException("Jar entry does not exist: jarFile=" + jarFile.getName() + ", path=" + path);
+            }
+        }
+
+        if (targetEntry.isDirectory()) {
+        	if(targetEntry instanceof UnpackedJarEntry) {
+        		//unpacked nested module inside unpacked ear
+        		File targetFile = ((UnpackedJarEntry) targetEntry).getFile();
+        		baseJar = new UnpackedJarFile(targetFile);
+                basePath = "";
+        	} else {
+        		baseJar = jarFile;
+        		if (!path.endsWith("/")) {
+                    path += "/";
+                }
+                basePath = path;
+        	}
+        } else {
+            if (targetEntry instanceof UnpackedJarEntry) {
+                // for unpacked jars we don't need to copy the jar file
+                // out to a temp directory, since it is already available
+                // as a raw file
+                File targetFile = ((UnpackedJarEntry) targetEntry).getFile();
+                baseJar = new JarFile(targetFile);
+                basePath = "";
+            } else {
+                tempFile = JarUtils.toFile(jarFile, targetEntry.getName());
+                baseJar = new JarFile(tempFile);
+                basePath = "";
+            }
+        }
+    }
+
+    public boolean isUnpacked() {
+        if (isClosed) {
+            throw new IllegalStateException("NestedJarFile is closed");
+        }
+
+        return ( basePath.length() > 0 ) ||
+               ( ( baseJar != null ) && ( baseJar instanceof UnpackedJarFile ) );
+    }
+
+    public boolean isPacked() {
+        if (isClosed) {
+            throw new IllegalStateException("NestedJarFile is closed");
+        }
+
+        return ( basePath.length() == 0 ) &&
+               ( ( baseJar == null ) || !( baseJar instanceof UnpackedJarFile ) );
+    }
+
+    public JarFile getBaseJar() {
+        if (isClosed) {
+            throw new IllegalStateException("NestedJarFile is closed");
+        }
+        return baseJar;
+    }
+
+    public String getBasePath() {
+        if (isClosed) {
+            throw new IllegalStateException("NestedJarFile is closed");
+        }
+        return basePath;
+    }
+
+    public Manifest getManifest() throws IOException {
+        if (isClosed) {
+            throw new IllegalStateException("NestedJarFile is closed");
+        }
+
+        if (!manifestLoaded) {
+            JarEntry manifestEntry = getBaseEntry("META-INF/MANIFEST.MF");
+
+            if (manifestEntry != null && !manifestEntry.isDirectory()) {
+                InputStream in = null;
+                try {
+                    in = baseJar.getInputStream(manifestEntry);
+                    manifest = new Manifest(in);
+                } finally {
+                    if (in != null) {
+                        try {
+                            in.close();
+                        } catch (IOException e) {
+                            // ignore
+                        }
+                    }
+                }
+            }
+            manifestLoaded = true;
+        }
+        return manifest;
+    }
+
+    public NestedJarEntry getNestedJarEntry(String name) {
+        if (isClosed) {
+            throw new IllegalStateException("NestedJarFile is closed");
+        }
+
+        JarEntry baseEntry = getBaseEntry(name);
+        if (baseEntry == null) {
+            return null;
+        }
+        return new NestedJarEntry(name, baseEntry, getManifestSafe());
+    }
+
+    public JarEntry getJarEntry(String name) {
+        if (isClosed) {
+            throw new IllegalStateException("NestedJarFile is closed");
+        }
+
+        return getNestedJarEntry(name);
+    }
+
+    public ZipEntry getEntry(String name) {
+        if (isClosed) {
+            throw new IllegalStateException("NestedJarFile is closed");
+        }
+
+        return getNestedJarEntry(name);
+    }
+
+    public Enumeration entries() {
+        if (isClosed) {
+            throw new IllegalStateException("NestedJarFile is closed");
+        }
+
+        Collection baseEntries = Collections.list(baseJar.entries());
+        Collection entries = new LinkedList();
+        for (Iterator iterator = baseEntries.iterator(); iterator.hasNext();) {
+            JarEntry baseEntry = (JarEntry) iterator.next();
+            String path = baseEntry.getName();
+            if (path.startsWith(basePath)) {
+                entries.add(new NestedJarEntry(path.substring(basePath.length()), baseEntry, getManifestSafe()));
+            }
+        }
+        return Collections.enumeration(entries);
+    }
+
+    public InputStream getInputStream(ZipEntry zipEntry) throws IOException {
+        if (isClosed) {
+            throw new IllegalStateException("NestedJarFile is closed");
+        }
+
+        JarEntry baseEntry;
+        if (zipEntry instanceof NestedJarEntry) {
+            baseEntry = ((NestedJarEntry)zipEntry).getBaseEntry();
+        } else {
+            baseEntry = getBaseEntry(zipEntry.getName());
+        }
+
+        if (baseEntry == null) {
+            throw new IOException("Entry not found: name=" + zipEntry.getName());
+        } else if (baseEntry.isDirectory()) {
+            return new IOUtils.EmptyInputStream();
+        }
+        return baseJar.getInputStream(baseEntry);
+    }
+
+    public String getName() {
+        return baseJar.getName();
+    }
+
+    /**
+     * Always returns -1.
+     * @return -1
+     */
+    public int size() {
+        if (isClosed) {
+            throw new IllegalStateException("NestedJarFile is closed");
+        }
+        return -1;
+    }
+
+    public void close() throws IOException {
+        if (isClosed) {
+            return;
+        }
+
+        try {
+            try {
+                super.close();
+            } catch(IOException ignored) {
+            }
+            if (baseJar != null && basePath.length() == 0) {
+                // baseJar is created by us.  We should be closing it too.
+                baseJar.close();
+            }
+        } finally {
+            isClosed = true;
+            baseJar = null;
+            basePath = null;
+            manifestLoaded = false;
+            manifest = null;
+            if (tempFile != null) {
+                tempFile.delete();
+                tempFile = null;
+            }
+        }
+    }
+
+    protected void finalize() throws IOException {
+        close();
+    }
+
+    private JarEntry getBaseEntry(String name) {
+        return baseJar.getJarEntry(basePath + name);
+    }
+
+    private Manifest getManifestSafe() {
+        Manifest manifest = null;
+        try {
+            manifest = getManifest();
+        } catch (IOException e) {
+            // ignore
+        }
+        return manifest;
+    }
+
+}

Propchange: geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/util/NestedJarFile.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/util/NestedJarFile.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/util/NestedJarFile.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/util/UnpackedJarEntry.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/util/UnpackedJarEntry.java?rev=896339&view=auto
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/util/UnpackedJarEntry.java (added)
+++ geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/util/UnpackedJarEntry.java Wed Jan  6 07:29:20 2010
@@ -0,0 +1,175 @@
+/**
+ *  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.kernel.util;
+
+import java.util.jar.JarEntry;
+import java.util.jar.Attributes;
+import java.util.jar.Manifest;
+import java.util.zip.ZipEntry;
+import java.io.IOException;
+import java.io.File;
+import java.security.cert.Certificate;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class UnpackedJarEntry extends JarEntry {
+    private final File file;
+    private final Manifest manifest;
+
+    public UnpackedJarEntry(String name, File file, Manifest manifest) {
+        super(name);
+        this.file = file;
+        this.manifest = manifest;
+    }
+
+    public File getFile() {
+        return file;
+    }
+
+    public Attributes getAttributes() throws IOException {
+        if (manifest == null) {
+            return null;
+        }
+        return manifest.getAttributes(getName());
+    }
+
+    /**
+     * Always return null.  This could be implementd by verifing the signatures
+     * in the manifest file against the actual file, but we don't need this for
+     * Geronimo.
+     * @return null
+     */
+    public Certificate[] getCertificates() {
+        return null;
+    }
+
+    /**
+     * An unpacked jar is read only, so this method always throws an UnsupportedOperationException.
+     * @param time ignored
+     * @throws UnsupportedOperationException always
+     */
+    public void setTime(long time) throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Can not change the time of unpacked jar entry");
+    }
+
+    public long getTime() {
+        return file.lastModified();
+    }
+
+    /**
+     * An unpacked jar is read only, so this method always throws an UnsupportedOperationException.
+     * @param size ignored
+     * @throws UnsupportedOperationException always
+     */
+    public void setSize(long size) throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Can not change the size of unpacked jar entry");
+    }
+
+    public long getSize() {
+        if (file.isDirectory()) {
+            return -1;
+        } else {
+            return file.length();
+        }
+    }
+
+    /**
+     * An unpacked jar is not compressed, so this method returns getSize().
+     * @return getSize()
+     */
+    public long getCompressedSize() {
+        return getSize();
+    }
+
+    /**
+     * An unpacked jar is read only, so this method always throws an UnsupportedOperationException.
+     * @param compressedSize ignored
+     * @throws UnsupportedOperationException always
+     */
+    public void setCompressedSize(long compressedSize) {
+        throw new UnsupportedOperationException("Can not change the compressed size of unpacked jar entry");
+    }
+
+    public long getCrc() {
+        return super.getCrc();    //To change body of overridden methods use File | Settings | File Templates.
+    }
+
+    /**
+     * An unpacked jar is read only, so this method always throws an UnsupportedOperationException.
+     * @param crc ignored
+     * @throws UnsupportedOperationException always
+     */
+    public void setCrc(long crc) {
+        throw new UnsupportedOperationException("Can not change the crc of unpacked jar entry");
+    }
+
+    public int getMethod() {
+        return ZipEntry.STORED;
+    }
+
+    /**
+     * An unpacked jar is read only, so this method always throws an UnsupportedOperationException.
+     * @param method ignored
+     * @throws UnsupportedOperationException always
+     */
+    public void setMethod(int method) {
+        throw new UnsupportedOperationException("Can not change the method of unpacked jar entry");
+    }
+
+    /**
+     * Always returns null.
+     * @return null
+     */
+    public byte[] getExtra() {
+        return null;
+    }
+
+    /**
+     * An unpacked jar is read only, so this method always throws an UnsupportedOperationException.
+     * @param extra ignored
+     * @throws UnsupportedOperationException always
+     */
+    public void setExtra(byte[] extra) {
+        throw new UnsupportedOperationException("Can not change the extra data of unpacked jar entry");
+    }
+
+    /**
+     * Always returns null.
+     * @return null
+     */
+    public String getComment() {
+        return null;
+    }
+
+    /**
+     * An unpacked jar is read only, so this method always throws an UnsupportedOperationException.
+     * @param comment ignored
+     * @throws UnsupportedOperationException always
+     */
+    public void setComment(String comment) {
+        throw new UnsupportedOperationException("Can not change the comment of unpacked jar entry");
+    }
+
+    public boolean isDirectory() {
+        return file.isDirectory();
+    }
+
+    public Object clone() {
+        return new UnpackedJarEntry(getName(), file, manifest);
+    }
+}

Propchange: geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/util/UnpackedJarEntry.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/util/UnpackedJarEntry.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/util/UnpackedJarEntry.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/util/UnpackedJarFile.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/util/UnpackedJarFile.java?rev=896339&view=auto
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/util/UnpackedJarFile.java (added)
+++ geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/util/UnpackedJarFile.java Wed Jan  6 07:29:20 2010
@@ -0,0 +1,164 @@
+/**
+ *  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.kernel.util;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+import java.util.jar.Manifest;
+import java.util.zip.ZipEntry;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class UnpackedJarFile extends JarFile {
+    private final File baseDir;
+    private boolean manifestLoaded = false;
+    private Manifest manifest;
+
+    public UnpackedJarFile(File baseDir) throws IOException {
+        super(JarUtils.DUMMY_JAR_FILE);
+        this.baseDir = baseDir;
+        if (!baseDir.isDirectory()) {
+            throw new IOException("File must be a directory: file=" + baseDir.getAbsolutePath());
+        }
+    }
+
+    public File getBaseDir() {
+        return baseDir;
+    }
+
+    public Manifest getManifest() throws IOException {
+        if (!manifestLoaded) {
+            File manifestFile = getFile("META-INF/MANIFEST.MF");
+
+            if (manifestFile != null && manifestFile.isFile()) {
+                FileInputStream in = null;
+                try {
+                    in = new FileInputStream(manifestFile);
+                    manifest = new Manifest(in);
+                } finally {
+                    if (in != null) {
+                        try {
+                            in.close();
+                        } catch (IOException e) {
+                            // ignore
+                        }
+                    }
+                }
+            }
+            manifestLoaded = true;
+        }
+        return manifest;
+    }
+
+    public UnpackedJarEntry getUnpackedJarEntry(String name) {
+        File file = getFile(name);
+        if (file == null) {
+            return null;
+        }
+        return new UnpackedJarEntry(name, file, getManifestSafe());
+    }
+
+    public JarEntry getJarEntry(String name) {
+        return getUnpackedJarEntry(name);
+    }
+
+    public ZipEntry getEntry(String name) {
+        return getUnpackedJarEntry(name);
+    }
+
+    public Enumeration entries() {
+        Collection files = FileUtils.listRecursiveFiles(baseDir);
+
+        Manifest manifest = getManifestSafe();
+        LinkedList entries = new LinkedList();
+        URI baseURI = baseDir.getAbsoluteFile().toURI();
+        for (Iterator iterator = files.iterator(); iterator.hasNext();) {
+            File entryFile = ((File) iterator.next()).getAbsoluteFile();
+            URI entryURI = entryFile.toURI();
+            URI relativeURI = baseURI.relativize(entryURI);
+            entries.add(new UnpackedJarEntry(relativeURI.getPath(), entryFile, manifest));
+        }
+        return Collections.enumeration(entries);
+    }
+
+    public InputStream getInputStream(ZipEntry zipEntry) throws IOException {
+        File file;
+        if (zipEntry instanceof UnpackedJarEntry) {
+            file = ((UnpackedJarEntry)zipEntry).getFile();
+        } else {
+            file = getFile(zipEntry.getName());
+        }
+
+        if (file == null) {
+            throw new IOException("Entry not found: name=" + zipEntry.getName());
+        } else if (file.isDirectory()) {
+            return new IOUtils.EmptyInputStream();
+        }
+        return new FileInputStream(file);
+    }
+
+    public String getName() {
+        return baseDir.getAbsolutePath();
+    }
+
+    /**
+     * Always returns -1.
+     * @return -1
+     */
+    public int size() {
+        return -1;
+    }
+
+    public void close() throws IOException {
+        try {
+            super.close();
+        } catch(IOException ignored) {
+        }
+    }
+
+    protected void finalize() throws IOException {
+    }
+
+    public File getFile(String name) {
+        File file = new File(baseDir, name);
+        if (!file.exists()) {
+            return null;
+        }
+        return file;
+    }
+
+    private Manifest getManifestSafe() {
+        Manifest manifest = null;
+        try {
+            manifest = getManifest();
+        } catch (IOException e) {
+            // ignore
+        }
+        return manifest;
+    }
+}

Propchange: geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/util/UnpackedJarFile.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/util/UnpackedJarFile.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/util/UnpackedJarFile.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/server/trunk/framework/modules/geronimo-kernel/src/test/java/org/apache/geronimo/kernel/mock/MockConfigStore.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-kernel/src/test/java/org/apache/geronimo/kernel/mock/MockConfigStore.java?rev=896339&r1=896338&r2=896339&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-kernel/src/test/java/org/apache/geronimo/kernel/mock/MockConfigStore.java (original)
+++ geronimo/server/trunk/framework/modules/geronimo-kernel/src/test/java/org/apache/geronimo/kernel/mock/MockConfigStore.java Wed Jan  6 07:29:20 2010
@@ -34,7 +34,7 @@
 import org.apache.geronimo.kernel.config.NoSuchConfigException;
 import org.apache.geronimo.kernel.config.NullConfigurationStore;
 import org.apache.geronimo.kernel.repository.Artifact;
-import org.apache.geronimo.kernel.util.IOUtils;
+import org.apache.geronimo.kernel.util.FileUtils;
 
 /**
  * ???
@@ -45,7 +45,7 @@
     extends NullConfigurationStore
 {
     protected static final Naming naming = new Jsr77Naming();
-    
+
     protected final Map<Artifact, File> locations = new HashMap<Artifact, File>();
     private Map<Artifact, ConfigurationData> configs = new HashMap<Artifact, ConfigurationData>();
 
@@ -87,7 +87,7 @@
         if (file == null) {
             throw new NoSuchConfigException(configId);
         }
-        return IOUtils.search(file, pattern);
+        return FileUtils.search(file, pattern);
     }
 
     public void installFake(Artifact configId, File file) {

Modified: geronimo/server/trunk/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/ArchiverGBean.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/ArchiverGBean.java?rev=896339&r1=896338&r2=896339&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/ArchiverGBean.java (original)
+++ geronimo/server/trunk/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/ArchiverGBean.java Wed Jan  6 07:29:20 2010
@@ -30,7 +30,7 @@
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
 import org.apache.geronimo.kernel.repository.Artifact;
-import org.apache.geronimo.kernel.util.IOUtils;
+import org.apache.geronimo.kernel.util.FileUtils;
 import org.apache.geronimo.system.serverinfo.ServerInfo;
 import org.apache.tools.ant.Project;
 import org.apache.tools.ant.taskdefs.MatchingTask;
@@ -55,22 +55,22 @@
     public void addExclude(String pattern) {
         this.excludes.add(pattern);
     }
-    
+
     public void removeExclude(String pattern) {
         this.excludes.remove(pattern);
     }
-    
+
     private void removeExcludes(File source, Map<String, File> all) {
         Map<String, File> matches = new HashMap<String, File>();
         for (String exclude : this.excludes) {
-            IOUtils.find(source, exclude, matches);
+            FileUtils.find(source, exclude, matches);
         }
 
         for (String exclude : matches.keySet()) {
             all.remove(exclude);
         }
     }
-        
+
     public File archive(String sourcePath, String destPath, Artifact artifact) throws //ArchiverException,
             IOException {
         File source = serverInfo.resolve(sourcePath);
@@ -130,31 +130,31 @@
                 // mark parent directories non-empty
                 for (File parentDir = sourceFile.getParentFile();
                      parentDir != null && !parentDir.equals(source);
-                     parentDir = parentDir.getParentFile()) {               
+                     parentDir = parentDir.getParentFile()) {
                     emptyDirs.put(parentDir, Boolean.FALSE);
                 }
-                
-            } else if (sourceFile.isDirectory()) {                           
-                Boolean isEmpty = emptyDirs.get(sourceFile);                
-                if (isEmpty == null) {       
+
+            } else if (sourceFile.isDirectory()) {
+                Boolean isEmpty = emptyDirs.get(sourceFile);
+                if (isEmpty == null) {
                     emptyDirs.put(sourceFile, Boolean.TRUE);
                     // mark parent directories non-empty
                     for (File parentDir = sourceFile.getParentFile();
                          parentDir != null && !parentDir.equals(source);
-                         parentDir = parentDir.getParentFile()) {               
+                         parentDir = parentDir.getParentFile()) {
                         emptyDirs.put(parentDir, Boolean.FALSE);
                     }
-                }              
+                }
             }
         }
-        
+
         if (!all.isEmpty()) {
             emptyDirs.put(source, Boolean.FALSE);
         }
-                
+
         String sourceDirPath = source.getAbsolutePath();
         for (Map.Entry<File, Boolean> entry : emptyDirs.entrySet()) {
-            if (entry.getValue().booleanValue()) {                
+            if (entry.getValue().booleanValue()) {
                 String emptyDirPath = entry.getKey().getAbsolutePath();
                 String relativeDir = emptyDirPath.substring(sourceDirPath.length());
                 relativeDir = relativeDir.replace('\\', '/');
@@ -162,9 +162,9 @@
             }
         }
         emptyDirs.clear();
-        
+
         all.clear();
-        
+
         // add execute permissions to all non-batch files in the bin/ directory
         File bin = new File(source, "bin");
         if (bin.exists()) {

Modified: geronimo/server/trunk/framework/modules/geronimo-service-builder/src/main/java/org/apache/geronimo/deployment/service/ServiceConfigBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-service-builder/src/main/java/org/apache/geronimo/deployment/service/ServiceConfigBuilder.java?rev=896339&r1=896338&r2=896339&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-service-builder/src/main/java/org/apache/geronimo/deployment/service/ServiceConfigBuilder.java (original)
+++ geronimo/server/trunk/framework/modules/geronimo-service-builder/src/main/java/org/apache/geronimo/deployment/service/ServiceConfigBuilder.java Wed Jan  6 07:29:20 2010
@@ -29,13 +29,13 @@
 import java.util.jar.JarFile;
 
 import javax.xml.namespace.QName;
+
 import org.apache.geronimo.common.DeploymentException;
 import org.apache.geronimo.deployment.ConfigurationBuilder;
 import org.apache.geronimo.deployment.DeploymentContext;
 import org.apache.geronimo.deployment.ModuleIDBuilder;
 import org.apache.geronimo.deployment.NamespaceDrivenBuilder;
 import org.apache.geronimo.deployment.NamespaceDrivenBuilderCollection;
-import org.apache.geronimo.deployment.util.DeploymentUtil;
 import org.apache.geronimo.deployment.xbeans.ArtifactType;
 import org.apache.geronimo.deployment.xbeans.EnvironmentType;
 import org.apache.geronimo.deployment.xbeans.ModuleDocument;
@@ -43,11 +43,11 @@
 import org.apache.geronimo.deployment.xmlbeans.XmlBeansUtil;
 import org.apache.geronimo.gbean.AbstractName;
 import org.apache.geronimo.gbean.GBeanLifecycle;
+import org.apache.geronimo.gbean.annotation.GBean;
 import org.apache.geronimo.gbean.annotation.ParamAttribute;
 import org.apache.geronimo.gbean.annotation.ParamReference;
 import org.apache.geronimo.gbean.annotation.ParamSpecial;
 import org.apache.geronimo.gbean.annotation.SpecialAttributeType;
-import org.apache.geronimo.gbean.annotation.GBean;
 import org.apache.geronimo.kernel.GBeanNotFoundException;
 import org.apache.geronimo.kernel.Kernel;
 import org.apache.geronimo.kernel.Naming;
@@ -61,6 +61,8 @@
 import org.apache.geronimo.kernel.repository.ArtifactResolver;
 import org.apache.geronimo.kernel.repository.Environment;
 import org.apache.geronimo.kernel.repository.Repository;
+import org.apache.geronimo.kernel.util.FileUtils;
+import org.apache.geronimo.kernel.util.JarUtils;
 import org.apache.xmlbeans.XmlCursor;
 import org.apache.xmlbeans.XmlException;
 import org.apache.xmlbeans.XmlObject;
@@ -138,7 +140,7 @@
             if (planFile != null) {
                 xmlObject = XmlBeansUtil.parse(planFile.toURI().toURL(), getClass().getClassLoader());
             } else {
-                URL path = DeploymentUtil.createJarURL(jarFile, "META-INF/geronimo-service.xml");
+                URL path = JarUtils.createJarURL(jarFile, "META-INF/geronimo-service.xml");
                 try {
                     xmlObject = XmlBeansUtil.parse(path, getClass().getClassLoader());
                 } catch (FileNotFoundException e) {
@@ -235,7 +237,7 @@
 
             AbstractName moduleName = naming.createRootName(configId, configId.toString(), SERVICE_MODULE);
             context = new DeploymentContext(outfile,
-                    inPlaceDeployment && null != jar ? DeploymentUtil.toFile(jar) : null,
+                    inPlaceDeployment && null != jar ? JarUtils.toFile(jar) : null,
                     environment,
                     moduleName,
                     ConfigurationModuleType.SERVICE,
@@ -275,7 +277,7 @@
             // ignore error on cleanu
         }
         if (directory != null) {
-            DeploymentUtil.recursiveDelete(directory);
+            FileUtils.recursiveDelete(directory);
         }
     }
 

Modified: geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/RepositoryConfigurationStore.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/RepositoryConfigurationStore.java?rev=896339&r1=896338&r2=896339&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/RepositoryConfigurationStore.java (original)
+++ geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/RepositoryConfigurationStore.java Wed Jan  6 07:29:20 2010
@@ -47,17 +47,19 @@
 import org.apache.geronimo.kernel.config.ConfigurationInfo;
 import org.apache.geronimo.kernel.config.ConfigurationStore;
 import org.apache.geronimo.kernel.config.ConfigurationUtil;
-import org.apache.geronimo.kernel.util.IOUtils;
 import org.apache.geronimo.kernel.config.InvalidConfigException;
 import org.apache.geronimo.kernel.config.NoOConfigurationDataTransformer;
 import org.apache.geronimo.kernel.config.NoSuchConfigException;
 import org.apache.geronimo.kernel.repository.Artifact;
 import org.apache.geronimo.kernel.repository.WritableListableRepository;
+import org.apache.geronimo.kernel.util.FileUtils;
+import org.apache.geronimo.kernel.util.IOUtils;
+import org.apache.geronimo.kernel.util.JarUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
- * Implementation of ConfigurationStore GBean that installs/loads Configurations from a 
+ * Implementation of ConfigurationStore GBean that installs/loads Configurations from a
  * repository.
  *
  * @version $Rev$ $Date$
@@ -82,7 +84,7 @@
             WritableListableRepository repository) {
         this(kernel, objectName, abstractName, repository, NoOConfigurationDataTransformer.SINGLETON);
     }
-    
+
     public RepositoryConfigurationStore(@ParamSpecial(type=SpecialAttributeType.kernel) Kernel kernel,
             @ParamSpecial(type=SpecialAttributeType.objectName) String objectName,
             @ParamSpecial(type=SpecialAttributeType.abstractName) AbstractName abstractName,
@@ -148,7 +150,7 @@
                     configurationData = ConfigurationUtil.readConfigurationData(in);
                 } finally {
                     IOUtils.close(in);
-                    IOUtils.close(jarFile);
+                    JarUtils.close(jarFile);
                 }
             }
         } catch (ClassNotFoundException e) {
@@ -162,7 +164,7 @@
         }
 
         transformer.transformDependencies(configurationData);
-        
+
         return configurationData;
     }
 
@@ -188,7 +190,7 @@
             } catch (IOException e) {
                 return false;
             } finally {
-                IOUtils.close(jarFile);
+                JarUtils.close(jarFile);
             }
         }
     }
@@ -249,7 +251,7 @@
             if (moduleName != null) {
                 location = new File(location, moduleName);
             }
-            return IOUtils.search(location, path);
+            return FileUtils.search(location, path);
  /*           if(path == null) {
                 return Collections.singleton(location.toURL());
             } else {
@@ -265,7 +267,7 @@
             if (moduleName != null) {
                 path = moduleName + "/" +path;
             }
-            return IOUtils.search(location, path);
+            return FileUtils.search(location, path);
         }
     }
 
@@ -297,7 +299,7 @@
         if (all.length == 0) {
             // it is an empty directory
             ZipEntry entry = new ZipEntry(prefix);
-            out.putNextEntry(entry); 
+            out.putNextEntry(entry);
         }
         for (File file : all) {
             if (file.isDirectory()) {
@@ -359,7 +361,7 @@
                 repository.copyToRepository(source, configId, null);
             } else if (source.isDirectory()) {
                 // directory is in wrong place -- directory copy
-                IOUtils.recursiveCopy(source, destination);
+                FileUtils.recursiveCopy(source, destination);
             } else {
                 throw new InvalidConfigException("Unable to install configuration from " + source);
             }
@@ -382,7 +384,7 @@
             // don't really care
         }
         File location = repository.getLocation(configId);
-        IOUtils.recursiveDelete(location);
+        FileUtils.recursiveDelete(location);
         // Number of directory levels up, to check and delete empty parent directories in the repo
         int dirDepth = 0;
 
@@ -424,7 +426,7 @@
                 throw ioException;
             }
         }
-        
+
         transformer.remove(configId);
     }
 
@@ -481,7 +483,7 @@
                 configurationInfo = ConfigurationUtil.readConfigurationInfo(in, getAbstractName(), inPlaceLocation);
             } finally {
                 IOUtils.close(in);
-                IOUtils.close(jarFile);
+                JarUtils.close(jarFile);
             }
         }
 

Modified: geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/AriesAppConfigBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/AriesAppConfigBuilder.java?rev=896339&r1=896338&r2=896339&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/AriesAppConfigBuilder.java (original)
+++ geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/AriesAppConfigBuilder.java Wed Jan  6 07:29:20 2010
@@ -35,7 +35,6 @@
 import org.apache.geronimo.deployment.ConfigurationBuilder;
 import org.apache.geronimo.deployment.DeploymentContext;
 import org.apache.geronimo.deployment.ModuleIDBuilder;
-import org.apache.geronimo.deployment.util.DeploymentUtil;
 import org.apache.geronimo.gbean.AbstractName;
 import org.apache.geronimo.gbean.GBeanLifecycle;
 import org.apache.geronimo.gbean.annotation.GBean;
@@ -56,6 +55,7 @@
 import org.apache.geronimo.kernel.repository.Environment;
 import org.apache.geronimo.kernel.repository.ImportType;
 import org.apache.geronimo.kernel.repository.WritableListableRepository;
+import org.apache.geronimo.kernel.util.JarUtils;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.Constants;
 import org.osgi.framework.ServiceReference;
@@ -254,7 +254,7 @@
         AbstractName moduleName = naming.createRootName(configId, configId.toString(), "AriesApplication");
         try {
             DeploymentContext context = new DeploymentContext(outfile,                
-                            inPlaceDeployment && null != jarFile ? DeploymentUtil.toFile(jarFile) : null,
+                            inPlaceDeployment && null != jarFile ? JarUtils.toFile(jarFile) : null,
                             environment,
                             moduleName,
                             ConfigurationModuleType.SERVICE,

Modified: geronimo/server/trunk/plugins/axis/geronimo-axis-builder/src/main/java/org/apache/geronimo/axis/builder/AxisBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/axis/geronimo-axis-builder/src/main/java/org/apache/geronimo/axis/builder/AxisBuilder.java?rev=896339&r1=896338&r2=896339&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/axis/geronimo-axis-builder/src/main/java/org/apache/geronimo/axis/builder/AxisBuilder.java (original)
+++ geronimo/server/trunk/plugins/axis/geronimo-axis-builder/src/main/java/org/apache/geronimo/axis/builder/AxisBuilder.java Wed Jan  6 07:29:20 2010
@@ -78,7 +78,6 @@
 import org.apache.geronimo.xbeans.j2ee.JavaXmlTypeMappingType;
 import org.apache.geronimo.xbeans.j2ee.ServiceEndpointInterfaceMappingType;
 import org.apache.geronimo.xbeans.j2ee.ServiceEndpointMethodMappingType;
-import org.apache.geronimo.deployment.util.DeploymentUtil;
 import org.apache.geronimo.deployment.DeploymentContext;
 import org.apache.geronimo.deployment.service.EnvironmentBuilder;
 import org.apache.geronimo.webservices.SerializableWebServiceContainerFactoryGBean;
@@ -89,6 +88,7 @@
 import org.apache.geronimo.kernel.GBeanAlreadyExistsException;
 import org.apache.geronimo.kernel.osgi.BundleClassLoader;
 import org.apache.geronimo.kernel.repository.Environment;
+import org.apache.geronimo.kernel.util.JarUtils;
 import org.osgi.framework.Bundle;
 
 /**
@@ -118,7 +118,7 @@
     public void findWebServices(JarFile moduleFile, boolean isEJB, Map servletLocations, Environment environment, Map sharedContext) throws DeploymentException {
         final String path = isEJB ? "META-INF/webservices.xml" : "WEB-INF/webservices.xml";
         try {
-            URL wsDDUrl = DeploymentUtil.createJarURL(moduleFile, path);
+            URL wsDDUrl = JarUtils.createJarURL(moduleFile, path);
             Map portMap = WSDescriptorParser.parseWebServiceDescriptor(wsDDUrl, moduleFile, isEJB, servletLocations);
             if (portMap != null) {
                 if (defaultEnvironment != null) {

Modified: geronimo/server/trunk/plugins/client/geronimo-client-builder/src/main/java/org/apache/geronimo/client/builder/AppClientModuleBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/client/geronimo-client-builder/src/main/java/org/apache/geronimo/client/builder/AppClientModuleBuilder.java?rev=896339&r1=896338&r2=896339&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/client/geronimo-client-builder/src/main/java/org/apache/geronimo/client/builder/AppClientModuleBuilder.java (original)
+++ geronimo/server/trunk/plugins/client/geronimo-client-builder/src/main/java/org/apache/geronimo/client/builder/AppClientModuleBuilder.java Wed Jan  6 07:29:20 2010
@@ -45,8 +45,6 @@
 import org.apache.geronimo.deployment.NamespaceDrivenBuilder;
 import org.apache.geronimo.deployment.NamespaceDrivenBuilderCollection;
 import org.apache.geronimo.deployment.service.EnvironmentBuilder;
-import org.apache.geronimo.deployment.util.DeploymentUtil;
-import org.apache.geronimo.deployment.util.NestedJarFile;
 import org.apache.geronimo.deployment.xbeans.EnvironmentType;
 import org.apache.geronimo.deployment.xbeans.PatternType;
 import org.apache.geronimo.deployment.xmlbeans.XmlBeansUtil;
@@ -57,8 +55,8 @@
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
 import org.apache.geronimo.gbean.GBeanLifecycle;
 import org.apache.geronimo.gbean.SingleElementCollection;
-import org.apache.geronimo.j2ee.deployment.ApplicationInfo;
 import org.apache.geronimo.j2ee.deployment.AppClientModule;
+import org.apache.geronimo.j2ee.deployment.ApplicationInfo;
 import org.apache.geronimo.j2ee.deployment.ConnectorModule;
 import org.apache.geronimo.j2ee.deployment.CorbaGBeanNameSource;
 import org.apache.geronimo.j2ee.deployment.EARContext;
@@ -81,6 +79,9 @@
 import org.apache.geronimo.kernel.repository.Environment;
 import org.apache.geronimo.kernel.repository.MissingDependencyException;
 import org.apache.geronimo.kernel.repository.Repository;
+import org.apache.geronimo.kernel.util.FileUtils;
+import org.apache.geronimo.kernel.util.JarUtils;
+import org.apache.geronimo.kernel.util.NestedJarFile;
 import org.apache.geronimo.schema.SchemaConversionUtils;
 import org.apache.geronimo.security.deploy.SubjectInfo;
 import org.apache.geronimo.xbeans.geronimo.client.GerApplicationClientDocument;
@@ -265,12 +266,12 @@
         ApplicationClientType appClient = null;
         try {
             if (specDDUrl == null) {
-                specDDUrl = DeploymentUtil.createJarURL(moduleFile, "META-INF/application-client.xml");
+                specDDUrl = JarUtils.createJarURL(moduleFile, "META-INF/application-client.xml");
             }
 
             // read in the entire specDD as a string, we need this for getDeploymentDescriptor
             // on the J2ee management object
-            specDD = DeploymentUtil.readAll(specDDUrl);
+            specDD = JarUtils.readAll(specDDUrl);
         } catch (Exception e) {
             //construct a default spec dd
             ApplicationClientDocument appClientDoc = ApplicationClientDocument.Factory.newInstance();
@@ -413,7 +414,7 @@
                     if (plan != null) {
                         rawPlan = XmlBeansUtil.parse((File) plan);
                     } else {
-                        URL path = DeploymentUtil.createJarURL(moduleFile, "META-INF/geronimo-application-client.xml");
+                        URL path = JarUtils.createJarURL(moduleFile, "META-INF/geronimo-application-client.xml");
                         rawPlan = XmlBeansUtil.parse(path, getClass().getClassLoader());
                     }
                 }
@@ -659,7 +660,7 @@
                 addManifestClassPath(appClientDeploymentContext, appClientModule.getEarFile(), moduleFile, moduleBase);
 
                 // get the classloader
-                Bundle appClientClassBundle = appClientDeploymentContext.getDeploymentBundle();              
+                Bundle appClientClassBundle = appClientDeploymentContext.getDeploymentBundle();
 
                 // pop in all the gbeans declared in the geronimo app client file
                 if (geronimoAppClient != null) {
@@ -908,7 +909,7 @@
     private boolean cleanupAppClientDir(File configurationDir) {
         LinkedList<String> cannotBeDeletedList = new LinkedList<String>();
 
-        if (!DeploymentUtil.recursiveDelete(configurationDir, cannotBeDeletedList)) {
+        if (!FileUtils.recursiveDelete(configurationDir, cannotBeDeletedList)) {
             // Output a message to help user track down file problem
             log.warn("Unable to delete " + cannotBeDeletedList.size() +
                     " files while recursively deleting directory "

Modified: geronimo/server/trunk/plugins/clustering/geronimo-deploy-farm/src/main/java/org/apache/geronimo/farm/deployment/BasicClusterConfigurationStore.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/clustering/geronimo-deploy-farm/src/main/java/org/apache/geronimo/farm/deployment/BasicClusterConfigurationStore.java?rev=896339&r1=896338&r2=896339&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/clustering/geronimo-deploy-farm/src/main/java/org/apache/geronimo/farm/deployment/BasicClusterConfigurationStore.java (original)
+++ geronimo/server/trunk/plugins/clustering/geronimo-deploy-farm/src/main/java/org/apache/geronimo/farm/deployment/BasicClusterConfigurationStore.java Wed Jan  6 07:29:20 2010
@@ -26,7 +26,7 @@
 import org.apache.geronimo.gbean.annotation.ParamReference;
 import org.apache.geronimo.kernel.config.ConfigurationData;
 import org.apache.geronimo.kernel.config.ConfigurationStore;
-import org.apache.geronimo.kernel.util.IOUtils;
+import org.apache.geronimo.kernel.util.FileUtils;
 import org.apache.geronimo.kernel.config.InvalidConfigException;
 import org.apache.geronimo.kernel.config.NoSuchConfigException;
 import org.apache.geronimo.kernel.repository.Artifact;
@@ -66,7 +66,7 @@
     }
 
     protected void deleteDir(File packedConfigurationDir) {
-        IOUtils.recursiveDelete(packedConfigurationDir);
+        FileUtils.recursiveDelete(packedConfigurationDir);
     }
 
     protected DirectoryPackager newDirectoryPackager() {

Modified: geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/main/java/org/apache/geronimo/connector/deployment/ConnectorModuleBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/main/java/org/apache/geronimo/connector/deployment/ConnectorModuleBuilder.java?rev=896339&r1=896338&r2=896339&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/main/java/org/apache/geronimo/connector/deployment/ConnectorModuleBuilder.java (original)
+++ geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/main/java/org/apache/geronimo/connector/deployment/ConnectorModuleBuilder.java Wed Jan  6 07:29:20 2010
@@ -42,16 +42,6 @@
 
 import org.apache.geronimo.common.DeploymentException;
 import org.apache.geronimo.common.propertyeditor.PropertyEditors;
-import org.apache.geronimo.connector.wrapper.ActivationSpecWrapperGBean;
-import org.apache.geronimo.connector.wrapper.AdminObjectWrapper;
-import org.apache.geronimo.connector.wrapper.AdminObjectWrapperGBean;
-import org.apache.geronimo.connector.wrapper.JCAResourceImplGBean;
-import org.apache.geronimo.connector.wrapper.ResourceAdapterImplGBean;
-import org.apache.geronimo.connector.wrapper.ResourceAdapterModuleImplGBean;
-import org.apache.geronimo.connector.wrapper.ResourceAdapterWrapperGBean;
-import org.apache.geronimo.connector.wrapper.outbound.ManagedConnectionFactoryWrapper;
-import org.apache.geronimo.connector.wrapper.outbound.JCAConnectionFactoryImplGBean;
-import org.apache.geronimo.connector.wrapper.outbound.ManagedConnectionFactoryWrapperGBean;
 import org.apache.geronimo.connector.outbound.connectionmanagerconfig.LocalTransactions;
 import org.apache.geronimo.connector.outbound.connectionmanagerconfig.NoPool;
 import org.apache.geronimo.connector.outbound.connectionmanagerconfig.NoTransactions;
@@ -61,11 +51,20 @@
 import org.apache.geronimo.connector.outbound.connectionmanagerconfig.TransactionLog;
 import org.apache.geronimo.connector.outbound.connectionmanagerconfig.TransactionSupport;
 import org.apache.geronimo.connector.outbound.connectionmanagerconfig.XATransactions;
+import org.apache.geronimo.connector.wrapper.ActivationSpecWrapperGBean;
+import org.apache.geronimo.connector.wrapper.AdminObjectWrapper;
+import org.apache.geronimo.connector.wrapper.AdminObjectWrapperGBean;
+import org.apache.geronimo.connector.wrapper.JCAResourceImplGBean;
+import org.apache.geronimo.connector.wrapper.ResourceAdapterImplGBean;
+import org.apache.geronimo.connector.wrapper.ResourceAdapterModuleImplGBean;
+import org.apache.geronimo.connector.wrapper.ResourceAdapterWrapperGBean;
+import org.apache.geronimo.connector.wrapper.outbound.JCAConnectionFactoryImplGBean;
+import org.apache.geronimo.connector.wrapper.outbound.ManagedConnectionFactoryWrapper;
+import org.apache.geronimo.connector.wrapper.outbound.ManagedConnectionFactoryWrapperGBean;
 import org.apache.geronimo.deployment.ModuleIDBuilder;
 import org.apache.geronimo.deployment.NamespaceDrivenBuilder;
 import org.apache.geronimo.deployment.NamespaceDrivenBuilderCollection;
 import org.apache.geronimo.deployment.service.EnvironmentBuilder;
-import org.apache.geronimo.deployment.util.DeploymentUtil;
 import org.apache.geronimo.deployment.xbeans.EnvironmentType;
 import org.apache.geronimo.deployment.xmlbeans.XmlBeansUtil;
 import org.apache.geronimo.gbean.AbstractName;
@@ -91,6 +90,7 @@
 import org.apache.geronimo.kernel.config.Configuration;
 import org.apache.geronimo.kernel.config.ConfigurationStore;
 import org.apache.geronimo.kernel.repository.Environment;
+import org.apache.geronimo.kernel.util.JarUtils;
 import org.apache.geronimo.management.JCAConnectionFactory;
 import org.apache.geronimo.management.geronimo.JCAAdminObject;
 import org.apache.geronimo.management.geronimo.JCAResourceAdapter;
@@ -121,9 +121,9 @@
 import org.apache.xmlbeans.XmlDocumentProperties;
 import org.apache.xmlbeans.XmlException;
 import org.apache.xmlbeans.XmlObject;
+import org.osgi.framework.Bundle;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.osgi.framework.Bundle;
 
 /**
  * @version $Rev:385659 $ $Date$
@@ -222,12 +222,12 @@
         XmlObject connector;
         try {
             if (specDDUrl == null) {
-                specDDUrl = DeploymentUtil.createJarURL(moduleFile, "META-INF/ra.xml");
+                specDDUrl = JarUtils.createJarURL(moduleFile, "META-INF/ra.xml");
             }
 
             // read in the entire specDD as a string, we need this for getDeploymentDescriptor
             // on the J2ee management object
-            specDD = DeploymentUtil.readAll(specDDUrl);
+            specDD = JarUtils.readAll(specDDUrl);
         } catch (Exception e) {
             //no ra.xml, not for us.
             return null;
@@ -255,7 +255,7 @@
                     if (plan != null) {
                         gerConnectorDoc = GerConnectorDocument.Factory.parse((File) plan, XmlBeansUtil.createXmlOptions(errors));
                     } else {
-                        URL path = DeploymentUtil.createJarURL(moduleFile, "META-INF/geronimo-ra.xml");
+                        URL path = JarUtils.createJarURL(moduleFile, "META-INF/geronimo-ra.xml");
                         gerConnectorDoc = GerConnectorDocument.Factory.parse(path, XmlBeansUtil.createXmlOptions(errors));
                     }
                     if (errors.size() > 0) {



Mime
View raw message