geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r432861 [1/3] - in /geronimo/xbean/branches/classloader: ./ xbean-classloaders/ xbean-classloaders/src/ xbean-classloaders/src/main/ xbean-classloaders/src/main/java/ xbean-classloaders/src/main/java/org/ xbean-classloaders/src/main/java/or...
Date Sat, 19 Aug 2006 18:56:30 GMT
Author: adc
Date: Sat Aug 19 11:56:27 2006
New Revision: 432861

URL: http://svn.apache.org/viewvc?rev=432861&view=rev
Log:
Moved the classloaders out to their own module

Added:
    geronimo/xbean/branches/classloader/xbean-classloaders/
    geronimo/xbean/branches/classloader/xbean-classloaders/LICENSE.txt   (with props)
    geronimo/xbean/branches/classloader/xbean-classloaders/NOTICE.txt   (with props)
    geronimo/xbean/branches/classloader/xbean-classloaders/pom.xml   (with props)
    geronimo/xbean/branches/classloader/xbean-classloaders/src/
    geronimo/xbean/branches/classloader/xbean-classloaders/src/main/
    geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/
    geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/
    geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/
    geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/
    geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/
    geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/
    geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/AbstractResourceHandle.java   (with props)
    geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/AbstractUrlResourceLocation.java   (with props)
    geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/ClassLoaderUtil.java   (with props)
    geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/DestroyableClassLoader.java   (with props)
    geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/DirectoryResourceHandle.java   (with props)
    geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/DirectoryResourceLocation.java   (with props)
    geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/IoUtil.java   (with props)
    geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/JarFileClassLoader.java   (with props)
    geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/JarFileUrlConnection.java   (with props)
    geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/JarFileUrlStreamHandler.java   (with props)
    geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/JarResourceHandle.java   (with props)
    geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/JarResourceLocation.java   (with props)
    geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/MultiParentClassLoader.java   (with props)
    geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/NamedClassLoader.java   (with props)
    geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/ResourceEnumeration.java   (with props)
    geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/ResourceFinder.java   (with props)
    geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/ResourceHandle.java   (with props)
    geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/ResourceLocation.java   (with props)
    geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/ThreadContextClassLoaderFactoryBean.java   (with props)
    geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/UnionEnumeration.java   (with props)
    geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/UrlResourceFinder.java   (with props)
    geronimo/xbean/branches/classloader/xbean-classloaders/src/main/resources/
    geronimo/xbean/branches/classloader/xbean-classloaders/src/main/resources/META-INF/
    geronimo/xbean/branches/classloader/xbean-classloaders/src/main/resources/META-INF/LICENSE
    geronimo/xbean/branches/classloader/xbean-classloaders/src/main/resources/META-INF/NOTICE
    geronimo/xbean/branches/classloader/xbean-classloaders/src/test/
    geronimo/xbean/branches/classloader/xbean-classloaders/src/test-data/
    geronimo/xbean/branches/classloader/xbean-classloaders/src/test-data/resourceFinderTest/
    geronimo/xbean/branches/classloader/xbean-classloaders/src/test-data/resourceFinderTest/jar1/
    geronimo/xbean/branches/classloader/xbean-classloaders/src/test-data/resourceFinderTest/jar1/resource
    geronimo/xbean/branches/classloader/xbean-classloaders/src/test-data/resourceFinderTest/jar2/
    geronimo/xbean/branches/classloader/xbean-classloaders/src/test-data/resourceFinderTest/jar2/resource
    geronimo/xbean/branches/classloader/xbean-classloaders/src/test/java/
    geronimo/xbean/branches/classloader/xbean-classloaders/src/test/java/org/
    geronimo/xbean/branches/classloader/xbean-classloaders/src/test/java/org/apache/
    geronimo/xbean/branches/classloader/xbean-classloaders/src/test/java/org/apache/xbean/
    geronimo/xbean/branches/classloader/xbean-classloaders/src/test/java/org/apache/xbean/server/
    geronimo/xbean/branches/classloader/xbean-classloaders/src/test/java/org/apache/xbean/server/classloader/
    geronimo/xbean/branches/classloader/xbean-classloaders/src/test/java/org/apache/xbean/server/classloader/JarFileClassLoaderTest.java   (with props)
    geronimo/xbean/branches/classloader/xbean-classloaders/src/test/java/org/apache/xbean/server/classloader/MultiParentClassLoaderTest.java   (with props)
    geronimo/xbean/branches/classloader/xbean-classloaders/src/test/java/org/apache/xbean/server/classloader/UrlResourceFinderTest.java   (with props)
