You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by ga...@apache.org on 2008/10/13 20:52:25 UTC

svn commit: r704201 - in /webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2: classloader/ deployment/ deployment/util/

Author: gawor
Date: Mon Oct 13 11:52:25 2008
New Revision: 704201

URL: http://svn.apache.org/viewvc?rev=704201&view=rev
Log:
use JarFileClassLoader on Windows to prevent file locking - patch from Tim McConnell (AXIS2-4072)

Added:
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/AbstractResourceHandle.java   (with props)
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/AbstractUrlResourceLocation.java   (with props)
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/DirectoryResourceHandle.java   (with props)
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/DirectoryResourceLocation.java   (with props)
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/IoUtil.java   (with props)
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/JarFileClassLoader.java   (with props)
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/JarResourceHandle.java   (with props)
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/JarResourceLocation.java   (with props)
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/ResourceEnumeration.java   (with props)
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/ResourceFinder.java   (with props)
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/ResourceHandle.java   (with props)
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/ResourceLocation.java   (with props)
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/UrlResourceFinder.java   (with props)
Modified:
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/MultiParentClassLoader.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/DeploymentEngine.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/util/Utils.java

Added: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/AbstractResourceHandle.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/AbstractResourceHandle.java?rev=704201&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/AbstractResourceHandle.java (added)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/AbstractResourceHandle.java Mon Oct 13 11:52:25 2008
@@ -0,0 +1,63 @@
+/**
+ *  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.axis2.classloader;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.security.cert.Certificate;
+import java.util.jar.Attributes;
+import java.util.jar.Manifest;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public abstract class AbstractResourceHandle implements ResourceHandle {
+    public byte[] getBytes() throws IOException {
+        InputStream in = getInputStream();
+        try {
+            byte[] bytes = IoUtil.getBytes(in);
+            return bytes;
+        } finally {
+            IoUtil.close(in);
+        }
+    }
+
+    public Manifest getManifest() throws IOException {
+        return null;
+    }
+
+    public Certificate[] getCertificates() {
+        return null;
+    }
+
+    public Attributes getAttributes() throws IOException {
+        Manifest m = getManifest();
+        if (m == null) {
+            return null;
+        }
+
+        String entry = getUrl().getFile();
+        return m.getAttributes(entry);
+    }
+
+    public void close() {
+    }
+
+    public String toString() {
+        return "[" + getName() + ": " + getUrl() + "; code source: " + getCodeSourceUrl() + "]";
+    }
+}

Propchange: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/AbstractResourceHandle.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/AbstractResourceHandle.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/AbstractResourceHandle.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/AbstractUrlResourceLocation.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/AbstractUrlResourceLocation.java?rev=704201&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/AbstractUrlResourceLocation.java (added)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/AbstractUrlResourceLocation.java Mon Oct 13 11:52:25 2008
@@ -0,0 +1,53 @@
+/**
+ *  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.axis2.classloader;
+
+import java.net.URL;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public abstract class AbstractUrlResourceLocation implements ResourceLocation {
+    private final URL codeSource;
+
+    public AbstractUrlResourceLocation(URL codeSource) {
+        this.codeSource = codeSource;
+    }
+
+    public final URL getCodeSource() {
+        return codeSource;
+    }
+
+    public void close() {
+    }
+
+    public final boolean equals(Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+
+        AbstractUrlResourceLocation that = (AbstractUrlResourceLocation) o;
+        return codeSource.equals(that.codeSource);
+    }
+
+    public final int hashCode() {
+        return codeSource.hashCode();
+    }
+
+    public final String toString() {
+        return "[" + getClass().getName() + ": " + codeSource + "]";
+    }
+}

Propchange: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/AbstractUrlResourceLocation.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/AbstractUrlResourceLocation.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/AbstractUrlResourceLocation.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/DirectoryResourceHandle.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/DirectoryResourceHandle.java?rev=704201&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/DirectoryResourceHandle.java (added)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/DirectoryResourceHandle.java Mon Oct 13 11:52:25 2008
@@ -0,0 +1,97 @@
+/**
+ *  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.axis2.classloader;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.net.URL;
+import java.net.MalformedURLException;
+import java.security.cert.Certificate;
+import java.util.jar.Attributes;
+import java.util.jar.Manifest;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class DirectoryResourceHandle extends AbstractResourceHandle {
+    private final String name;
+    private final File file;
+    private final Manifest manifest;
+    private final URL url;
+    private final URL codeSource;
+
+    public DirectoryResourceHandle(String name, File file, File codeSource, Manifest manifest) throws MalformedURLException {
+        this.name = name;
+        this.file = file;
+        this.codeSource = codeSource.toURL();
+        this.manifest = manifest;
+        url = file.toURL();
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public URL getUrl() {
+        return url;
+    }
+
+    public URL getCodeSourceUrl() {
+        return codeSource;
+    }
+
+    public boolean isDirectory() {
+        return file.isDirectory();
+    }
+
+    public InputStream getInputStream() throws IOException {
+        if (file.isDirectory()) {
+            return new IoUtil.EmptyInputStream();
+        }
+        return new FileInputStream(file);
+    }
+
+    public int getContentLength() {
+        if (file.isDirectory() || file.length() > Integer.MAX_VALUE) {
+            return -1;
+        } else {
+            return (int) file.length();
+        }
+    }
+
+    public Manifest getManifest() throws IOException {
+        return manifest;
+    }
+
+    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 right now.
+     * @return null
+     */
+    public Certificate[] getCertificates() {
+        return null;
+    }
+}

