geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gdam...@apache.org
Subject svn commit: r158589 - in geronimo/trunk/modules: assembly/ assembly/src/plan/ assembly/src/var/security/ classloader-server/ classloader-server/src/ classloader-server/src/java/ classloader-server/src/java/org/ classloader-server/src/java/org/apache/ classloader-server/src/java/org/apache/geronimo/ classloader-server/src/java/org/apache/geronimo/classloaderserver/ classloader-server/src/java/org/apache/geronimo/classloaderserver/http/ classloader-server/src/test/ classloader-server/src/test/org/ classloader-server/src/test/org/apache/ classloader-server/src/test/org/apache/geronimo/ classloader-server/src/test/org/apache/geronimo/classloaderserver/ classloader-server/src/test/org/apache/geronimo/classloaderserver/http/ kernel/src/java/org/apache/geronimo/kernel/config/ system/src/java/org/apache/geronimo/system/rmi/ system/src/test/org/apache/geronimo/system/rmi/
Date Tue, 22 Mar 2005 10:03:05 GMT
Author: gdamour
Date: Tue Mar 22 02:03:00 2005
New Revision: 158589

URL: http://svn.apache.org/viewcvs?view=rev&rev=158589
Log:
Allow remote class loading via RMI annotation for deployment. This includes:

o the definition of a ClassLoaderServer used to export and unexport 
ClassLoaderInfo. This later is a simple wrapper around ClassLoader.

Provide an implementation of ClassLoaderServer using HTTP as the communication
protocol.

o define ConfigurationClassLoader, a specific ClassLoader for Configuration,
which adds two new attributes on top of the URLClassLoader type: ID, which is 
the ID of the defining Configuration; and classLoaderServerURLs, which is
an array of URLs defining the locations from which the Configuration classes
are services by a ClassLoaderServer.

o impact RMIClassLoaderSpiImpl such that it uses the classLoaderServerURLs
defined by a ConfigurationClassLoader to provide the codebase of serialized
classes.

o add the org/apache/geronimo/RemoteClassLoadingDeployer configuration, which
exports the ConfigurationClassLoader of the org/apache/geronimo/Server and
org/apache/geronimo/RuntimeDeployer configurations. 

o add a policy file, which can be used along with deployer.jar to enable
remote class loading.

This policy file is "opened" and needs to be updated to reflect the
execution environment.

Added:
    geronimo/trunk/modules/assembly/src/plan/j2ee-remote-classloading-deployer-plan.xml
    geronimo/trunk/modules/assembly/src/var/security/deployer.policy
    geronimo/trunk/modules/classloader-server/
    geronimo/trunk/modules/classloader-server/LICENSE.txt
    geronimo/trunk/modules/classloader-server/NOTICE.txt
    geronimo/trunk/modules/classloader-server/maven.xml
    geronimo/trunk/modules/classloader-server/project.xml
    geronimo/trunk/modules/classloader-server/src/
    geronimo/trunk/modules/classloader-server/src/java/
    geronimo/trunk/modules/classloader-server/src/java/org/
    geronimo/trunk/modules/classloader-server/src/java/org/apache/
    geronimo/trunk/modules/classloader-server/src/java/org/apache/geronimo/
    geronimo/trunk/modules/classloader-server/src/java/org/apache/geronimo/classloaderserver/
    geronimo/trunk/modules/classloader-server/src/java/org/apache/geronimo/classloaderserver/ClassLoaderInfo.java
    geronimo/trunk/modules/classloader-server/src/java/org/apache/geronimo/classloaderserver/ClassLoaderServer.java
    geronimo/trunk/modules/classloader-server/src/java/org/apache/geronimo/classloaderserver/ClassLoaderServerException.java
    geronimo/trunk/modules/classloader-server/src/java/org/apache/geronimo/classloaderserver/ConfigurationClassLoaderExporter.java
    geronimo/trunk/modules/classloader-server/src/java/org/apache/geronimo/classloaderserver/http/
    geronimo/trunk/modules/classloader-server/src/java/org/apache/geronimo/classloaderserver/http/HTTPClassLoaderServer.java
    geronimo/trunk/modules/classloader-server/src/test/
    geronimo/trunk/modules/classloader-server/src/test/org/
    geronimo/trunk/modules/classloader-server/src/test/org/apache/
    geronimo/trunk/modules/classloader-server/src/test/org/apache/geronimo/
    geronimo/trunk/modules/classloader-server/src/test/org/apache/geronimo/classloaderserver/
    geronimo/trunk/modules/classloader-server/src/test/org/apache/geronimo/classloaderserver/http/
    geronimo/trunk/modules/classloader-server/src/test/org/apache/geronimo/classloaderserver/http/HTTPClassLoaderServerTest.java
    geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationClassLoader.java
Modified:
    geronimo/trunk/modules/assembly/maven.xml
    geronimo/trunk/modules/assembly/project.xml
    geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/Configuration.java
    geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/rmi/RMIClassLoaderSpiImpl.java
    geronimo/trunk/modules/system/src/test/org/apache/geronimo/system/rmi/RMIClassLoaderSpiImplTest.java

Modified: geronimo/trunk/modules/assembly/maven.xml
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/assembly/maven.xml?view=diff&r1=158588&r2=158589
==============================================================================
--- geronimo/trunk/modules/assembly/maven.xml (original)
+++ geronimo/trunk/modules/assembly/maven.xml Tue Mar 22 02:03:00 2005
@@ -435,6 +435,18 @@
                 <ant:arg value="${maven.repo.local}/geronimo/wars/geronimo-jmxdebug-${pom.currentVersion}.war"/>
             </ant:java>
 