Removed:
    geronimo/xbean/branches/classloader/xbean-server/src/main/java/org/apache/xbean/server/classloader/
    geronimo/xbean/branches/classloader/xbean-server/src/test-data/
    geronimo/xbean/branches/classloader/xbean-server/src/test/java/org/apache/xbean/server/classloader/
Modified:
    geronimo/xbean/branches/classloader/pom.xml
    geronimo/xbean/branches/classloader/xbean-server/pom.xml

Modified: geronimo/xbean/branches/classloader/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/xbean/branches/classloader/pom.xml?rev=432861&r1=432860&r2=432861&view=diff
==============================================================================
--- geronimo/xbean/branches/classloader/pom.xml (original)
+++ geronimo/xbean/branches/classloader/pom.xml Sat Aug 19 11:56:27 2006
@@ -133,6 +133,7 @@
   </profiles>
   <modules>
     <module>xbean-classpath</module>
+    <module>xbean-classloaders</module>
     <module>xbean-kernel</module>
     <module>xbean-osgi</module>
     <module>xbean-reflect</module>
@@ -229,6 +230,11 @@
         <groupId>org.springframework</groupId>
         <artifactId>spring</artifactId>
         <version>1.2.4</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.xbean</groupId>
+        <artifactId>xbean-classloaders</artifactId>
+        <version>2.6-SNAPSHOT</version>
       </dependency>
       <dependency>
         <groupId>org.apache.xbean</groupId>

Added: geronimo/xbean/branches/classloader/xbean-classloaders/LICENSE.txt
URL: http://svn.apache.org/viewvc/geronimo/xbean/branches/classloader/xbean-classloaders/LICENSE.txt?rev=432861&view=auto
==============================================================================
--- geronimo/xbean/branches/classloader/xbean-classloaders/LICENSE.txt (added)
+++ geronimo/xbean/branches/classloader/xbean-classloaders/LICENSE.txt Sat Aug 19 11:56:27 2006
@@ -0,0 +1,203 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed 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.
+

Propchange: geronimo/xbean/branches/classloader/xbean-classloaders/LICENSE.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/xbean/branches/classloader/xbean-classloaders/LICENSE.txt
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/xbean/branches/classloader/xbean-classloaders/LICENSE.txt
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/xbean/branches/classloader/xbean-classloaders/NOTICE.txt
URL: http://svn.apache.org/viewvc/geronimo/xbean/branches/classloader/xbean-classloaders/NOTICE.txt?rev=432861&view=auto
==============================================================================
--- geronimo/xbean/branches/classloader/xbean-classloaders/NOTICE.txt (added)
+++ geronimo/xbean/branches/classloader/xbean-classloaders/NOTICE.txt Sat Aug 19 11:56:27 2006
@@ -0,0 +1,3 @@
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+

Propchange: geronimo/xbean/branches/classloader/xbean-classloaders/NOTICE.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/xbean/branches/classloader/xbean-classloaders/NOTICE.txt
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/xbean/branches/classloader/xbean-classloaders/NOTICE.txt
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/xbean/branches/classloader/xbean-classloaders/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/xbean/branches/classloader/xbean-classloaders/pom.xml?rev=432861&view=auto
==============================================================================
--- geronimo/xbean/branches/classloader/xbean-classloaders/pom.xml (added)
+++ geronimo/xbean/branches/classloader/xbean-classloaders/pom.xml Sat Aug 19 11:56:27 2006
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?><project>
+  <parent>
+    <artifactId>xbean</artifactId>
+    <groupId>org.apache.xbean</groupId>
+    <version>2.6-SNAPSHOT</version>
+  </parent>
+  <modelVersion>4.0.0</modelVersion>
+  <artifactId>xbean-classloaders</artifactId>
+  <name>XBean :: Classloaders</name>
+  <version>2.6-SNAPSHOT</version>
+  <build>
+    <plugins>
+      <plugin>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <configuration>
+          <source>1.4</source>
+          <target>1.4</target>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+  <dependencies>
+    <dependency>
+      <groupId>cglib</groupId>
+      <artifactId>cglib-nodep</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.springframework</groupId>
+      <artifactId>spring</artifactId>
+    </dependency>
+  </dependencies>
+</project>