Propchange: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/DirectoryResourceHandle.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/DirectoryResourceHandle.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/DirectoryResourceHandle.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/DirectoryResourceLocation.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/DirectoryResourceLocation.java?rev=704201&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/DirectoryResourceLocation.java (added)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/DirectoryResourceLocation.java Mon Oct 13 11:52:25 2008
@@ -0,0 +1,79 @@
+/**
+ *  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.axis2.classloader;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.util.jar.Manifest;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class DirectoryResourceLocation extends AbstractUrlResourceLocation {
+    private final File baseDir;
+    private boolean manifestLoaded = false;
+    private Manifest manifest;
+
+    public DirectoryResourceLocation(File baseDir) throws MalformedURLException {
+        super(baseDir.toURL());
+        this.baseDir = baseDir;
+    }
+
+    public ResourceHandle getResourceHandle(String resourceName) {
+        File file = new File(baseDir, resourceName);
+        if (!file.exists()) {
+            return null;
+        }
+
+        try {
+            ResourceHandle resourceHandle = new DirectoryResourceHandle(resourceName, file, baseDir, getManifestSafe());
+            return resourceHandle;
+        } catch (MalformedURLException e) {
+            return null;
+        }
+    }
+
+    public Manifest getManifest() throws IOException {
+        if (!manifestLoaded) {
+            File manifestFile = new File(baseDir, "META-INF/MANIFEST.MF");
+
+            if (manifestFile.isFile() && manifestFile.canRead()) {
+                FileInputStream in = null;
+                try {
+                    in = new FileInputStream(manifestFile);
+                    manifest = new Manifest(in);
+                } finally {
+                    IoUtil.close(in);
+                }
+            }
+            manifestLoaded = true;
+        }
+        return manifest;
+    }
+
+    private Manifest getManifestSafe() {
+        Manifest manifest = null;
+        try {
+            manifest = getManifest();
+        } catch (IOException e) {
+            // ignore
+        }
+        return manifest;
+    }
+}

Propchange: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/DirectoryResourceLocation.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/DirectoryResourceLocation.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/DirectoryResourceLocation.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/IoUtil.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/IoUtil.java?rev=704201&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/IoUtil.java (added)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/IoUtil.java Mon Oct 13 11:52:25 2008
@@ -0,0 +1,145 @@
+/**
+ *  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.axis2.classloader;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.Reader;
+import java.io.Writer;
+import java.util.jar.JarFile;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public final class IoUtil {
+    private IoUtil() {
+    }
+
+    public static byte[] getBytes(InputStream inputStream) throws IOException {
+        try {
+            byte[] buffer = new byte[4096];
+            ByteArrayOutputStream out = new ByteArrayOutputStream();
+            for (int count = inputStream.read(buffer); count >= 0; count = inputStream.read(buffer)) {
+                out.write(buffer, 0, count);
+            }
+            byte[] bytes = out.toByteArray();
+            return bytes;
+        } finally {
+            close(inputStream);
+        }
+    }
+
+    public static void flush(OutputStream thing) {
+        if (thing != null) {
+            try {
+                thing.flush();
+            } catch(Exception ignored) {
+            }
+        }
+    }
+
+    public static void flush(Writer thing) {
+        if (thing != null) {
+            try {
+                thing.flush();
+            } catch(Exception ignored) {
+            }
+        }
+    }
+
+    public static void close(JarFile thing) {
+        if (thing != null) {
+            try {
+                thing.close();
+            } catch(Exception ignored) {
+            }
+        }
+    }
+
+    public static void close(InputStream thing) {
+        if (thing != null) {
+            try {
+                thing.close();
+            } catch(Exception ignored) {
+            }
+        }
+    }
+
+    public static void close(OutputStream thing) {
+        if (thing != null) {
+            try {
+                thing.close();
+            } catch(Exception ignored) {
+            }
+        }
+    }
+
+    public static void close(Reader thing) {
+        if (thing != null) {
+            try {
+                thing.close();
+            } catch(Exception ignored) {
+            }
+        }
+    }
+
+    public static void close(Writer thing) {
+        if (thing != null) {
+            try {
+                thing.close();
+            } catch(Exception ignored) {
+            }
+        }
+    }
+
+    public static final class EmptyInputStream extends InputStream {
+        public int read() {
+            return -1;
+        }
+
+        public int read(byte b[])  {
+            return -1;
+        }
+
+        public int read(byte b[], int off, int len) {
+            return -1;
+        }
+
+        public long skip(long n) {
+            return 0;
+        }
+
+        public int available() {
+            return 0;
+        }
+
+        public void close() {
+        }
+
+        public synchronized void mark(int readlimit) {
+        }
+
+        public synchronized void reset() {
+        }
+
+        public boolean markSupported() {
+            return false;
+        }
+    }
+}

Propchange: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/IoUtil.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/IoUtil.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/IoUtil.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/JarFileClassLoader.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/JarFileClassLoader.java?rev=704201&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/JarFileClassLoader.java (added)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/JarFileClassLoader.java Mon Oct 13 11:52:25 2008
@@ -0,0 +1,350 @@
+/**
+ *  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.axis2.classloader;
+
+import java.io.IOException;
+import java.io.File;
+import java.net.URL;
+import java.net.URI;
+import java.net.URLClassLoader;
+import java.security.AccessControlContext;
+import java.security.AccessController;
+import java.security.CodeSource;
+import java.security.PrivilegedAction;
+import java.security.PrivilegedExceptionAction;
+import java.security.PrivilegedActionException;
+import java.security.cert.Certificate;
+import java.util.Collection;
+import java.util.Enumeration;
+import java.util.jar.Attributes;
+import java.util.jar.Manifest;
+
+/**
+ * The JarFileClassLoader that loads classes and resources from a list of JarFiles.  This method is simmilar to URLClassLoader
+ * except it properly closes JarFiles when the classloader is destroyed so that the file read lock will be released, and
+ * the jar file can be modified and deleted.
+ * <p>
+ *
+ * @version $Rev$ $Date$
+ */
+public class JarFileClassLoader extends MultiParentClassLoader {
+    private static final URL[] EMPTY_URLS = new URL[0];
+
+    private final UrlResourceFinder resourceFinder = new UrlResourceFinder();
+    private final AccessControlContext acc;
+
+    /**
+     * Creates a JarFileClassLoader that is a child of the system class loader.
+     * @param urls a list of URLs from which classes and resources should be loaded
+     */
+    public JarFileClassLoader(URL[] urls) {
+        super(EMPTY_URLS);
+        this.acc = AccessController.getContext();
+        addURLs(urls);
+    }
+
+    /**
+     * Creates a JarFileClassLoader that is a child of the specified class loader.
+     * @param urls a list of URLs from which classes and resources should be loaded
+     * @param parent the parent of this class loader
+     */
+    public JarFileClassLoader(URL[] urls, ClassLoader parent) {
+        super(EMPTY_URLS, parent);
+        this.acc = AccessController.getContext();
+        addURLs(urls);
+    }
+
+    public JarFileClassLoader(URL[] urls, ClassLoader parent, boolean inverseClassLoading, String[] hiddenClasses, String[] nonOverridableClasses) {
+        super(EMPTY_URLS, parent, inverseClassLoading, hiddenClasses, nonOverridableClasses);
+        this.acc = AccessController.getContext();
+        addURLs(urls);
+    }
+
+    /**
+     * Creates a named class loader as a child of the specified parents.
+     * @param urls the urls from which this class loader will classes and resources
+     * @param parents the parents of this class loader
+     */
+    public JarFileClassLoader(URL[] urls, ClassLoader[] parents) {
+        super(EMPTY_URLS, parents);
+        this.acc = AccessController.getContext();
+        addURLs(urls);
+    }
+
+    public JarFileClassLoader(URL[] urls, ClassLoader[] parents, boolean inverseClassLoading, Collection hiddenClasses, Collection nonOverridableClasses) {
+        super(EMPTY_URLS, parents, inverseClassLoading, hiddenClasses, nonOverridableClasses);
+        this.acc = AccessController.getContext();
+        addURLs(urls);
+    }
+
+    public JarFileClassLoader(URL[] urls, ClassLoader[] parents, boolean inverseClassLoading, String[] hiddenClasses, String[] nonOverridableClasses) {
+        super(EMPTY_URLS, parents, inverseClassLoading, hiddenClasses, nonOverridableClasses);
+        this.acc = AccessController.getContext();
+        addURLs(urls);
+    }
+
+    public JarFileClassLoader(JarFileClassLoader source) {
+        super(source);
+        this.acc = AccessController.getContext();
+        addURLs(source.getURLs());
+    }
+
+    public static ClassLoader copy(ClassLoader source) {
+        if (source instanceof JarFileClassLoader) {
+            return new JarFileClassLoader((JarFileClassLoader) source);
+        } else if (source instanceof MultiParentClassLoader) {
+            return new MultiParentClassLoader((MultiParentClassLoader) source);
+        } else if (source instanceof URLClassLoader) {
+            return new URLClassLoader(((URLClassLoader)source).getURLs(), source.getParent());
+        } else {
+            return new URLClassLoader(new URL[0], source);
+        }
+    }
+
+    ClassLoader copy() {
+        return JarFileClassLoader.copy(this);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public URL[] getURLs() {
+        return resourceFinder.getUrls();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void addURL(final URL url) {
+        AccessController.doPrivileged(new PrivilegedAction() {
+            public Object run() {
+                resourceFinder.addUrl(url);
+                return null;
+            }
+        }, acc);
+    }
+
+    /**
+     * Adds an array of urls to the end of this class loader.
+     * @param urls the URLs to add
+     */
+    protected void addURLs(final URL[] urls) {
+        AccessController.doPrivileged(new PrivilegedAction() {
+            public Object run() {
+                resourceFinder.addUrls(urls);
+                return null;
+            }
+        }, acc);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void destroy() {
+        resourceFinder.destroy();
+        super.destroy();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public URL findResource(final String resourceName) {
+        return (URL) AccessController.doPrivileged(new PrivilegedAction() {
+            public Object run() {
+                return resourceFinder.findResource(resourceName);
+            }
+        }, acc);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    protected Enumeration<URL> internalfindResources(final String name) throws IOException {
+        return  AccessController.doPrivileged(new PrivilegedAction<Enumeration<URL>>() {
+            public Enumeration<URL> run() {
+                return resourceFinder.findResources(name);
+            }
+        }, acc);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    protected String findLibrary(String libraryName) {
+        // if the libraryName is actually a directory it is invalid
+        int pathEnd = libraryName.lastIndexOf('/');
+        if (pathEnd == libraryName.length() - 1) {
+            throw new IllegalArgumentException("libraryName ends with a '/' character: " + libraryName);
+        }
+
+        // get the name if the library file
+        final String resourceName;
+        if (pathEnd < 0) {
+            resourceName = System.mapLibraryName(libraryName);
+        } else {
+            String path = libraryName.substring(0, pathEnd + 1);
+            String file = libraryName.substring(pathEnd + 1);
+            resourceName = path + System.mapLibraryName(file);
+        }
+
+        // get a resource handle to the library
+        ResourceHandle resourceHandle = (ResourceHandle) AccessController.doPrivileged(new PrivilegedAction() {
+            public Object run() {
+                return resourceFinder.getResource(resourceName);
+            }
+        }, acc);
+
+        if (resourceHandle == null) {
+            return null;
+        }
+
+        // the library must be accessable on the file system
+        URL url = resourceHandle.getUrl();
+        if (!"file".equals(url.getProtocol())) {
+            return null;
+        }
+
+        String path = new File(URI.create(url.toString())).getPath();
+        return path;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    protected Class findClass(final String className) throws ClassNotFoundException {
+        try {
+            return (Class) AccessController.doPrivileged(new PrivilegedExceptionAction() {
+                public Object run() throws ClassNotFoundException {
+                    // first think check if we are allowed to define the package
+                    SecurityManager securityManager = System.getSecurityManager();
+                    if (securityManager != null) {
+                        String packageName;
+                        int packageEnd = className.lastIndexOf('.');
+                        if (packageEnd >= 0) {
+                            packageName = className.substring(0, packageEnd);
+                            securityManager.checkPackageDefinition(packageName);
+                        }
+                    }
+
+
+                    // convert the class name to a file name
+                    String resourceName = className.replace('.', '/') + ".class";
+
+                    // find the class file resource
+                    ResourceHandle resourceHandle = resourceFinder.getResource(resourceName);
+                    if (resourceHandle == null) {
+                        throw new ClassNotFoundException(className);
+                    }
+
+                    byte[] bytes;
+                    Manifest manifest;
+                    try {
+                        // get the bytes from the class file
+                        bytes = resourceHandle.getBytes();
+
+                        // get the manifest for defining the packages
+                        manifest = resourceHandle.getManifest();
+                    } catch (IOException e) {
+                        throw new ClassNotFoundException(className, e);
+                    }
+
+                    // get the certificates for the code source
+                    Certificate[] certificates = resourceHandle.getCertificates();
+
+                    // the code source url is used to define the package and as the security context for the class
+                    URL codeSourceUrl = resourceHandle.getCodeSourceUrl();
+
+                    // define the package (required for security)
+                    definePackage(className, codeSourceUrl, manifest);
+
+                    // this is the security context of the class
+                    CodeSource codeSource = new CodeSource(codeSourceUrl, certificates);
+
+                    // load the class into the vm
+                    Class clazz = defineClass(className, bytes, 0, bytes.length, codeSource);
+                    return clazz;
+                }
+            }, acc);
+        } catch (PrivilegedActionException e) {
+            throw (ClassNotFoundException) e.getException();
+        }
+    }
+
+    private void definePackage(String className, URL jarUrl, Manifest manifest) {
+        int packageEnd = className.lastIndexOf('.');
+        if (packageEnd < 0) {
+            return;
+        }
+
+        String packageName = className.substring(0, packageEnd);
+        String packagePath = packageName.replace('.', '/') + "/";
+
+        Attributes packageAttributes = null;
+        Attributes mainAttributes = null;
+        if (manifest != null) {
+            packageAttributes = manifest.getAttributes(packagePath);
+            mainAttributes = manifest.getMainAttributes();
+        }
+        Package pkg = getPackage(packageName);
+        if (pkg != null) {
+            if (pkg.isSealed()) {
+                if (!pkg.isSealed(jarUrl)) {
+                    throw new SecurityException("Package was already sealed with another URL: package=" + packageName + ", url=" + jarUrl);
+                }
+            } else {
+                if (isSealed(packageAttributes, mainAttributes)) {
+                    throw new SecurityException("Package was already been loaded and not sealed: package=" + packageName + ", url=" + jarUrl);
+                }
+            }
+        } else {
+            String specTitle = getAttribute(Attributes.Name.SPECIFICATION_TITLE, packageAttributes, mainAttributes);
+            String specVendor = getAttribute(Attributes.Name.SPECIFICATION_VENDOR, packageAttributes, mainAttributes);
+            String specVersion = getAttribute(Attributes.Name.SPECIFICATION_VERSION, packageAttributes, mainAttributes);
+            String implTitle = getAttribute(Attributes.Name.IMPLEMENTATION_TITLE, packageAttributes, mainAttributes);
+            String implVendor = getAttribute(Attributes.Name.IMPLEMENTATION_VENDOR, packageAttributes, mainAttributes);
+            String implVersion = getAttribute(Attributes.Name.IMPLEMENTATION_VERSION, packageAttributes, mainAttributes);
+
+            URL sealBase = null;
+            if (isSealed(packageAttributes, mainAttributes)) {
+                sealBase = jarUrl;
+            }
+
+            definePackage(packageName, specTitle, specVersion, specVendor, implTitle, implVersion, implVendor, sealBase);
+        }
+    }
+
+    private String getAttribute(Attributes.Name name, Attributes packageAttributes, Attributes mainAttributes) {
+        if (packageAttributes != null) {
+            String value = packageAttributes.getValue(name);
+            if (value != null) {
+                return value;
+            }
+        }
+        if (mainAttributes != null) {
+            return mainAttributes.getValue(name);
+        }
+        return null;
+    }
+
+    private boolean isSealed(Attributes packageAttributes, Attributes mainAttributes) {
+        String sealed = getAttribute(Attributes.Name.SEALED, packageAttributes, mainAttributes);
+        if (sealed == null) {
+            return false;
+        }
+        return "true".equalsIgnoreCase(sealed);
+    }
+}
\ No newline at end of file

Propchange: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/JarFileClassLoader.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/JarFileClassLoader.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/JarFileClassLoader.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/JarResourceHandle.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/JarResourceHandle.java?rev=704201&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/JarResourceHandle.java (added)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/JarResourceHandle.java Mon Oct 13 11:52:25 2008
@@ -0,0 +1,80 @@
+/**
+ *  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.axis2.classloader;
+
+import java.util.jar.JarFile;
+import java.util.jar.JarEntry;
+import java.util.jar.Manifest;
+import java.util.jar.Attributes;
+import java.net.URL;
+import java.net.MalformedURLException;
+import java.io.InputStream;
+import java.io.IOException;
+import java.security.cert.Certificate;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class JarResourceHandle extends AbstractResourceHandle {
+    private final JarFile jarFile;
+    private final JarEntry jarEntry;
+    private final URL url;
+    private final URL codeSource;
+
+    public JarResourceHandle(JarFile jarFile, JarEntry jarEntry, URL codeSource) throws MalformedURLException {
+        this.jarFile = jarFile;
+        this.jarEntry = jarEntry;
+        this.url = JarFileUrlStreamHandler.createUrl(jarFile, jarEntry, codeSource);
+        this.codeSource = codeSource;
+    }
+
+    public String getName() {
+        return jarEntry.getName();
+    }
+
+    public URL getUrl() {
+        return url;
+    }
+
+    public URL getCodeSourceUrl() {
+        return codeSource;
+    }
+
+    public boolean isDirectory() {
+        return jarEntry.isDirectory();
+    }
+
+    public InputStream getInputStream() throws IOException {
+        return jarFile.getInputStream(jarEntry);
+    }
+
+    public int getContentLength() {
+        return (int) jarEntry.getSize();
+    }
+
+    public Manifest getManifest() throws IOException {
+        return jarFile.getManifest();
+    }
+
+    public Attributes getAttributes() throws IOException {
+        return jarEntry.getAttributes();
+    }
+
+    public Certificate[] getCertificates() {
+        return jarEntry.getCertificates();
+    }
+}

Propchange: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/JarResourceHandle.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/JarResourceHandle.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/JarResourceHandle.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/JarResourceLocation.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/JarResourceLocation.java?rev=704201&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/JarResourceLocation.java (added)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/JarResourceLocation.java Mon Oct 13 11:52:25 2008
@@ -0,0 +1,151 @@
+/**
+ *  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.axis2.classloader;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+import java.util.jar.JarInputStream;
+import java.util.jar.Manifest;
+import java.util.zip.ZipException;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class JarResourceLocation extends AbstractUrlResourceLocation {
+    private JarFile jarFile;
+    private byte content[];
+
+    public JarResourceLocation(URL codeSource, File cacheFile) throws IOException {
+        super(codeSource);
+        try {
+            jarFile = new JarFile(cacheFile);
+        } catch (ZipException ze) {
+            // We get this exception on windows when the
+            // path to the jar file gets too long (Bug ID: 6374379)
+            InputStream is = null;
+            try {
+                is = new FileInputStream(cacheFile);
+                ByteArrayOutputStream baos = new ByteArrayOutputStream();
+                byte[] buffer = new byte[2048];
+                int bytesRead = -1;
+                while ((bytesRead = is.read(buffer)) != -1) {
+                    baos.write(buffer, 0, bytesRead);
+                }
+                this.content = baos.toByteArray();
+            } finally {
+                if (is != null) {
+                    is.close();
+                }
+            }
+        }
+    }
+
+    public ResourceHandle getResourceHandle(String resourceName) {
+        if (jarFile != null) {
+            JarEntry jarEntry = jarFile.getJarEntry(resourceName);
+            if (jarEntry != null) {
+                try {
+                    URL url = new URL(getCodeSource(), resourceName);
+                    return new JarResourceHandle(jarFile, jarEntry, getCodeSource());
+                } catch (MalformedURLException e) {
+                }
+            }
+        } else {
+            try {
+                final JarInputStream is = new JarInputStream(new ByteArrayInputStream(this.content));
+                JarEntry jarEntry = null;
+                while ((jarEntry = is.getNextJarEntry()) != null) {
+                    if (jarEntry.getName().equals(resourceName)) {
+                        try {
+                            URL url = new URL(getCodeSource(), resourceName);
+                            final JarEntry jarEntry2 = jarEntry;
+                            return new JarEntryResourceHandle(jarEntry2, is);
+                        } catch (MalformedURLException e) {
+                        }
+                    }
+                }
+            } catch (IOException e) {
+            }
+        }
+        return null;
+    }
+
+    public Manifest getManifest() throws IOException {
+        if (jarFile != null) {
+            return jarFile.getManifest();
+        } else {
+            try {
+                JarInputStream is = new JarInputStream(new ByteArrayInputStream(this.content));
+                return is.getManifest();
+            } catch (IOException e) {
+            }
+        }
+        return null;
+    }
+
+    public void close() {
+        if (jarFile != null) {
+            IoUtil.close(jarFile);
+        }
+    }
+
+    private class JarEntryResourceHandle extends AbstractResourceHandle {
+        private final JarEntry jarEntry2;
+        private final JarInputStream is;
+
+        public JarEntryResourceHandle(JarEntry jarEntry2, JarInputStream is) {
+            this.jarEntry2 = jarEntry2;
+            this.is = is;
+        }
+
+        public String getName() {
+            return jarEntry2.getName();
+        }
+
+        public URL getUrl() {
+            try {
+                return new URL("jar", "", -1, getCodeSource() + "!/" + jarEntry2.getName());
+            } catch (MalformedURLException e) {
+                throw new RuntimeException(e);
+            }
+        }
+
+        public boolean isDirectory() {
+            return jarEntry2.isDirectory();
+        }
+
+        public URL getCodeSourceUrl() {
+            return getCodeSource();
+        }
+
+        public InputStream getInputStream() throws IOException {
+            return is;
+        }
+
+        public int getContentLength() {
+            return (int) jarEntry2.getSize();
+        }
+    }
+}

Propchange: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/JarResourceLocation.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/JarResourceLocation.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/JarResourceLocation.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/MultiParentClassLoader.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/MultiParentClassLoader.java?rev=704201&r1=704200&r2=704201&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/MultiParentClassLoader.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/MultiParentClassLoader.java Mon Oct 13 11:52:25 2008
@@ -128,6 +128,24 @@
         nonOverridableResources = toResources(nonOverridableClasses);
     }
 
+    public MultiParentClassLoader(MultiParentClassLoader source) {
+        this(source.getURLs(), deepCopyParents(source.parents), source.inverseClassLoading, source.hiddenClasses, source.nonOverridableClasses);
+    }
+
+    static ClassLoader copy(ClassLoader source) {
+        if (source instanceof MultiParentClassLoader) {
+            return new MultiParentClassLoader((MultiParentClassLoader) source);
+        } else if (source instanceof URLClassLoader) {
+            return new URLClassLoader(((URLClassLoader) source).getURLs(), source.getParent());
+        } else {
+            return new URLClassLoader(new URL[0], source);
+        }
+    }
+
+    ClassLoader copy() {
+        return MultiParentClassLoader.copy(this);
+    }
+
     private String[] toResources(String[] classes) {
         String[] resources = new String[classes.length];
         for (int i = 0; i < classes.length; i++) {
@@ -168,6 +186,21 @@
         return newParentsArray;
     }
 
+    private static ClassLoader[] deepCopyParents(ClassLoader[] parents) {
+        ClassLoader[] newParentsArray = new ClassLoader[parents.length];
+        for (int i = 0; i < parents.length; i++) {
+            ClassLoader parent = parents[i];
+            if (parent == null) {
+                throw new RuntimeException("parent[" + i + "] is null");
+            }
+            if (parent instanceof MultiParentClassLoader) {
+                parent = ((MultiParentClassLoader) parent).copy();
+            }
+            newParentsArray[i] = parent;
+        }
+        return newParentsArray;
+    }
+
     /**
      * Gets the parents of this class loader.
      *

Added: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/ResourceEnumeration.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/ResourceEnumeration.java?rev=704201&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/ResourceEnumeration.java (added)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/ResourceEnumeration.java Mon Oct 13 11:52:25 2008
@@ -0,0 +1,83 @@
+/**
+ *  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.axis2.classloader;
+
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.Collection;
+import java.util.NoSuchElementException;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ResourceEnumeration implements Enumeration {
+    private Iterator iterator;
+    private final String resourceName;
+    private Object next;
+
+    public ResourceEnumeration(Collection resourceLocations, String resourceName) {
+        this.iterator = resourceLocations.iterator();
+        this.resourceName = resourceName;
+    }
+
+    public boolean hasMoreElements() {
+        fetchNext();
+        return (next != null);
+    }
+
+    public Object nextElement() {
+        fetchNext();
+
+        // save next into a local variable and clear the next field
+        Object next = this.next;
+        this.next = null;
+
+        // if we didn't have a next throw an exception
+        if (next == null) {
+            throw new NoSuchElementException();
+        }
+        return next;
+    }
+
+    private void fetchNext() {
+        if (iterator == null) {
+            return;
+        }
+        if (next != null) {
+            return;
+        }
+
+        try {
+            while (iterator.hasNext()) {
+                ResourceLocation resourceLocation = (ResourceLocation) iterator.next();
+                ResourceHandle resourceHandle = resourceLocation.getResourceHandle(resourceName);
+                if (resourceHandle != null) {
+                    next = resourceHandle.getUrl();
+                    return;
+                }
+            }
+            // no more elements
+            // clear the iterator so it can be GCed
+            iterator = null;
+        } catch (IllegalStateException e) {
+            // Jar file was closed... this means the resource finder was destroyed
+            // clear the iterator so it can be GCed
+            iterator = null;
+            throw e;
+        }
+    }
+}

Propchange: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/ResourceEnumeration.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/ResourceEnumeration.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/ResourceEnumeration.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/ResourceFinder.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/ResourceFinder.java?rev=704201&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/ResourceFinder.java (added)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/ResourceFinder.java Mon Oct 13 11:52:25 2008
@@ -0,0 +1,55 @@
+/**
+ *  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.axis2.classloader;
+
+import java.net.URL;
+import java.util.Enumeration;
+
+/**
+ * Abstraction of resource searching policy. Given resource name, the resource
+ * finder performs implementation-specific lookup, and, if it is able to locate
+ * the resource, returns the {@link AbstractResourceHandle handle(s)} or URL(s) of it.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface ResourceFinder {
+    /**
+     * Find the resource by name and return URL of it if found.
+     *
+     * @param name the resource name
+     * @return resource URL or null if resource was not found
+     */
+    public URL findResource(String name);
+
+    /**
+     * Find all resources with given name and return enumeration of their URLs.
+     *
+     * @param name the resource name
+     * @return enumeration of resource URLs (possibly empty).
+     */
+    public Enumeration findResources(String name);
+
+    /**
+     * Get the resource by name and, if found, open connection to it and return
+     * the {@link AbstractResourceHandle handle} of it.
+     *
+     * @param name the resource name
+     * @return resource handle or null if resource was not found
+     */
+    public ResourceHandle getResource(String name);
+
+}

Propchange: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/ResourceFinder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/ResourceFinder.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/ResourceFinder.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/ResourceHandle.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/ResourceHandle.java?rev=704201&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/ResourceHandle.java (added)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/ResourceHandle.java Mon Oct 13 11:52:25 2008
@@ -0,0 +1,97 @@
+/**
+ *  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.axis2.classloader;
+
+import java.net.URL;
+import java.io.InputStream;
+import java.io.IOException;
+import java.util.jar.Manifest;
+import java.util.jar.Attributes;
+import java.security.cert.Certificate;
+
+/**
+ * This is a handle (a connection) to some resource, which may
+ * be a class, native library, text file, image, etc. Handles are returned
+ * by a ResourceFinder. A resource handle allows easy access to the resource data
+ * (using methods {@link #getInputStream} or {@link #getBytes}) as well as
+ * access resource metadata, such as attributes, certificates, etc.
+ * <p/>
+ * As soon as the handle is no longer in use, it should be explicitly
+ * {@link #close}d, similarly to I/O streams.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface ResourceHandle {
+    /**
+     * Return the name of the resource. The name is a "/"-separated path
+     * name that identifies the resource.
+     */
+    String getName();
+
+    /**
+     * Returns the URL of the resource.
+     */
+    URL getUrl();
+
+    /**
+     * Does this resource refer to a directory.  Directory resources are commly used
+     * as the basis for a URL in client application.  A directory resource has 0 bytes for it's content. 
+     */
+    boolean isDirectory();
+
+    /**
+     * Returns the CodeSource URL for the class or resource.
+     */
+    URL getCodeSourceUrl();
+
+    /**
+     * Returns and InputStream for reading this resource data.
+     */
+    InputStream getInputStream() throws IOException;
+
+    /**
+     * Returns the length of this resource data, or -1 if unknown.
+     */
+    int getContentLength();
+
+    /**
+     * Returns this resource data as an array of bytes.
+     */
+    byte[] getBytes() throws IOException;
+
+    /**
+     * Returns the Manifest of the JAR file from which this resource
+     * was loaded, or null if none.
+     */
+    Manifest getManifest() throws IOException;
+
+    /**
+     * Return the Certificates of the resource, or null if none.
+     */
+    Certificate[] getCertificates();
+
+    /**
+     * Return the Attributes of the resource, or null if none.
+     */
+    Attributes getAttributes() throws IOException;
+
+    /**
+     * Closes a connection to the resource indentified by this handle. Releases
+     * any I/O objects associated with the handle.
+     */
+    void close();
+}

Propchange: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/ResourceHandle.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/ResourceHandle.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/ResourceHandle.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/ResourceLocation.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/ResourceLocation.java?rev=704201&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/ResourceLocation.java (added)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/ResourceLocation.java Mon Oct 13 11:52:25 2008
@@ -0,0 +1,33 @@
+/**
+ *  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.axis2.classloader;
+
+import java.util.jar.Manifest;
+import java.io.IOException;
+import java.net.URL;
+
+/**
+ * This is a location which is searched by
+ * 
+ * @version $Rev$ $Date$
+ */
+public interface ResourceLocation {
+    URL getCodeSource();    
+    ResourceHandle getResourceHandle(String resourceName);
+    Manifest getManifest() throws IOException;
+    void close();
+}

Propchange: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/ResourceLocation.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/ResourceLocation.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/ResourceLocation.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/UrlResourceFinder.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/UrlResourceFinder.java?rev=704201&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/UrlResourceFinder.java (added)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/UrlResourceFinder.java Mon Oct 13 11:52:25 2008
@@ -0,0 +1,293 @@
+/**
+ *  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.axis2.classloader;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.StringTokenizer;
+import java.util.jar.Attributes;
+import java.util.jar.Manifest;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class UrlResourceFinder implements ResourceFinder {
+    private final Object lock = new Object();
+    private final LinkedHashSet<URL> urls = new LinkedHashSet<URL>();
+    private final LinkedHashMap<URL,ResourceLocation> classPath = new LinkedHashMap<URL,ResourceLocation>();
+    private final LinkedHashSet<File> watchedFiles = new LinkedHashSet<File>();
+
+    private boolean destroyed = false;
+
+    public UrlResourceFinder() {
+    }
+
+    public UrlResourceFinder(URL[] urls) {
+        addUrls(urls);
+    }
+
+    public void destroy() {
+        synchronized (lock) {
+            if (destroyed) {
+                return;
+            }
+            destroyed = true;
+            urls.clear();
+            for (ResourceLocation resourceLocation : classPath.values()) {
+                resourceLocation.close();
+            }
+            classPath.clear();
+        }
+    }
+
+    public ResourceHandle getResource(String resourceName) {
+        synchronized (lock) {
+            if (destroyed) {
+                return null;
+            }
+            for (Map.Entry<URL, ResourceLocation> entry : getClassPath().entrySet()) {
+                ResourceLocation resourceLocation = entry.getValue();
+                ResourceHandle resourceHandle = resourceLocation.getResourceHandle(resourceName);
+                if (resourceHandle != null && !resourceHandle.isDirectory()) {
+                    return resourceHandle;
+                }
+            }
+        }
+        return null;
+    }
+
+    public URL findResource(String resourceName) {
+        synchronized (lock) {
+            if (destroyed) {
+                return null;
+            }
+            for (Map.Entry<URL, ResourceLocation> entry : getClassPath().entrySet()) {
+                ResourceLocation resourceLocation = entry.getValue();
+                ResourceHandle resourceHandle = resourceLocation.getResourceHandle(resourceName);
+                if (resourceHandle != null) {
+                    return resourceHandle.getUrl();
+                }
+            }
+        }
+        return null;
+    }
+
+    public Enumeration findResources(String resourceName) {
+        synchronized (lock) {
+            return new ResourceEnumeration(new ArrayList<ResourceLocation>(getClassPath().values()), resourceName);
+        }
+    }
+
+    public void addUrl(URL url) {
+        addUrls(Collections.singletonList(url));
+    }
+
+    public URL[] getUrls() {
+        synchronized (lock) {
+            return urls.toArray(new URL[urls.size()]);
+        }
+    }
+
+    /**
+     * Adds an array of urls to the end of this class loader.
+     * @param urls the URLs to add
+     */
+    protected void addUrls(URL[] urls) {
+        addUrls(Arrays.asList(urls));
+    }
+
+    /**
+     * Adds a list of urls to the end of this class loader.
+     * @param urls the URLs to add
+     */
+    protected void addUrls(List<URL> urls) {
+        synchronized (lock) {
+            if (destroyed) {
+                throw new IllegalStateException("UrlResourceFinder has been destroyed");
+            }
+
+            boolean shouldRebuild = this.urls.addAll(urls);
+            if (shouldRebuild) {
+                rebuildClassPath();
+            }
+        }
+    }
+
+    private LinkedHashMap<URL, ResourceLocation> getClassPath() {
+        assert Thread.holdsLock(lock): "This method can only be called while holding the lock";
+
+        for (File file : watchedFiles) {
+            if (file.canRead()) {
+                rebuildClassPath();
+                break;
+            }
+        }
+
+        return classPath;
+    }
+
+    /**
+     * Rebuilds the entire class path.  This class is called when new URLs are added or one of the watched files
+     * becomes readable.  This method will not open jar files again, but will add any new entries not alredy open
+     * to the class path.  If any file based url is does not exist, we will watch for that file to appear.
+     */
+    private void rebuildClassPath() {
+        assert Thread.holdsLock(lock): "This method can only be called while holding the lock";
+
+        // copy all of the existing locations into a temp map and clear the class path
+        Map<URL,ResourceLocation> existingJarFiles = new LinkedHashMap<URL,ResourceLocation>(classPath);
+        classPath.clear();
+
+        LinkedList<URL> locationStack = new LinkedList<URL>(urls);
+        try {
+            while (!locationStack.isEmpty()) {
+                URL url = locationStack.removeFirst();
+
+                // Skip any duplicate urls in the classpath
+                if (classPath.containsKey(url)) {
+                    continue;
+                }
+
+                // Check is this URL has already been opened
+                ResourceLocation resourceLocation = existingJarFiles.remove(url);
+
+                // If not opened, cache the url and wrap it with a resource location
+                if (resourceLocation == null) {
+                    try {
+                        File file = cacheUrl(url);
+                        resourceLocation = createResourceLocation(url, file);
+                    } catch (FileNotFoundException e) {
+                        // if this is a file URL, the file doesn't exist yet... watch to see if it appears later
+                        if ("file".equals(url.getProtocol())) {
+                            File file = new File(url.getPath());
+                            watchedFiles.add(file);
+                            continue;
+
+                        }
+                    } catch (IOException ignored) {
+                        // can't seem to open the file... this is most likely a bad jar file
+                        // so don't keep a watch out for it because that would require lots of checking
+                        // Dain: We may want to review this decision later
+                        continue;
+                    } catch (UnsupportedOperationException ex) {
+                        // the protocol for the JAR file's URL is not supported.  This can occur when
+                        // the jar file is embedded in an EAR or CAR file.  Proceed but log the message.
+                        System.out.println("The protocol for the JAR file's URL is not supported" + ex);
+                        continue;
+                    }
+                }
+
+                // add the jar to our class path
+                classPath.put(resourceLocation.getCodeSource(), resourceLocation);
+
+                // push the manifest classpath on the stack (make sure to maintain the order)
+                List<URL> manifestClassPath = getManifestClassPath(resourceLocation);
+                locationStack.addAll(0, manifestClassPath);
+            }
+        } catch (Error e) {
+            destroy();
+            throw e;
+        }
+
+        for (ResourceLocation resourceLocation : existingJarFiles.values()) {
+            resourceLocation.close();
+        }
+    }
+
+    protected File cacheUrl(URL url) throws IOException {
+        if (!"file".equals(url.getProtocol())) {
+            // download the jar
+            throw new UnsupportedOperationException("Only local file jars are supported " + url);
+        }
+
+        File file = new File(url.getPath());
+        if (!file.exists()) {
+            throw new FileNotFoundException(file.getAbsolutePath());
+        }
+        if (!file.canRead()) {
+            throw new IOException("File is not readable: " + file.getAbsolutePath());
+        }
+        return file;
+    }
+
+    protected ResourceLocation createResourceLocation(URL codeSource, File cacheFile) throws IOException {
+        if (!cacheFile.exists()) {
+            throw new FileNotFoundException(cacheFile.getAbsolutePath());
+        }
+        if (!cacheFile.canRead()) {
+            throw new IOException("File is not readable: " + cacheFile.getAbsolutePath());
+        }
+
+        ResourceLocation resourceLocation;
+        if (cacheFile.isDirectory()) {
+            // DirectoryResourceLocation will only return "file" URLs within this directory
+            // do not user the DirectoryResourceLocation for non file based urls
+            resourceLocation = new DirectoryResourceLocation(cacheFile);
+        } else {
+            resourceLocation = new JarResourceLocation(codeSource, cacheFile);
+        }
+        return resourceLocation;
+    }
+
+    private List<URL> getManifestClassPath(ResourceLocation resourceLocation) {
+        try {
+            // get the manifest, if possible
+            Manifest manifest = resourceLocation.getManifest();
+            if (manifest == null) {
+                // some locations don't have a manifest
+                return Collections.EMPTY_LIST;
+            }
+
+            // get the class-path attribute, if possible
+            String manifestClassPath = manifest.getMainAttributes().getValue(Attributes.Name.CLASS_PATH);
+            if (manifestClassPath == null) {
+                return Collections.EMPTY_LIST;
+            }
+
+            // build the urls...
+            // the class-path attribute is space delimited
+            URL codeSource = resourceLocation.getCodeSource();
+            LinkedList<URL> classPathUrls = new LinkedList<URL>();
+            for (StringTokenizer tokenizer = new StringTokenizer(manifestClassPath, " "); tokenizer.hasMoreTokens();) {
+                String entry = tokenizer.nextToken();
+                try {
+                    // the class path entry is relative to the resource location code source
+                    URL entryUrl = new URL(codeSource, entry);
+                    classPathUrls.addLast(entryUrl);
+                } catch (MalformedURLException ignored) {
+                    // most likely a poorly named entry
+                }
+            }
+            return classPathUrls;
+        } catch (IOException ignored) {
+            // error opening the manifest
+            return Collections.EMPTY_LIST;
+        }
+    }
+}

Propchange: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/UrlResourceFinder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/UrlResourceFinder.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/classloader/UrlResourceFinder.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/DeploymentEngine.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/DeploymentEngine.java?rev=704201&r1=704200&r2=704201&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/DeploymentEngine.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/DeploymentEngine.java Mon Oct 13 11:52:25 2008
@@ -22,6 +22,7 @@
 
 import org.apache.axiom.om.OMElement;
 import org.apache.axis2.AxisFault;
+import org.apache.axis2.classloader.JarFileClassLoader;
 import org.apache.axis2.Constants;
 import org.apache.axis2.context.ConfigurationContext;
 import org.apache.axis2.context.ServiceContext;
@@ -1200,6 +1201,15 @@
      * Clean up the mess
      */
     public void cleanup() {
+        if (axisConfig.getModuleClassLoader() instanceof JarFileClassLoader) {
+            ((JarFileClassLoader)axisConfig.getModuleClassLoader()).destroy();
+        }
+        if (axisConfig.getServiceClassLoader() instanceof JarFileClassLoader) {
+            ((JarFileClassLoader)axisConfig.getServiceClassLoader()).destroy();
+        }
+        if (axisConfig.getSystemClassLoader() instanceof JarFileClassLoader) {
+            ((JarFileClassLoader)axisConfig.getSystemClassLoader()).destroy();
+        }
         if (scheduler != null) {
             scheduler.cleanup();
         }

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/util/Utils.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/util/Utils.java?rev=704201&r1=704200&r2=704201&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/util/Utils.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/util/Utils.java Mon Oct 13 11:52:25 2008
@@ -25,6 +25,7 @@
 import org.apache.axiom.soap.SOAP11Constants;
 import org.apache.axiom.soap.SOAP12Constants;
 import org.apache.axis2.AxisFault;
+import org.apache.axis2.classloader.JarFileClassLoader;
 import org.apache.axis2.Constants;
 import org.apache.axis2.context.ConfigurationContext;
 import org.apache.axis2.deployment.DeploymentClassLoader;
@@ -339,7 +340,11 @@
             classLoader = (URLClassLoader)AccessController
                     .doPrivileged(new PrivilegedAction() {
                         public Object run() {
-                            return new URLClassLoader(urllist, parent);
+                            if (useJarFileClassLoader()) {
+                                return new JarFileClassLoader(urllist, parent);
+                            } else {
+                                return new URLClassLoader(urllist, parent);
+                            }
                         }
                     });
             return classLoader;
@@ -348,6 +353,20 @@
         }
     }
 
+    private static boolean useJarFileClassLoader() {
+        // The JarFileClassLoader was created to address a locking problem seen only on Windows platforms.
+        // It carries with it a slight performance penalty that needs to be addressed.  Rather than make
+        // *nix OSes carry this burden we'll engage the JarFileClassLoader for Windows or if the user 
+        // specifically requests it.
+        boolean useJarFileClassLoader = false;
+        if (System.getProperty("org.apache.axis2.classloader.JarFileClassLoader") == null) {
+            useJarFileClassLoader = System.getProperty("os.name").startsWith("Windows");
+        } else {
+            useJarFileClassLoader = Boolean.getBoolean("org.apache.axis2.classloader.JarFileClassLoader");
+        }
+        return useJarFileClassLoader;
+    }
+    
     private static boolean addFiles(ArrayList urls, final File libfiles)
             throws MalformedURLException {
         Boolean exists = (Boolean)org.apache.axis2.java.security.AccessController