+            <!-- build the remote class loading deployer configuration "org/apache/geronimo/RemoteClassLoadingDeployer"-->
+            <ant:echo>Building remote class loading deployer configuration</ant:echo>
+            <ant:java fork="true" jar="${distDir}/bin/deployer.jar" failonerror="true">
+                <ant:jvmarg value="-ea"/>
+                <ant:arg value="--user"/>
+                <ant:arg value="system"/>
+                <ant:arg value="--password"/>
+                <ant:arg value="manager"/>
+                <ant:arg value="distribute"/>
+                <ant:arg value="target/plan/j2ee-remote-classloading-deployer-plan.xml"/>
+            </ant:java>
+
             <j:if test="${context.getVariable('geronimo.assemble.offline') != 'true'}">
                 <deploy:stopRemoteServer
                     uri="deployer:geronimo:jmx:rmi://localhost/jndi/rmi:/JMXConnector"

Modified: geronimo/trunk/modules/assembly/project.xml
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/assembly/project.xml?view=diff&r1=158588&r2=158589
==============================================================================
--- geronimo/trunk/modules/assembly/project.xml (original)
+++ geronimo/trunk/modules/assembly/project.xml Tue Mar 22 02:03:00 2005
@@ -419,6 +419,15 @@
         </dependency>
 
         <dependency>
+            <groupId>geronimo</groupId>
+            <artifactId>geronimo-classloader-server</artifactId>
+            <version>${pom.currentVersion}</version>
+            <properties>
+                <repository>true</repository>
+            </properties>
+        </dependency>
+
+        <dependency>
             <groupId>tranql</groupId>
             <artifactId>tranql-connector</artifactId>
             <version>${tranql_connector_version}</version>

Added: geronimo/trunk/modules/assembly/src/plan/j2ee-remote-classloading-deployer-plan.xml
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/assembly/src/plan/j2ee-remote-classloading-deployer-plan.xml?view=auto&rev=158589
==============================================================================
--- geronimo/trunk/modules/assembly/src/plan/j2ee-remote-classloading-deployer-plan.xml (added)
+++ geronimo/trunk/modules/assembly/src/plan/j2ee-remote-classloading-deployer-plan.xml Tue Mar 22 02:03:00 2005
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+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.
+-->
+
+<!-- $Rev: 57116 $ $Date: 2004-11-09 17:34:38 -0800 (Tue, 09 Nov 2004) $ -->
+
+<!--
+Child of the org/apache/geronimo/RuntimeDeployer configuration that includes the runtime deployment services
+-->
+<configuration
+    xmlns="http://geronimo.apache.org/xml/ns/deployment"
+    configId="org/apache/geronimo/RemoteClassLoadingDeployer"
+    parentId="org/apache/geronimo/RuntimeDeployer"
+    >
+
+    <dependency>
+        <uri>geronimo/jars/geronimo-classloader-server-${geronimo_version}.jar</uri>
+    </dependency>
+
+    <gbean name="HTTPClassLoaderServer" class="org.apache.geronimo.classloaderserver.http.HTTPClassLoaderServer">
+        <reference name="JettyContainer"><module>org/apache/geronimo/Server</module><name>JettyWebContainer</name></reference>
+        <reference name="JettyConnector"><module>org/apache/geronimo/Server</module><name>JettyWebConnector</name></reference>
+    </gbean>
+
+    <gbean name="ServerConfigurationClassLoaderExporter" class="org.apache.geronimo.classloaderserver.ConfigurationClassLoaderExporter">
+        <reference name="ClassLoaderServer"><name>HTTPClassLoaderServer</name></reference>
+        <reference name="Configuration"><gbean-name>geronimo.config:name="org/apache/geronimo/Server"</gbean-name></reference>
+    </gbean>
+
+    <gbean name="RuntimeDeployerConfigurationClassLoaderExporter" class="org.apache.geronimo.classloaderserver.ConfigurationClassLoaderExporter">
+        <reference name="ClassLoaderServer"><name>HTTPClassLoaderServer</name></reference>
+        <reference name="Configuration"><gbean-name>geronimo.config:name="org/apache/geronimo/RuntimeDeployer"</gbean-name></reference>
+    </gbean>
+
+</configuration>

Added: geronimo/trunk/modules/assembly/src/var/security/deployer.policy
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/assembly/src/var/security/deployer.policy?view=auto&rev=158589
==============================================================================
--- geronimo/trunk/modules/assembly/src/var/security/deployer.policy (added)
+++ geronimo/trunk/modules/assembly/src/var/security/deployer.policy Tue Mar 22 02:03:00 2005
@@ -0,0 +1,46 @@
+
+
+//
+//
+//   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.
+//
+
+//
+// $Rev: 158397 $ $Date: 2005-03-21 14:06:55 +1100 (Mon, 21 Mar 2005) $
+//
+
+grant {
+    permission java.util.PropertyPermission "jmx.remote.protocol.provider.pkgs", "read";
+    permission java.util.PropertyPermission "mx4j.remote.resolver.pkgs", "read";
+    permission java.util.PropertyPermission "mx4j.log.priority", "read";
+    permission java.util.PropertyPermission "mx4j.log.prototype", "read";
+    permission java.util.PropertyPermission "mx4j.objectname.caching", "read";
+    permission java.util.PropertyPermission "user.dir", "read";
+
+    // HTTP server from where classes are downloaded - configure the reflect your execution environment.
+    permission java.net.SocketPermission "*:8080", "connect,resolve";
+
+    // RMI registry - configure the reflect your execution environment.
+    permission java.net.SocketPermission "*:1099", "connect,resolve";
+    // For RMI communications - configure the reflect your execution environment.
+    permission java.net.SocketPermission "*:1024-", "connect,resolve";
+
+    // Configure to reflect your execution environment.
+    permission java.io.FilePermission "<<ALL FILES>>", "read";
+
+    permission java.lang.RuntimePermission "setContextClassLoader";
+    permission java.lang.RuntimePermission "createClassLoader";
+    permission java.lang.RuntimePermission "getProtectionDomain";
+};