Propchange: geronimo/xbean/branches/classloader/xbean-classloaders/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/xbean/branches/classloader/xbean-classloaders/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/xbean/branches/classloader/xbean-classloaders/pom.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/AbstractResourceHandle.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/AbstractResourceHandle.java?rev=432861&view=auto
==============================================================================
--- geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/AbstractResourceHandle.java (added)
+++ geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/AbstractResourceHandle.java Sat Aug 19 11:56:27 2006
@@ -0,0 +1,63 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation
+ *
+ *  Licensed 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.xbean.server.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: 2006-06-01 06:35:48 +0200 (Thu, 01 Jun 2006) $
+ */
+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: geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/AbstractResourceHandle.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/AbstractResourceHandle.java
------------------------------------------------------------------------------
    svn:keywords = "Date Revision Id Author"

Propchange: geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/AbstractResourceHandle.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/AbstractUrlResourceLocation.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/AbstractUrlResourceLocation.java?rev=432861&view=auto
==============================================================================
--- geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/AbstractUrlResourceLocation.java (added)
+++ geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/AbstractUrlResourceLocation.java Sat Aug 19 11:56:27 2006
@@ -0,0 +1,53 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation
+ *
+ *  Licensed 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.xbean.server.classloader;
+
+import java.net.URL;
+
+/**
+ * @version $Rev$ $Date: 2006-06-01 06:35:48 +0200 (Thu, 01 Jun 2006) $
+ */
+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: geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/AbstractUrlResourceLocation.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/AbstractUrlResourceLocation.java
------------------------------------------------------------------------------
    svn:keywords = "Date Revision Id Author"

Propchange: geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/AbstractUrlResourceLocation.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/ClassLoaderUtil.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/ClassLoaderUtil.java?rev=432861&view=auto
==============================================================================
--- geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/ClassLoaderUtil.java (added)
+++ geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/ClassLoaderUtil.java Sat Aug 19 11:56:27 2006
@@ -0,0 +1,91 @@
+/**
+ *
+ * Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed 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.xbean.server.classloader;
+
+import java.util.Map;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.beans.Introspector;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.ObjectStreamClass;
+
+/**
+ * Utility methods for class loader manipulation in a server environment.
+ *
+ * @author Dain Sundstrom
+ * @version $Id$
+ * @since 2.0
+ */
+public final class ClassLoaderUtil {
+    private ClassLoaderUtil() {
+    }
+
+    /**
+     * Cleans well known class loader leaks in VMs and libraries.  There is a lot of bad code out there and this method
+     * will clear up the know problems.  This method should only be called when the class loader will no longer be used.
+     * It this method is called two often it can have a serious impact on preformance.
+     * @param classLoader the class loader to destroy
+     */
+    public static void destroy(ClassLoader classLoader) {
+        releaseCommonsLoggingCache(classLoader);
+        clearSunSoftCache(ObjectInputStream.class, "subclassAudits");
+        clearSunSoftCache(ObjectOutputStream.class, "subclassAudits");
+        clearSunSoftCache(ObjectStreamClass.class, "localDescs");
+        clearSunSoftCache(ObjectStreamClass.class, "reflectors");
+        Introspector.flushCaches();
+    }
+
+    /**
+     * Clears the caches maintained by the SunVM object stream implementation.  This method uses reflection and
+     * setAccessable to obtain access to the Sun cache.  The cache is locked with a synchronize monitor and cleared.
+     * This method completely clears the class loader cache which will impact preformance of object serialization.
+     * @param clazz the name of the class containing the cache field
+     * @param fieldName the name of the cache field
+     */
+    public static void clearSunSoftCache(Class clazz, String fieldName) {
+        Map cache = null;
+        try {
+            Field field = clazz.getDeclaredField(fieldName);
+            field.setAccessible(true);
+            cache = (Map) field.get(null);
+        } catch (Throwable ignored) {
+            // there is nothing a user could do about this anyway
+        }
+
+        if (cache != null) {
+            synchronized (cache) {
+                cache.clear();
+            }
+        }
+    }
+
+    /**
+     * Releases the specified classloader from the Apache Jakarta Commons Logging class loader cache using reflection.
+     * @param classLoader the class loader to release
+     */
+    public static void releaseCommonsLoggingCache(ClassLoader classLoader) {
+        try {
+            Class logFactory = classLoader.loadClass("org.apache.commons.logging.LogFactory");
+            Method release = logFactory.getMethod("release", new Class[] {ClassLoader.class});
+            release.invoke(null, new Object[] {classLoader});
+        } catch (Throwable ignored) {
+            // there is nothing a user could do about this anyway
+        }
+    }
+
+}

Propchange: geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/ClassLoaderUtil.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/ClassLoaderUtil.java
------------------------------------------------------------------------------
    svn:keywords = "Date Revision Id Author"

Propchange: geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/ClassLoaderUtil.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/DestroyableClassLoader.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/DestroyableClassLoader.java?rev=432861&view=auto
==============================================================================
--- geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/DestroyableClassLoader.java (added)
+++ geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/DestroyableClassLoader.java Sat Aug 19 11:56:27 2006
@@ -0,0 +1,33 @@
+/**
+ *
+ * Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed 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.xbean.server.classloader;
+
+/**
+ * DestroyableClassLoader is a mixin interface for a ClassLoader that add a destroy method to propertly cleanup a
+ * classloader then dereferenced by the server.
+ *
+ * @author Dain Sundstrom
+ * @version $Id$
+ * @since 2.0
+ */
+public interface DestroyableClassLoader {
+    /**
+     * Destroys the clasloader releasing all resources.  After this mehtod is called, the class loader will no longer
+     * load any classes or resources.
+     */
+    void destroy();
+}

Propchange: geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/DestroyableClassLoader.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/DestroyableClassLoader.java
------------------------------------------------------------------------------
    svn:keywords = "Date Revision Id Author"

Propchange: geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/DestroyableClassLoader.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/DirectoryResourceHandle.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/DirectoryResourceHandle.java?rev=432861&view=auto
==============================================================================
--- geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/DirectoryResourceHandle.java (added)
+++ geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/DirectoryResourceHandle.java Sat Aug 19 11:56:27 2006
@@ -0,0 +1,97 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation
+ *
+ *  Licensed 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.xbean.server.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: 2006-06-01 06:35:48 +0200 (Thu, 01 Jun 2006) $
+ */
+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: geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/DirectoryResourceHandle.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/DirectoryResourceHandle.java
------------------------------------------------------------------------------
    svn:keywords = "Date Revision Id Author"

Propchange: geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/DirectoryResourceHandle.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/DirectoryResourceLocation.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/DirectoryResourceLocation.java?rev=432861&view=auto
==============================================================================
--- geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/DirectoryResourceLocation.java (added)
+++ geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/DirectoryResourceLocation.java Sat Aug 19 11:56:27 2006
@@ -0,0 +1,79 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation
+ *
+ *  Licensed 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.xbean.server.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: 2006-06-01 06:35:48 +0200 (Thu, 01 Jun 2006) $
+ */
+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: geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/DirectoryResourceLocation.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/DirectoryResourceLocation.java
------------------------------------------------------------------------------
    svn:keywords = "Date Revision Id Author"

Propchange: geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/DirectoryResourceLocation.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/IoUtil.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/IoUtil.java?rev=432861&view=auto
==============================================================================
--- geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/IoUtil.java (added)
+++ geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/IoUtil.java Sat Aug 19 11:56:27 2006
@@ -0,0 +1,145 @@
+/**
+ *
+ * Copyright 2004 The Apache Software Foundation
+ *
+ *  Licensed 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.xbean.server.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: 2006-06-01 06:35:48 +0200 (Thu, 01 Jun 2006) $
+ */
+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: geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/IoUtil.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/IoUtil.java
------------------------------------------------------------------------------
    svn:keywords = "Date Revision Id Author"