Added: geronimo/trunk/modules/classloader-server/LICENSE.txt
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/classloader-server/LICENSE.txt?view=auto&rev=158589
==============================================================================
--- geronimo/trunk/modules/classloader-server/LICENSE.txt (added)
+++ geronimo/trunk/modules/classloader-server/LICENSE.txt Tue Mar 22 02:03:00 2005
@@ -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.
+

Added: geronimo/trunk/modules/classloader-server/NOTICE.txt
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/classloader-server/NOTICE.txt?view=auto&rev=158589
==============================================================================
--- geronimo/trunk/modules/classloader-server/NOTICE.txt (added)
+++ geronimo/trunk/modules/classloader-server/NOTICE.txt Tue Mar 22 02:03:00 2005
@@ -0,0 +1,3 @@
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+

Added: geronimo/trunk/modules/classloader-server/maven.xml
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/classloader-server/maven.xml?view=auto&rev=158589
==============================================================================
--- geronimo/trunk/modules/classloader-server/maven.xml (added)
+++ geronimo/trunk/modules/classloader-server/maven.xml Tue Mar 22 02:03:00 2005
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+
+    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.
+-->
+  
+
+<!-- $Rev: 56771 $ $Date: 2004-11-07 06:58:54 +1100 (Sun, 07 Nov 2004) $ -->
+
+<project default="default"
+    xmlns:j="jelly:core"
+    xmlns:ant="jelly:ant"
+    xmlns:maven="jelly:maven">
+
+</project>