Propchange: geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/IoUtil.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/JarFileClassLoader.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/JarFileClassLoader.java?rev=432861&view=auto
==============================================================================
--- geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/JarFileClassLoader.java (added)
+++ geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/JarFileClassLoader.java Sat Aug 19 11:56:27 2006
@@ -0,0 +1,344 @@
+/**
+ *
+ * Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed 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.xbean.server.classloader;
+
+import java.io.IOException;
+import java.io.File;
+import java.net.URL;
+import java.net.URI;
+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>
+ * Note: This implementation currently does not work reliably on windows, since the jar URL handler included with the Sun JavaVM
+ * holds a read lock on the JarFile, and this lock is not released when the jar url is dereferenced.  To fix this a
+ * replacement for the jar url handler must be written.
+ *
+ * @author Dain Sundstrom
+ * @version $Id$
+ * @since 2.0
+ */
+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 name the name of this class loader
+     * @param urls a list of URLs from which classes and resources should be loaded
+     */
+    public JarFileClassLoader(String name, URL[] urls) {
+        super(name, EMPTY_URLS);
+        this.acc = AccessController.getContext();
+        addURLs(urls);
+    }
+
+    /**
+     * Creates a JarFileClassLoader that is a child of the specified class loader.
+     * @param name the name of this 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(String name, URL[] urls, ClassLoader parent) {
+        super(name, EMPTY_URLS, parent);
+        this.acc = AccessController.getContext();
+        addURLs(urls);
+    }
+
+    public JarFileClassLoader(String name, URL[] urls, ClassLoader parent, boolean inverseClassLoading, String[] hiddenClasses, String[] nonOverridableClasses) {
+        super(name, 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 name the name of this class loader
+     * @param urls the urls from which this class loader will classes and resources
+     * @param parents the parents of this class loader
+     */
+    public JarFileClassLoader(String name, URL[] urls, ClassLoader[] parents) {
+        super(name, EMPTY_URLS, parents);
+        this.acc = AccessController.getContext();
+        addURLs(urls);
+    }
+
+    public JarFileClassLoader(String name, URL[] urls, ClassLoader[] parents, boolean inverseClassLoading, Collection hiddenClasses, Collection nonOverridableClasses) {
+        super(name, EMPTY_URLS, parents, inverseClassLoading, hiddenClasses, nonOverridableClasses);
+        this.acc = AccessController.getContext();
+        addURLs(urls);
+    }
+
+    public JarFileClassLoader(String name, URL[] urls, ClassLoader[] parents, boolean inverseClassLoading, String[] hiddenClasses, String[] nonOverridableClasses) {
+        super(name, EMPTY_URLS, parents, inverseClassLoading, hiddenClasses, nonOverridableClasses);
+        this.acc = AccessController.getContext();
+        addURLs(urls);
+    }
+
+    /**
+     * {@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}
+     */
+    public Enumeration findResources(final String resourceName) throws IOException {
+        // todo this is not right
+        // first get the resources from the parent classloaders
+        Enumeration parentResources = super.findResources(resourceName);
+
+        // get the classes from my urls
+        Enumeration myResources = (Enumeration) AccessController.doPrivileged(new PrivilegedAction() {
+            public Object run() {
+                return resourceFinder.findResources(resourceName);
+            }
+        }, acc);
+
+        // join the two together
+        Enumeration resources = new UnionEnumeration(parentResources, myResources);
+        return resources;
+    }
+
+    /**
+     * {@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);
+    }
+}

Propchange: geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/JarFileClassLoader.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/JarFileClassLoader.java
------------------------------------------------------------------------------
    svn:keywords = "Date Revision Id Author"

Propchange: geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/JarFileClassLoader.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/JarFileUrlConnection.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/JarFileUrlConnection.java?rev=432861&view=auto
==============================================================================
--- geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/JarFileUrlConnection.java (added)
+++ geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/JarFileUrlConnection.java Sat Aug 19 11:56:27 2006
@@ -0,0 +1,132 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation
+ *
+ *  Licensed 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.xbean.server.classloader;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.JarURLConnection;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLConnection;
+import java.net.URLStreamHandler;
+import java.security.Permission;
+import java.security.cert.Certificate;
+import java.util.jar.Attributes;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+import java.util.jar.Manifest;
+
+/**
+ * @version $Rev$ $Date: 2006-06-01 06:35:48 +0200 (Thu, 01 Jun 2006) $
+ */
+public class JarFileUrlConnection extends JarURLConnection {
+    public static final URL DUMMY_JAR_URL;
+    static {
+        try {
+            DUMMY_JAR_URL = new URL("jar", "", -1, "file:dummy!/", new URLStreamHandler() {
+                protected URLConnection openConnection(URL u) {
+                    throw new UnsupportedOperationException();
+                }
+            });
+        } catch (Exception e) {
+            throw new ExceptionInInitializerError(e);
+        }
+    }
+
+    private final URL url;
+    private final JarFile jarFile;
+    private final JarEntry jarEntry;
+    private final URL jarFileUrl;
+
+    public JarFileUrlConnection(URL url, JarFile jarFile, JarEntry jarEntry) throws MalformedURLException {
+        super(DUMMY_JAR_URL);
+
+        if (url == null) throw new NullPointerException("url is null");
+        if (jarFile == null) throw new NullPointerException("jarFile is null");
+        if (jarEntry == null) throw new NullPointerException("jarEntry is null");
+
+        this.url = url;
+        this.jarFile = jarFile;
+        this.jarEntry = jarEntry;
+        jarFileUrl = new File(jarFile.getName()).toURL();
+    }
+
+    public JarFile getJarFile() throws IOException {
+        return jarFile;
+    }
+
+    public synchronized void connect() {
+    }
+
+    public URL getJarFileURL() {
+        return jarFileUrl;
+    }
+
+    public String getEntryName() {
+        return getJarEntry().getName();
+    }
+
+    public Manifest getManifest() throws IOException {
+        return jarFile.getManifest();
+    }
+
+    public JarEntry getJarEntry() {
+        return jarEntry;
+    }
+
+    public Attributes getAttributes() throws IOException {
+        return getJarEntry().getAttributes();
+    }
+
+    public Attributes getMainAttributes() throws IOException {
+        return getManifest().getMainAttributes();
+    }
+
+    public Certificate[] getCertificates() throws IOException {
+        return getJarEntry().getCertificates();
+    }
+
+    public URL getURL() {
+        return url;
+    }
+
+    public int getContentLength() {
+        long size = getJarEntry().getSize();
+        if (size > Integer.MAX_VALUE) {
+            return -1;
+        }
+        return (int) size;
+    }
+
+    public long getLastModified() {
+        return getJarEntry().getTime();
+    }
+
+    public synchronized InputStream getInputStream() throws IOException {
+        return jarFile.getInputStream(jarEntry);
+    }
+
+    public Permission getPermission() throws IOException {
+        URL jarFileUrl = new File(jarFile.getName()).toURL();
+        return jarFileUrl.openConnection().getPermission();
+    }
+
+    public String toString() {
+        return JarFileUrlConnection.class.getName() + ":" + url;
+    }
+}

Propchange: geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/JarFileUrlConnection.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/JarFileUrlConnection.java
------------------------------------------------------------------------------
    svn:keywords = "Date Revision Id Author"

Propchange: geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/JarFileUrlConnection.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/JarFileUrlStreamHandler.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/JarFileUrlStreamHandler.java?rev=432861&view=auto
==============================================================================
--- geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/JarFileUrlStreamHandler.java (added)
+++ geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/JarFileUrlStreamHandler.java Sat Aug 19 11:56:27 2006
@@ -0,0 +1,106 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation
+ *
+ *  Licensed 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.xbean.server.classloader;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.FileNotFoundException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLConnection;
+import java.net.URLStreamHandler;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+
+/**
+ * @version $Rev$ $Date: 2006-08-11 01:16:47 +0200 (ven., 11 août 2006) $
+ */
+public class JarFileUrlStreamHandler extends URLStreamHandler {
+    public static URL createUrl(JarFile jarFile, JarEntry jarEntry) throws MalformedURLException {
+        return createUrl(jarFile, jarEntry, new File(jarFile.getName()).toURL());
+    }
+
+    public static URL createUrl(JarFile jarFile, JarEntry jarEntry, URL codeSource) throws MalformedURLException {
+        JarFileUrlStreamHandler handler = new JarFileUrlStreamHandler(jarFile, jarEntry);
+        URL url = new URL("jar", "", -1, codeSource + "!/" + jarEntry.getName(), handler);
+        handler.setExpectedUrl(url);
+        return url;
+    }
+
+    private URL expectedUrl;
+    private final JarFile jarFile;
+    private final JarEntry jarEntry;
+
+    public JarFileUrlStreamHandler(JarFile jarFile, JarEntry jarEntry) {
+        if (jarFile == null) throw new NullPointerException("jarFile is null");
+        if (jarEntry == null) throw new NullPointerException("jarEntry is null");
+
+        this.jarFile = jarFile;
+        this.jarEntry = jarEntry;
+    }
+
+    public void setExpectedUrl(URL expectedUrl) {
+        if (expectedUrl == null) throw new NullPointerException("expectedUrl is null");
+        this.expectedUrl = expectedUrl;
+    }
+
+    public URLConnection openConnection(URL url) throws IOException {
+        if (expectedUrl == null) throw new IllegalStateException("expectedUrl was not set");
+
+        // the caller copied the URL reusing a stream handler from a previous call
+        if (!expectedUrl.equals(url)) {
+            // the new url is supposed to be within our context, so it must have a jar protocol
+            if (!url.getProtocol().equals("jar")) {
+                throw new IllegalArgumentException("Unsupported protocol " + url.getProtocol());
+            }
+
+            // split the path at "!/" into the file part and entry part
+            String path = url.getPath();
+            String[] chunks = path.split("!/", 2);
+
+            // if we only got only one chunk, it didn't contain the required "!/" delimiter
+            if (chunks.length == 1) {
+                throw new MalformedURLException("Url does not contain a '!' character: " + url);
+            }
+
+            String file = chunks[0];
+            String entryPath = chunks[1];
+
+            // this handler only supports jars on the local file system
+            if (!file.startsWith("file:")) {
+                // let the system handler deal with this
+                return new URL(url.toExternalForm()).openConnection();
+            }
+            file = file.substring("file:".length());
+
+            // again the new url is supposed to be within our context so it must reference the same jar file
+            if (!jarFile.getName().equals(file)) {
+                // let the system handler deal with this
+                return new URL(url.toExternalForm()).openConnection();
+            }
+
+            // get the entry
+            JarEntry newEntry = jarFile.getJarEntry(entryPath);
+            if (newEntry == null) {
+                throw new FileNotFoundException("Entry not found: " + url);
+            }
+            return new JarFileUrlConnection(url, jarFile, newEntry);
+        }
+
+        return new JarFileUrlConnection(url, jarFile, jarEntry);
+    }
+}