Added: geronimo/trunk/modules/classloader-server/project.xml
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/classloader-server/project.xml?view=auto&rev=158589
==============================================================================
--- geronimo/trunk/modules/classloader-server/project.xml (added)
+++ geronimo/trunk/modules/classloader-server/project.xml Tue Mar 22 02:03:00 2005
@@ -0,0 +1,103 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+
+    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.
+-->
+  
+<!-- $Rev: 151483 $ $Date: 2005-02-05 18:09:05 +1100 (Sat, 05 Feb 2005) $ -->
+
+<project>
+    <pomVersion>3</pomVersion>
+    <extend>../../etc/project.xml</extend>
+
+    <!-- ===================== -->
+    <!-- Module Identification -->
+    <!-- ===================== -->
+
+    <name>Geronimo :: ClassLoader Server</name>
+    <id>geronimo-classloader-server</id>
+    <shortDescription>ClassLoader Server</shortDescription>
+    <description>ClassLoader Server</description>
+    <url>http://geronimo.apache.org/modules/classloader-server</url>
+    <siteDirectory>/www/geronimo.apache.org/modules/classloader-server</siteDirectory>
+    <distributionDirectory>/www/incubator.apache.org/projects/geronimo/builds/classloader-server</distributionDirectory>
+
+    <package>org.apache.geronimo.classloaderserver</package>
+
+    <!-- ============ -->
+    <!-- Dependencies -->
+    <!-- ============ -->
+
+    <dependencies>
+
+        <dependency>
+            <groupId>geronimo</groupId>
+            <artifactId>geronimo-kernel</artifactId>
+            <version>${pom.currentVersion}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>geronimo</groupId>
+            <artifactId>geronimo-j2ee</artifactId>
+            <version>${pom.currentVersion}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>geronimo</groupId>
+            <artifactId>geronimo-webservices</artifactId>
+            <version>${pom.currentVersion}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>geronimo</groupId>
+            <artifactId>geronimo-jetty</artifactId>
+            <version>${pom.currentVersion}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>geronimo-spec</groupId>
+            <artifactId>geronimo-spec-servlet</artifactId>
+            <version>${geronimo_spec_servlet_version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>jetty</groupId>
+            <artifactId>org.mortbay.jetty</artifactId>
+            <version>${jetty_version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>mx4j</groupId>
+            <artifactId>mx4j</artifactId>
+            <version>${mx4j_version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>commons-logging</groupId>
+            <artifactId>commons-logging</artifactId>
+            <version>${commons_logging_version}</version>
+            <url>http://jakarta.apache.org/commons/logging/</url>
+        </dependency>
+
+        <dependency>
+            <groupId>cglib</groupId>
+            <artifactId>cglib-full</artifactId>
+            <version>${cglib_version}</version>
+            <url>http://cglib.sf.net/</url>
+        </dependency>
+
+    </dependencies>
+
+</project>

Added: geronimo/trunk/modules/classloader-server/src/java/org/apache/geronimo/classloaderserver/ClassLoaderInfo.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/classloader-server/src/java/org/apache/geronimo/classloaderserver/ClassLoaderInfo.java?view=auto&rev=158589
==============================================================================
--- geronimo/trunk/modules/classloader-server/src/java/org/apache/geronimo/classloaderserver/ClassLoaderInfo.java (added)
+++ geronimo/trunk/modules/classloader-server/src/java/org/apache/geronimo/classloaderserver/ClassLoaderInfo.java Tue Mar 22 02:03:00 2005
@@ -0,0 +1,35 @@
+/**
+ *
+ * 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.geronimo.classloaderserver;
+
+import java.net.URL;
+
+/**
+ *
+ * @version $Rev: 109957 $ $Date: 2004-12-06 18:52:06 +1100 (Mon, 06 Dec 2004) $
+ */
+public interface ClassLoaderInfo {
+    
+    public ClassLoader getClassLoader();
+    
+    public Object getID();
+
+    public void setClassLoaderServerURLs(URL[] urls);
+
+}
+

Added: geronimo/trunk/modules/classloader-server/src/java/org/apache/geronimo/classloaderserver/ClassLoaderServer.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/classloader-server/src/java/org/apache/geronimo/classloaderserver/ClassLoaderServer.java?view=auto&rev=158589
==============================================================================
--- geronimo/trunk/modules/classloader-server/src/java/org/apache/geronimo/classloaderserver/ClassLoaderServer.java (added)
+++ geronimo/trunk/modules/classloader-server/src/java/org/apache/geronimo/classloaderserver/ClassLoaderServer.java Tue Mar 22 02:03:00 2005
@@ -0,0 +1,32 @@
+/**
+ *
+ * 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.geronimo.classloaderserver;
+
+
+/**
+ *
+ * @version $Rev: 109957 $ $Date: 2004-12-06 18:52:06 +1100 (Mon, 06 Dec 2004) $
+ */
+public interface ClassLoaderServer {
+    
+    public void export(ClassLoaderInfo info) throws ClassLoaderServerException;
+
+    public void unexport(ClassLoaderInfo info) throws ClassLoaderServerException;
+    
+}
+

Added: geronimo/trunk/modules/classloader-server/src/java/org/apache/geronimo/classloaderserver/ClassLoaderServerException.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/classloader-server/src/java/org/apache/geronimo/classloaderserver/ClassLoaderServerException.java?view=auto&rev=158589
==============================================================================
--- geronimo/trunk/modules/classloader-server/src/java/org/apache/geronimo/classloaderserver/ClassLoaderServerException.java (added)
+++ geronimo/trunk/modules/classloader-server/src/java/org/apache/geronimo/classloaderserver/ClassLoaderServerException.java Tue Mar 22 02:03:00 2005
@@ -0,0 +1,43 @@
+/**
+ *
+ * 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.geronimo.classloaderserver;
+
+
+/**
+ *
+ * @version $Rev: 109957 $ $Date: 2004-12-06 18:52:06 +1100 (Mon, 06 Dec 2004) $
+ */
+public class ClassLoaderServerException extends Exception {
+
+    public ClassLoaderServerException() {
+    }
+
+    public ClassLoaderServerException(Throwable cause) {
+        super(cause);
+    }
+
+    public ClassLoaderServerException(String message) {
+        super(message);
+    }
+
+    public ClassLoaderServerException(String message, Throwable cause) {
+        super(message, cause);
+    }
+    
+}
+

Added: geronimo/trunk/modules/classloader-server/src/java/org/apache/geronimo/classloaderserver/ConfigurationClassLoaderExporter.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/classloader-server/src/java/org/apache/geronimo/classloaderserver/ConfigurationClassLoaderExporter.java?view=auto&rev=158589
==============================================================================
--- geronimo/trunk/modules/classloader-server/src/java/org/apache/geronimo/classloaderserver/ConfigurationClassLoaderExporter.java (added)
+++ geronimo/trunk/modules/classloader-server/src/java/org/apache/geronimo/classloaderserver/ConfigurationClassLoaderExporter.java Tue Mar 22 02:03:00 2005
@@ -0,0 +1,104 @@
+/**
+ *
+ * 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.geronimo.classloaderserver;
+
+import java.net.URL;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.GBeanInfoBuilder;
+import org.apache.geronimo.gbean.GBeanLifecycle;
+import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
+import org.apache.geronimo.kernel.config.Configuration;
+import org.apache.geronimo.kernel.config.ConfigurationClassLoader;
+
+
+/**
+ *
+ * @version $Rev: 109957 $ $Date: 2004-12-06 18:52:06 +1100 (Mon, 06 Dec 2004) $
+ */
+public class ConfigurationClassLoaderExporter implements GBeanLifecycle {
+    private static final Log log = LogFactory.getLog(ConfigurationClassLoaderExporter.class);
+    
+    private final ClassLoaderServer networkServer;
+    private final Configuration configuration;
+    private ClassLoaderInfoAdapter adapter;
+    
+    public ConfigurationClassLoaderExporter(ClassLoaderServer networkServer, Configuration configuration) {
+        this.networkServer = networkServer;
+        this.configuration = configuration;
+    }
+
+    public void doStart() throws Exception {
+        ConfigurationClassLoader cl = configuration.getConfigurationClassLoader();
+        
+        adapter = new ClassLoaderInfoAdapter(cl);
+        networkServer.export(adapter);
+    }
+
+    public void doStop() throws Exception {
+        networkServer.unexport(adapter);
+    }
+
+    public void doFail() {
+        try {
+            networkServer.unexport(adapter);
+        } catch (ClassLoaderServerException e) {
+            log.error(e);
+        }
+    }
+    
+    private static class ClassLoaderInfoAdapter implements ClassLoaderInfo {
+        private final ConfigurationClassLoader cl;
+        
+        private ClassLoaderInfoAdapter(ConfigurationClassLoader cl) {
+            this.cl = cl;
+        }
+        
+        public ClassLoader getClassLoader() {
+            return cl;
+        }
+
+        public Object getID() {
+            return cl.getID();
+        }
+
+        public void setClassLoaderServerURLs(URL[] urls) {
+            cl.setClassLoaderServerURLs(urls);
+        }
+    }
+    
+    public static final GBeanInfo GBEAN_INFO;
+
+    static {
+        GBeanInfoBuilder infoBuilder = new GBeanInfoBuilder("ConfigurationClassLoader Exporter", ConfigurationClassLoaderExporter.class);
+
+        infoBuilder.addReference("ClassLoaderServer", ClassLoaderServer.class, NameFactory.GERONIMO_SERVICE);
+        infoBuilder.addReference("Configuration", Configuration.class, NameFactory.CONFIGURATION_ENTRY);
+        
+        infoBuilder.setConstructor(new String[] {"ClassLoaderServer", "Configuration"});
+        
+        GBEAN_INFO = infoBuilder.getBeanInfo();
+    }
+
+    public static GBeanInfo getGBeanInfo() {
+        return GBEAN_INFO;
+    }
+}
+

Added: geronimo/trunk/modules/classloader-server/src/java/org/apache/geronimo/classloaderserver/http/HTTPClassLoaderServer.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/classloader-server/src/java/org/apache/geronimo/classloaderserver/http/HTTPClassLoaderServer.java?view=auto&rev=158589
==============================================================================
--- geronimo/trunk/modules/classloader-server/src/java/org/apache/geronimo/classloaderserver/http/HTTPClassLoaderServer.java (added)
+++ geronimo/trunk/modules/classloader-server/src/java/org/apache/geronimo/classloaderserver/http/HTTPClassLoaderServer.java Tue Mar 22 02:03:00 2005
@@ -0,0 +1,219 @@
+/**
+ *
+ * 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.geronimo.classloaderserver.http;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.classloaderserver.ClassLoaderInfo;
+import org.apache.geronimo.classloaderserver.ClassLoaderServer;
+import org.apache.geronimo.classloaderserver.ClassLoaderServerException;
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.GBeanInfoBuilder;
+import org.apache.geronimo.gbean.GBeanLifecycle;
+import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
+import org.apache.geronimo.jetty.JettyContainer;
+import org.apache.geronimo.jetty.connector.JettyConnector;
+import org.mortbay.http.HttpContext;
+import org.mortbay.http.HttpException;
+import org.mortbay.http.HttpHandler;
+import org.mortbay.http.HttpRequest;
+import org.mortbay.http.HttpResponse;
+
+
+/**
+ *
+ * @version $Rev: 109957 $ $Date: 2004-12-06 18:52:06 +1100 (Mon, 06 Dec 2004) $
+ */
+public class HTTPClassLoaderServer implements ClassLoaderServer, GBeanLifecycle {
+    private final Log log = LogFactory.getLog(HTTPClassLoaderServer.class);
+    
+    private final JettyContainer jettyContainer;
+    private final JettyConnector jettyConnector;
+    private final Map infos = new HashMap();
+    private String protocol;
+    private String host;
+    private int port;
+        
+    public HTTPClassLoaderServer(JettyContainer jettyContainer, JettyConnector jettyConnector) {
+        this.jettyContainer = jettyContainer;
+        this.jettyConnector = jettyConnector;
+    }
+
+    public void export(ClassLoaderInfo info) throws ClassLoaderServerException {
+        String id = getID(info);
+        ClassLoaderContext context = new ClassLoaderContext(id, info.getClassLoader());
+        synchronized(infos) {
+            if (infos.containsKey(id)) {
+                throw new ClassLoaderServerException("ClassLoader with ID " + id + " already defined");
+            }
+            infos.put(id, context);
+        }
+        jettyContainer.addContext(context);
+        try {
+            context.start();
+        } catch (Exception e) {
+            throw new ClassLoaderServerException("Cannot start ClassLoaderContext", e);
+        }
+        
+        URL url;
+        try {
+            url = new URL(protocol, host, port, id);
+        } catch (MalformedURLException e) {
+            throw new ClassLoaderServerException("Cannot build baseURL", e);
+        }
+        info.setClassLoaderServerURLs(new URL[] {url});
+    }
+
+    public void unexport(ClassLoaderInfo info) throws ClassLoaderServerException {
+        String id = getID(info);
+        ClassLoaderContext context;
+        synchronized(infos) {
+            context = (ClassLoaderContext) infos.remove(id);
+        }
+        if (null == context) {
+            throw new ClassLoaderServerException("ClassLoader with ID " + id + " is undefined");
+        }
+        try {
+            context.stop();
+        } catch (InterruptedException e) {
+            log.error("Error while stopping ClassLoaderContext", e);
+        }
+        jettyContainer.removeContext(context);
+        info.setClassLoaderServerURLs(null);
+    }
+
+    public void doStart() throws Exception {
+        protocol = jettyConnector.getDefaultScheme();
+        host = jettyConnector.getHost();
+        port = jettyConnector.getPort();
+    }
+
+    public void doStop() throws Exception {
+    }
+
+    public void doFail() {
+    }
+    
+    private String getID(ClassLoaderInfo info) {
+        String id = info.getID().toString().replace('/', '.');
+        return "/HTTPClassLoaderServer[" + id + "]/";
+    }
+    
+    private static class ClassLoaderContext extends HttpContext {
+        private ClassLoaderContext(String contextPath, ClassLoader cl) {
+            setContextPath(contextPath);
+            addHandler(new ClassLoaderHandler(cl));
+        }
+    }
+    
+    private static class ClassLoaderHandler implements HttpHandler {
+        private final ClassLoader cl;
+        private HttpContext httpContext;
+        private boolean started;
+        
+        private ClassLoaderHandler(ClassLoader cl) {
+            this.cl = cl;
+        }
+        
+        public String getName() {
+            return "ClassLoaderHandler";
+        }
+
+        public HttpContext getHttpContext() {
+            return httpContext;
+        }
+        
+        public void initialize(HttpContext httpContext) {
+            this.httpContext = httpContext;
+        }
+
+        public void handle(String pathInContext, String pathParams, HttpRequest request, HttpResponse response) throws HttpException, IOException {
+            String method=request.getMethod();
+            if (false == method.equals(HttpRequest.__GET)) {
+                response.sendError(HttpResponse.__405_Method_Not_Allowed);
+                return;
+            }
+           
+            String resource = pathInContext.substring(1);
+            
+            InputStream in = cl.getResourceAsStream(resource);
+            if (null == in) {
+                response.sendError(HttpResponse.__404_Not_Found);
+                return;
+            }
+            
+            ByteArrayOutputStream out = new ByteArrayOutputStream();
+            byte[] buffer = new byte[1024];
+            try {
+                int read = 0;
+                while (0 < (read = in.read(buffer))) {
+                    out.write(buffer, 0, read);
+                }
+            } catch (IOException e) {
+                response.sendError(HttpResponse.__500_Internal_Server_Error);
+                return;
+            }
+            
+            response.setContentLength(out.size());
+            OutputStream respOut = response.getOutputStream();
+            out.writeTo(respOut);
+        }
+
+        public void start() throws Exception {
+            started = true;
+        }
+
+        public void stop() throws InterruptedException {
+            started = false;
+        }
+
+        public boolean isStarted() {
+            return started;
+        }
+    }
+    
+    public static final GBeanInfo GBEAN_INFO;
+
+    static {
+        GBeanInfoBuilder infoBuilder = new GBeanInfoBuilder("HTTP ClassLoader Server", HTTPClassLoaderServer.class);
+
+        infoBuilder.addOperation("export", new Class[] {ClassLoaderInfo.class});
+        infoBuilder.addOperation("unexport", new Class[] {ClassLoaderInfo.class});
+        
+        infoBuilder.addReference("JettyContainer", JettyContainer.class, NameFactory.GERONIMO_SERVICE);
+        infoBuilder.addReference("JettyConnector", JettyConnector.class, NameFactory.GERONIMO_SERVICE);
+        
+        infoBuilder.setConstructor(new String[] {"JettyContainer", "JettyConnector"});
+
+        GBEAN_INFO = infoBuilder.getBeanInfo();
+    }
+
+    public static GBeanInfo getGBeanInfo() {
+        return GBEAN_INFO;
+    }
+}
+

Added: geronimo/trunk/modules/classloader-server/src/test/org/apache/geronimo/classloaderserver/http/HTTPClassLoaderServerTest.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/classloader-server/src/test/org/apache/geronimo/classloaderserver/http/HTTPClassLoaderServerTest.java?view=auto&rev=158589
==============================================================================
--- geronimo/trunk/modules/classloader-server/src/test/org/apache/geronimo/classloaderserver/http/HTTPClassLoaderServerTest.java (added)
+++ geronimo/trunk/modules/classloader-server/src/test/org/apache/geronimo/classloaderserver/http/HTTPClassLoaderServerTest.java Tue Mar 22 02:03:00 2005
@@ -0,0 +1,143 @@
+/**
+ *
+ * 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.geronimo.classloaderserver.http;
+
+import java.io.InputStream;
+import java.net.URI;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.management.ObjectName;
+
+import junit.framework.TestCase;
+
+import org.apache.geronimo.classloaderserver.ClassLoaderInfo;
+import org.apache.geronimo.gbean.GBeanData;
+import org.apache.geronimo.jetty.JettyContainerImpl;
+import org.apache.geronimo.jetty.connector.HTTPConnector;
+import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.kernel.registry.BasicGBeanRegistry;
+
+
+/**
+ *
+ * @version $Rev: 109957 $ $Date: 2004-12-06 18:52:06 +1100 (Mon, 06 Dec 2004) $
+ */
+public class HTTPClassLoaderServerTest extends TestCase {
+    private ClassLoader cl = this.getClass().getClassLoader();
+    private ObjectName containerName;
+    private ObjectName connectorName;
+    private ObjectName classLoaderServerName;
+    private MockClassLoaderInfo clInfo;
+    private Kernel kernel;
+    
+    public void testURLs() throws Exception {
+        assertEquals(1, clInfo.urls.length);
+    }
+    
+    public void testOK() throws Exception {
+        URLClassLoader urlCL = new URLClassLoader(clInfo.urls, null);
+        String className = HTTPClassLoaderServerTest.class.getName();
+        Class clazz = urlCL.loadClass(className);
+        assertEquals(className, clazz.getName());
+    }
+    
+    public void testNOK() throws Exception {
+        URLClassLoader urlCL = new URLClassLoader(clInfo.urls, null);
+        try {
+            urlCL.loadClass("Test");
+            fail();
+        } catch (ClassNotFoundException e) {
+        }
+    }
+    
+    private void start(GBeanData instance) throws Exception {
+        kernel.loadGBean(instance, cl);
+        kernel.startGBean(instance.getName());
+    }
+
+    private void stop(ObjectName name) throws Exception {
+        kernel.stopGBean(name);
+        kernel.unloadGBean(name);
+    }
+
+    protected void setUp() throws Exception {
+        containerName = new ObjectName("geronimo.jetty:role=Container");
+        Set containerPatterns = new HashSet();
+        containerPatterns.add(containerName);
+        connectorName = new ObjectName("geronimo.jetty:role=Connector");
+        Set connectorPatterns = new HashSet();
+        connectorPatterns.add(connectorName);
+        kernel = new Kernel("test.kernel", new BasicGBeanRegistry());
+        kernel.boot();
+        GBeanData container = new GBeanData(containerName, JettyContainerImpl.GBEAN_INFO);
+        start(container);
+        
+        int port = 5678;
+        GBeanData connector = new GBeanData(connectorName, HTTPConnector.GBEAN_INFO);
+        connector.setAttribute("port", new Integer(port));
+        connector.setReferencePatterns("JettyContainer", containerPatterns);
+        start(connector);
+        
+        classLoaderServerName = new ObjectName("geronimo.jetty:role=ClassLoaderServer");
+        GBeanData classLoaderServer = new GBeanData(classLoaderServerName, HTTPClassLoaderServer.GBEAN_INFO);
+        classLoaderServer.setReferencePatterns("JettyContainer", containerPatterns);
+        classLoaderServer.setReferencePatterns("JettyConnector", connectorPatterns);
+        start(classLoaderServer);
+        
+        clInfo = new MockClassLoaderInfo(new URI("test"), getClass().getClassLoader());
+        kernel.invoke(classLoaderServerName, "export", new Object[] {clInfo}, new String[] {ClassLoaderInfo.class.getName()});
+    }
+
+    protected void tearDown() throws Exception {
+        stop(containerName);
+        stop(connectorName);
+        stop(classLoaderServerName);
+        kernel.shutdown();
+    }
+    
+    private static class MockClassLoaderInfo extends ClassLoader implements ClassLoaderInfo {
+        private final Object id;
+        private final ClassLoader delegate;
+        private URL[] urls;
+        
+        private MockClassLoaderInfo(Object id, ClassLoader delegate) {
+            this.id = id;
+            this.delegate = delegate;
+        }
+        
+        public InputStream getResourceAsStream(String name) {
+            return delegate.getResourceAsStream(name);
+        }
+        
+        public ClassLoader getClassLoader() {
+            return this;
+        }
+
+        public Object getID() {
+            return id;
+        }
+
+        public void setClassLoaderServerURLs(URL[] urls) {
+            this.urls = urls;
+        }
+    }
+}
+

Modified: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/Configuration.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/Configuration.java?view=diff&r1=158588&r2=158589
==============================================================================
--- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/Configuration.java (original)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/Configuration.java Tue Mar 22 02:03:00 2005
@@ -21,14 +21,11 @@
 import java.io.ByteArrayOutputStream;
 import java.io.EOFException;
 import java.io.IOException;
-import java.io.InputStream;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
-import java.io.ObjectStreamClass;
+import java.net.MalformedURLException;
 import java.net.URI;
 import java.net.URL;
-import java.net.URLClassLoader;
-import java.net.MalformedURLException;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
@@ -38,6 +35,7 @@
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+
 import javax.management.MalformedObjectNameException;
 import javax.management.ObjectName;
 
@@ -49,7 +47,6 @@
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
 import org.apache.geronimo.gbean.GBeanLifecycle;
 import org.apache.geronimo.kernel.Kernel;
-import org.apache.geronimo.kernel.ClassLoading;
 import org.apache.geronimo.kernel.ObjectInputStreamExt;
 import org.apache.geronimo.kernel.jmx.JMXUtil;
 import org.apache.geronimo.kernel.repository.MissingDependencyException;
@@ -135,7 +132,7 @@
     /**
      * The classloadeder used to load the child GBeans contained in this configuration.
      */
-    private final ClassLoader configurationClassLoader;
+    private final ConfigurationClassLoader configurationClassLoader;
 
     /**
      * The GBeanData for the GBeans contained in this configuration.  These must be persisted as a ByteArray, becuase
@@ -144,6 +141,22 @@
      */
     private byte[] gbeanState;
 
+    /**
+     * Only used to allow declaration as a reference.
+     */
+    public Configuration() {
+        kernel = null;
+        objectNameString = null;
+        objectName = null;
+        id = null;
+        moduleType = null;
+        parentID = null;
+        configurationStore = null;
+        domain = null;
+        server = null;
+        objectNames = null;
+        configurationClassLoader = null;
+    }
 
     /**
      * Constructor that can be used to create an offline Configuration, typically
@@ -193,9 +206,9 @@
             // no explicit parent set, so use the class loader of this class as
             // the parent... this class should be in the root geronimo classloader,
             // which is normally the system class loader but not always, so be safe
-            configurationClassLoader = new URLClassLoader(urls, getClass().getClassLoader());
+            configurationClassLoader = new ConfigurationClassLoader(id, urls, getClass().getClassLoader());
         } else {
-            configurationClassLoader = new URLClassLoader(urls, parent.getConfigurationClassLoader());
+            configurationClassLoader = new ConfigurationClassLoader(id, urls, parent.getConfigurationClassLoader());
         }
 
         // DSS: why exactally are we doing this?  I bet there is a reason, but
@@ -366,7 +379,7 @@
         return gbeanState;
     }
 
-    public ClassLoader getConfigurationClassLoader() {
+    public ConfigurationClassLoader getConfigurationClassLoader() {
         return configurationClassLoader;
     }
 
@@ -447,7 +460,7 @@
         infoFactory.addAttribute("dependencies", List.class, true);
         infoFactory.addAttribute("gBeanState", byte[].class, true);
         infoFactory.addAttribute("baseURL", URL.class, true);
-        infoFactory.addAttribute("configurationClassLoader", ClassLoader.class, false);
+        infoFactory.addAttribute("configurationClassLoader", ConfigurationClassLoader.class, false);
 
         infoFactory.addReference("Parent", ConfigurationParent.class);
         infoFactory.addReference("Repositories", Repository.class, "GBean");

Added: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationClassLoader.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationClassLoader.java?view=auto&rev=158589
==============================================================================
--- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationClassLoader.java (added)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationClassLoader.java Tue Mar 22 02:03:00 2005
@@ -0,0 +1,52 @@
+/**
+ *
+ * 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.geronimo.kernel.config;
+
+import java.net.URI;
+import java.net.URL;
+import java.net.URLClassLoader;
+
+/**
+ *
+ * @version $Rev: 156292 $ $Date: 2005-03-06 13:48:02 +1100 (Sun, 06 Mar 2005) $
+ */
+public class ConfigurationClassLoader extends URLClassLoader {
+    private final URI id;
+    private URL[] urls;
+    
+    public ConfigurationClassLoader(URI id, URL[] urls, ClassLoader parent) {
+        super(urls, parent);
+        this.id = id;
+    }
+    
+    public URI getID() {
+        return id;
+    }
+
+    public URL[] getClassLoaderServerURLs() {
+        return urls;
+    }
+    
+    public void setClassLoaderServerURLs(URL[] urls) {
+        this.urls = urls;
+    }
+    
+    public String toString() {
+        return "[Configuration ClassLoader id=" + id + "]";
+    }
+}

Modified: geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/rmi/RMIClassLoaderSpiImpl.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/rmi/RMIClassLoaderSpiImpl.java?view=diff&r1=158588&r2=158589
==============================================================================
--- geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/rmi/RMIClassLoaderSpiImpl.java (original)
+++ geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/rmi/RMIClassLoaderSpiImpl.java Tue Mar 22 02:03:00 2005
@@ -27,6 +27,8 @@
 import java.rmi.server.RMIClassLoader;
 import java.rmi.server.RMIClassLoaderSpi;
 
+import org.apache.geronimo.kernel.config.ConfigurationClassLoader;
+
 /**
  * An implementation of {@link RMIClassLoaderSpi} which provides normilzation
  * of codebase URLs and delegates to the default {@link RMIClassLoaderSpi}.
@@ -69,6 +71,27 @@
     }
     
     public String getClassAnnotation(Class type) {
+        Object obj = type.getClassLoader();
+        if (obj instanceof ConfigurationClassLoader) {
+            obj = new ConfigurationClassLoaderAdapter((ConfigurationClassLoader) obj);
+        }
+        if (obj instanceof ClassLoaderServerAware) {
+            ClassLoaderServerAware classLoader = (ClassLoaderServerAware) obj;
+            URL urls[] = classLoader.getClassLoaderServerURLs();
+            if (null == urls) {
+                return delegate.getClassAnnotation(type);
+            }
+            StringBuffer codebase = new StringBuffer();
+            for (int i = 0; i < urls.length; i++) {
+                URL url = normalizeURL(urls[i]);
+                if (codebase.length() != 0) {
+                    codebase.append(' ');
+                }
+                codebase.append(url);
+            }
+            return codebase.toString();
+        }
+        
         return delegate.getClassAnnotation(type);
     }
     
@@ -141,5 +164,21 @@
         }
         
         return url;
+    }
+    
+    public interface ClassLoaderServerAware {
+        public URL[] getClassLoaderServerURLs();
+    }
+    
+    private static class ConfigurationClassLoaderAdapter implements ClassLoaderServerAware {
+        private final ConfigurationClassLoader cl;
+        
+        private ConfigurationClassLoaderAdapter(ConfigurationClassLoader cl) {
+            this.cl = cl;
+        }
+
+        public URL[] getClassLoaderServerURLs() {
+            return cl.getClassLoaderServerURLs();
+        }
     }
 }

Modified: geronimo/trunk/modules/system/src/test/org/apache/geronimo/system/rmi/RMIClassLoaderSpiImplTest.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/system/src/test/org/apache/geronimo/system/rmi/RMIClassLoaderSpiImplTest.java?view=diff&r1=158588&r2=158589
==============================================================================
--- geronimo/trunk/modules/system/src/test/org/apache/geronimo/system/rmi/RMIClassLoaderSpiImplTest.java (original)
+++ geronimo/trunk/modules/system/src/test/org/apache/geronimo/system/rmi/RMIClassLoaderSpiImplTest.java Tue Mar 22 02:03:00 2005
@@ -18,9 +18,15 @@
 package org.apache.geronimo.system.rmi;
 
 import java.net.MalformedURLException;
+import java.net.URI;
 import java.net.URL;
 
+import java.io.ByteArrayOutputStream;
 import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.apache.geronimo.kernel.config.ConfigurationClassLoader;
 
 import junit.framework.TestCase;
 
@@ -63,5 +69,86 @@
         String normal = RMIClassLoaderSpiImpl.normalizeCodebase(codebase);
         assertEquals(normalizedBaseURL + "/Apache%20Group/Geronimo " +
                      normalizedBaseURL + "/Apache%20Group/Apache2", normal);
+    }
+    
+    public void testGetClassAnnotationWithConfigurationCL() throws Exception {
+        final ClassLoader delegate = getClass().getClassLoader();
+        ConfigurationClassLoader cl = new ConfigurationClassLoader(new URI("test"), new URL[] {new URL("http://localhost:8080/")}, delegate) {
+            public Class loadClass(String name) throws ClassNotFoundException {
+                if (name.startsWith("java")) {
+                    return delegate.loadClass(name);
+                }
+                String resourceName = name.replace('.', '/') + ".class";
+                InputStream in = delegate.getResourceAsStream(resourceName);
+                byte[] buffer = new byte[1024];
+                ByteArrayOutputStream out = new ByteArrayOutputStream();
+                int read = 0;
+                try {
+                    while (0 < (read = in.read(buffer))) {
+                        out.write(buffer, 0, read);
+                    }
+                } catch (IOException e) {
+                    fail();
+                    return null;
+                }
+                return defineClass(name, out.toByteArray(), 0, out.size());
+            }  
+        };
+        String url1 = "http://localhost:8090/Tester1";
+        String url2 = "http://localhost:8090/Tester2";
+        cl.setClassLoaderServerURLs(new URL[] {new URL(url1), new URL(url2)});
+
+        Class clazz = cl.loadClass(RMIClassLoaderSpiImplTest.class.getName());
+        
+        RMIClassLoaderSpiImpl impl = new RMIClassLoaderSpiImpl();
+        String annotations = impl.getClassAnnotation(clazz);
+        assertEquals(url1 + " " + url2, annotations);
+    }
+    
+
+    public void testGetClassAnnotationWithClassLoaderServerAware() throws Exception {
+        String url1 = "http://localhost:8090/Tester1";
+        String url2 = "http://localhost:8090/Tester2";
+        MockClassLoader cl = new MockClassLoader(getClass().getClassLoader(), new URL[] {new URL(url1), new URL(url2)});
+
+        Class clazz = cl.loadClass(RMIClassLoaderSpiImplTest.class.getName());
+        
+        RMIClassLoaderSpiImpl impl = new RMIClassLoaderSpiImpl();
+        String annotations = impl.getClassAnnotation(clazz);
+        assertEquals(url1 + " " + url2, annotations);
+    }
+    
+    private static class MockClassLoader extends ClassLoader implements RMIClassLoaderSpiImpl.ClassLoaderServerAware {
+        private final ClassLoader delegate;
+        private final URL[] urls;
+
+        private MockClassLoader(ClassLoader delegate, URL[] urls) {
+            this.delegate = delegate;
+            this.urls = urls;
+        }
+        
+        public Class loadClass(String name) throws ClassNotFoundException {
+            if (name.startsWith("java")) {
+                return delegate.loadClass(name);
+            }
+            String resourceName = name.replace('.', '/') + ".class";
+            InputStream in = delegate.getResourceAsStream(resourceName);
+            byte[] buffer = new byte[1024];
+            ByteArrayOutputStream out = new ByteArrayOutputStream();
+            int read = 0;
+            try {
+                while (0 < (read = in.read(buffer))) {
+                    out.write(buffer, 0, read);
+                }
+            } catch (IOException e) {
+                fail();
+                return null;
+            }
+            return defineClass(name, out.toByteArray(), 0, out.size());
+        }  
+        
+        public URL[] getClassLoaderServerURLs() {
+            return urls;
+        }
     }
 }



Mime
View raw message