Propchange: geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/JarFileUrlStreamHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/JarFileUrlStreamHandler.java
------------------------------------------------------------------------------
    svn:keywords = "Date Revision Id Author"

Propchange: geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/JarFileUrlStreamHandler.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/JarResourceHandle.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/JarResourceHandle.java?rev=432861&view=auto
==============================================================================
--- geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/JarResourceHandle.java (added)
+++ geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/JarResourceHandle.java Sat Aug 19 11:56:27 2006
@@ -0,0 +1,80 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation
+ *
+ *  Licensed 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.xbean.server.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: 2006-06-01 06:35:48 +0200 (Thu, 01 Jun 2006) $
+ */
+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: geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/JarResourceHandle.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/JarResourceHandle.java
------------------------------------------------------------------------------
    svn:keywords = "Date Revision Id Author"

Propchange: geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/JarResourceHandle.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/JarResourceLocation.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/JarResourceLocation.java?rev=432861&view=auto
==============================================================================
--- geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/JarResourceLocation.java (added)
+++ geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/JarResourceLocation.java Sat Aug 19 11:56:27 2006
@@ -0,0 +1,56 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation
+ *
+ *  Licensed 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.xbean.server.classloader;
+
+import java.util.jar.Manifest;
+import java.util.jar.JarFile;
+import java.util.jar.JarEntry;
+import java.net.URL;
+import java.net.MalformedURLException;
+import java.io.IOException;
+
+/**
+ * @version $Rev$ $Date: 2006-06-01 06:35:48 +0200 (Thu, 01 Jun 2006) $
+ */
+public class JarResourceLocation extends AbstractUrlResourceLocation  {
+    private final JarFile jarFile;
+
+    public JarResourceLocation(URL codeSource, JarFile jarFile) {
+        super(codeSource);
+        this.jarFile = jarFile;
+    }
+
+    public ResourceHandle getResourceHandle(String resourceName) {
+        JarEntry jarEntry = jarFile.getJarEntry(resourceName);
+        if (jarEntry != null) {
+            try {
+                URL url = new URL(getCodeSource(), resourceName);
+                return new JarResourceHandle(jarFile, jarEntry, getCodeSource());
+            } catch (MalformedURLException e) {
+            }
+        }
+        return null;
+    }
+
+    public Manifest getManifest() throws IOException {
+        return jarFile.getManifest();
+    }
+
+    public void close() {
+        IoUtil.close(jarFile);
+    }
+}

Propchange: geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/JarResourceLocation.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/JarResourceLocation.java
------------------------------------------------------------------------------
    svn:keywords = "Date Revision Id Author"

Propchange: geronimo/xbean/branches/classloader/xbean-classloaders/src/main/java/org/apache/xbean/server/classloader/JarResourceLocation.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message