[jboss-cvs] JBossAS SVN: r86540 - in projects/reloaded/trunk: compoundclassloader and 31 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Mar 31 13:36:50 EDT 2009


Author: wolfc
Date: 2009-03-31 13:36:49 -0400 (Tue, 31 Mar 2009)
New Revision: 86540

Added:
   projects/reloaded/trunk/compoundclassloader/
   projects/reloaded/trunk/compoundclassloader/.classpath
   projects/reloaded/trunk/compoundclassloader/.project
   projects/reloaded/trunk/compoundclassloader/.settings/
   projects/reloaded/trunk/compoundclassloader/.settings/org.eclipse.jdt.core.prefs
   projects/reloaded/trunk/compoundclassloader/.settings/org.maven.ide.eclipse.prefs
   projects/reloaded/trunk/compoundclassloader/pom.xml
   projects/reloaded/trunk/compoundclassloader/src/
   projects/reloaded/trunk/compoundclassloader/src/main/
   projects/reloaded/trunk/compoundclassloader/src/main/java/
   projects/reloaded/trunk/compoundclassloader/src/main/java/org/
   projects/reloaded/trunk/compoundclassloader/src/main/java/org/jboss/
   projects/reloaded/trunk/compoundclassloader/src/main/java/org/jboss/reloaded/
   projects/reloaded/trunk/compoundclassloader/src/main/java/org/jboss/reloaded/compoundclassloader/
   projects/reloaded/trunk/compoundclassloader/src/main/java/org/jboss/reloaded/compoundclassloader/spi/
   projects/reloaded/trunk/compoundclassloader/src/main/java/org/jboss/reloaded/compoundclassloader/spi/dependency/
   projects/reloaded/trunk/compoundclassloader/src/main/java/org/jboss/reloaded/compoundclassloader/spi/dependency/CompoundClassLoaderPolicyModule.java
   projects/reloaded/trunk/compoundclassloader/src/main/java/org/jboss/reloaded/compoundclassloader/spi/metadata/
   projects/reloaded/trunk/compoundclassloader/src/main/java/org/jboss/reloaded/compoundclassloader/spi/metadata/AbstractClassLoaderFactory.java
   projects/reloaded/trunk/compoundclassloader/src/main/java/org/jboss/reloaded/compoundclassloader/spi/metadata/CompoundClassLoaderFactory.java
   projects/reloaded/trunk/compoundclassloader/src/main/java/org/jboss/reloaded/compoundclassloader/spi/metadata/CompoundClassLoaderFactory10.java
   projects/reloaded/trunk/compoundclassloader/src/main/java/org/jboss/reloaded/compoundclassloader/spi/metadata/package-info.java
   projects/reloaded/trunk/compoundclassloader/src/main/java/org/jboss/reloaded/compoundclassloader/spi/policy/
   projects/reloaded/trunk/compoundclassloader/src/main/java/org/jboss/reloaded/compoundclassloader/spi/policy/AbstractClassLoaderPolicy.java
   projects/reloaded/trunk/compoundclassloader/src/main/java/org/jboss/reloaded/compoundclassloader/spi/policy/CompoundClassLoaderPolicy.java
   projects/reloaded/trunk/compoundclassloader/src/main/java/org/jboss/reloaded/compoundclassloader/xb/
   projects/reloaded/trunk/compoundclassloader/src/main/java/org/jboss/reloaded/compoundclassloader/xb/spi/
   projects/reloaded/trunk/compoundclassloader/src/main/java/org/jboss/reloaded/compoundclassloader/xb/spi/JaxbSchema.java
   projects/reloaded/trunk/compoundclassloader/src/main/java/org/jboss/reloaded/compoundclassloader/xb/spi/JaxbSchemaService.java
   projects/reloaded/trunk/compoundclassloader/src/main/java/org/jboss/reloaded/compoundclassloader/xb/spi/ServiceInitializationException.java
   projects/reloaded/trunk/compoundclassloader/src/main/resources/
   projects/reloaded/trunk/compoundclassloader/src/main/resources/META-INF/
   projects/reloaded/trunk/compoundclassloader/src/main/resources/META-INF/services/
   projects/reloaded/trunk/compoundclassloader/src/main/resources/META-INF/services/org.jboss.reloaded.compoundclassloader.xb.spi.JaxbSchema
   projects/reloaded/trunk/compoundclassloader/src/test/
   projects/reloaded/trunk/compoundclassloader/src/test/java/
   projects/reloaded/trunk/compoundclassloader/src/test/java/org/
   projects/reloaded/trunk/compoundclassloader/src/test/java/org/jboss/
   projects/reloaded/trunk/compoundclassloader/src/test/java/org/jboss/reloaded/
   projects/reloaded/trunk/compoundclassloader/src/test/java/org/jboss/reloaded/compoundclassloader/
   projects/reloaded/trunk/compoundclassloader/src/test/java/org/jboss/reloaded/compoundclassloader/test/
   projects/reloaded/trunk/compoundclassloader/src/test/java/org/jboss/reloaded/compoundclassloader/test/simple/
   projects/reloaded/trunk/compoundclassloader/src/test/java/org/jboss/reloaded/compoundclassloader/test/simple/ResourceResolver.java
   projects/reloaded/trunk/compoundclassloader/src/test/java/org/jboss/reloaded/compoundclassloader/test/simple/unit/
   projects/reloaded/trunk/compoundclassloader/src/test/java/org/jboss/reloaded/compoundclassloader/test/simple/unit/CompoundCLTestCase.java
   projects/reloaded/trunk/compoundclassloader/src/test/resources/
   projects/reloaded/trunk/compoundclassloader/src/test/resources/conf/
   projects/reloaded/trunk/compoundclassloader/src/test/resources/conf/bootstrap.xml
   projects/reloaded/trunk/compoundclassloader/src/test/resources/conf/bootstrap/
   projects/reloaded/trunk/compoundclassloader/src/test/resources/conf/bootstrap/classloader.xml
   projects/reloaded/trunk/compoundclassloader/src/test/resources/conf/bootstrap/jbossxb.xml
   projects/reloaded/trunk/compoundclassloader/src/test/resources/conf/bootstrap/testcompoundcl.xml
   projects/reloaded/trunk/compoundclassloader/src/test/resources/log4j.xml
   projects/reloaded/trunk/compoundclassloader/src/test/resources/path1/
   projects/reloaded/trunk/compoundclassloader/src/test/resources/path1/somefile.txt
   projects/reloaded/trunk/compoundclassloader/src/test/resources/path2/
   projects/reloaded/trunk/compoundclassloader/src/test/resources/path2/someotherfile.txt
   projects/reloaded/trunk/compoundclassloader/src/test/resources/somefile.txt
Log:
RELOADED-4: intial setup of compound class loader factory


Property changes on: projects/reloaded/trunk/compoundclassloader
___________________________________________________________________
Name: svn:ignore
   + eclipse-target
target


Added: projects/reloaded/trunk/compoundclassloader/.classpath
===================================================================
--- projects/reloaded/trunk/compoundclassloader/.classpath	                        (rev 0)
+++ projects/reloaded/trunk/compoundclassloader/.classpath	2009-03-31 17:36:49 UTC (rev 86540)
@@ -0,0 +1,9 @@
+<classpath>
+  <classpathentry kind="src" path="src/main/java"/>
+  <classpathentry kind="src" path="src/main/resources" excluding="**/*.java"/>
+  <classpathentry kind="src" path="src/test/java" output="eclipse-target/test-classes"/>
+  <classpathentry kind="src" path="src/test/resources" output="eclipse-target/test-classes" excluding="**/*.java"/>
+  <classpathentry kind="output" path="eclipse-target/classes"/>
+  <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+  <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
+</classpath>
\ No newline at end of file

Added: projects/reloaded/trunk/compoundclassloader/.project
===================================================================
--- projects/reloaded/trunk/compoundclassloader/.project	                        (rev 0)
+++ projects/reloaded/trunk/compoundclassloader/.project	2009-03-31 17:36:49 UTC (rev 86540)
@@ -0,0 +1,17 @@
+<projectDescription>
+  <name>jboss-reloaded-compoundclassloader</name>
+  <comment>Allows multiple class loader factories to be stacked.</comment>
+  <projects/>
+  <buildSpec>
+    <buildCommand>
+      <name>org.eclipse.jdt.core.javabuilder</name>
+    </buildCommand>
+    <buildCommand>
+      <name>org.maven.ide.eclipse.maven2Builder</name>
+    </buildCommand>
+  </buildSpec>
+  <natures>
+    <nature>org.eclipse.jdt.core.javanature</nature>
+    <nature>org.maven.ide.eclipse.maven2Nature</nature>
+  </natures>
+</projectDescription>
\ No newline at end of file

Added: projects/reloaded/trunk/compoundclassloader/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- projects/reloaded/trunk/compoundclassloader/.settings/org.eclipse.jdt.core.prefs	                        (rev 0)
+++ projects/reloaded/trunk/compoundclassloader/.settings/org.eclipse.jdt.core.prefs	2009-03-31 17:36:49 UTC (rev 86540)
@@ -0,0 +1,5 @@
+#Tue Mar 31 14:22:58 CEST 2009
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.source=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5

Added: projects/reloaded/trunk/compoundclassloader/.settings/org.maven.ide.eclipse.prefs
===================================================================
--- projects/reloaded/trunk/compoundclassloader/.settings/org.maven.ide.eclipse.prefs	                        (rev 0)
+++ projects/reloaded/trunk/compoundclassloader/.settings/org.maven.ide.eclipse.prefs	2009-03-31 17:36:49 UTC (rev 86540)
@@ -0,0 +1,8 @@
+#Tue Mar 31 15:55:16 CEST 2009
+activeProfiles=eclipse
+eclipse.preferences.version=1
+fullBuildGoals=process-test-resources
+includeModules=false
+resolveWorkspaceProjects=true
+resourceFilterGoals=process-resources resources\:testResources
+version=1

Added: projects/reloaded/trunk/compoundclassloader/pom.xml
===================================================================
--- projects/reloaded/trunk/compoundclassloader/pom.xml	                        (rev 0)
+++ projects/reloaded/trunk/compoundclassloader/pom.xml	2009-03-31 17:36:49 UTC (rev 86540)
@@ -0,0 +1,51 @@
+<!-- 
+  vi:ts=2:sw=2:expandtab 
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <parent>
+    <groupId>org.jboss.reloaded</groupId>
+    <artifactId>jboss-reloaded-build</artifactId>
+    <version>0.1.0-SNAPSHOT</version>
+    <relativePath>../build/pom.xml</relativePath>
+  </parent>
+  <modelVersion>4.0.0</modelVersion>
+  <artifactId>jboss-reloaded-compoundclassloader</artifactId>
+  <version>0.1.0-SNAPSHOT</version>
+  <packaging>jar</packaging>
+  <name>JBoss Reloaded Compound ClassLoader</name>
+  <url>http://www.jboss.org</url>
+  <description>
+    Allows multiple class loader factories to be stacked.
+  </description>
+  
+  <dependencies>
+    <dependency>
+      <groupId>org.jboss.bootstrap</groupId>
+      <artifactId>jboss-bootstrap</artifactId>
+      <version>1.0.0-SNAPSHOT</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss.cl</groupId>
+      <artifactId>jboss-classloading-vfs</artifactId>
+      <version>2.0.4.GA</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss.cl</groupId>
+      <artifactId>jboss-classloading</artifactId>
+      <version>2.0.4.GA</version>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss.man</groupId>
+      <artifactId>jboss-managed</artifactId>
+      <version>2.0.0.GA</version>
+      <scope>compile</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss.microcontainer</groupId>
+      <artifactId>jboss-kernel</artifactId>
+      <version>2.0.4.GA</version>
+    </dependency>
+  </dependencies>
+</project>

Added: projects/reloaded/trunk/compoundclassloader/src/main/java/org/jboss/reloaded/compoundclassloader/spi/dependency/CompoundClassLoaderPolicyModule.java
===================================================================
--- projects/reloaded/trunk/compoundclassloader/src/main/java/org/jboss/reloaded/compoundclassloader/spi/dependency/CompoundClassLoaderPolicyModule.java	                        (rev 0)
+++ projects/reloaded/trunk/compoundclassloader/src/main/java/org/jboss/reloaded/compoundclassloader/spi/dependency/CompoundClassLoaderPolicyModule.java	2009-03-31 17:36:49 UTC (rev 86540)
@@ -0,0 +1,163 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.reloaded.compoundclassloader.spi.dependency;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.classloader.spi.ClassLoaderPolicy;
+import org.jboss.classloading.spi.dependency.policy.ClassLoaderPolicyModule;
+import org.jboss.kernel.spi.dependency.KernelControllerContext;
+import org.jboss.reloaded.compoundclassloader.spi.metadata.CompoundClassLoaderFactory;
+import org.jboss.reloaded.compoundclassloader.spi.policy.CompoundClassLoaderPolicy;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class CompoundClassLoaderPolicyModule extends ClassLoaderPolicyModule
+{
+   /** The serialVersionUID */
+   private static final long serialVersionUID = 1L;
+
+   private ClassLoaderPolicyModule modules[];
+
+   /**
+    * Create a new CompoundClassLoaderPolicyModule.
+    *
+    * @param classLoadingMetaData the classloading metadata
+    * @param contextName the context name
+    */
+   public CompoundClassLoaderPolicyModule(CompoundClassLoaderFactory classLoadingMetaData, String contextName)
+   {
+      super(classLoadingMetaData, contextName);
+   }
+
+   /*
+   @Override
+   protected List<Capability> determineCapabilities()
+   {
+      // While we are here, check the roots
+      VirtualFile[] roots = determineVFSRoots();
+
+      List<Capability> capabilities = super.determineCapabilities();
+      if (capabilities != null)
+         return capabilities;
+
+      // We need to work it out
+      ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance();
+      capabilities = new CopyOnWriteArrayList<Capability>();
+
+      // We have a module capability
+      Object version = getVersion();
+      Capability capability = factory.createModule(getName(), version);
+      capabilities.add(capability);
+
+      // Do we determine package capabilities
+      ClassFilter included = getIncluded();
+      ClassFilter excluded = getExcluded();
+      ClassFilter excludedExport = getExcludedExport();
+      ExportAll exportAll = getExportAll();
+      if (exportAll != null)
+      {
+         Set<String> exportedPackages = PackageVisitor.determineAllPackages(roots, null, exportAll, included, excluded, excludedExport);
+         for (String packageName : exportedPackages)
+         {
+            capability = factory.createPackage(packageName, version);
+            capabilities.add(capability);
+         }
+      }
+
+      return capabilities;
+   }
+   */
+
+   public void setKernelControllerContext(KernelControllerContext context) throws Exception
+   {
+      setControllerContext(context);
+   }
+
+   public void unsetKernelControllerContext(KernelControllerContext context) throws Exception
+   {
+      setControllerContext(null);
+   }
+
+   @Override
+   protected CompoundClassLoaderFactory getClassLoadingMetaData()
+   {
+      return (CompoundClassLoaderFactory) super.getClassLoadingMetaData();
+   }
+
+   @Override
+   public CompoundClassLoaderPolicy getPolicy()
+   {
+      return (CompoundClassLoaderPolicy) super.getPolicy();
+   }
+
+   @Override
+   protected CompoundClassLoaderPolicy determinePolicy()
+   {
+      List<ClassLoaderPolicy> policies = new ArrayList<ClassLoaderPolicy>();
+      for(ClassLoaderPolicyModule module : modules)
+         policies.add(module.getPolicy());
+      CompoundClassLoaderPolicy policy = new CompoundClassLoaderPolicy(getContextName(), policies);
+      
+      String[] packageNames = getPackageNames();
+      policy.setExportedPackages(packageNames);
+      policy.setIncluded(getIncluded());
+      policy.setExcluded(getExcluded());
+      policy.setExcludedExport(getExcludedExport());
+      policy.setExportAll(getExportAll());
+      policy.setImportAll(isImportAll());
+      policy.setCacheable(isCacheable());
+      policy.setBlackListable(isBlackListable());
+      policy.setDelegates(getDelegates());
+      return policy;
+   }
+
+   @Override
+   public void reset()
+   {
+      super.reset();
+   }
+
+//   @Override
+//   public void visit(ResourceVisitor visitor, ResourceFilter filter, ResourceFilter recurseFilter, URL... urls)
+//   {
+//      ClassLoader classLoader = getClassLoader();
+//      if (classLoader == null)
+//         throw new IllegalStateException("ClassLoader has not been constructed for " + getContextName());
+//
+//      VirtualFile[] roots = determineVFSRoots();
+//      if (roots != null && roots.length > 0)
+//      {
+//         ClassFilter included = getIncluded();
+//         ClassFilter excluded = getExcluded();
+//         VFSResourceVisitor.visit(roots, null, included, excluded, classLoader, visitor, filter, recurseFilter, urls);
+//      }
+//   }
+
+   public void setModules(ClassLoaderPolicyModule modules[])
+   {
+      this.modules = modules;
+   }
+}

Added: projects/reloaded/trunk/compoundclassloader/src/main/java/org/jboss/reloaded/compoundclassloader/spi/metadata/AbstractClassLoaderFactory.java
===================================================================
--- projects/reloaded/trunk/compoundclassloader/src/main/java/org/jboss/reloaded/compoundclassloader/spi/metadata/AbstractClassLoaderFactory.java	                        (rev 0)
+++ projects/reloaded/trunk/compoundclassloader/src/main/java/org/jboss/reloaded/compoundclassloader/spi/metadata/AbstractClassLoaderFactory.java	2009-03-31 17:36:49 UTC (rev 86540)
@@ -0,0 +1,100 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.reloaded.compoundclassloader.spi.metadata;
+
+import javax.xml.bind.annotation.XmlAttribute;
+
+import org.jboss.beans.metadata.spi.BeanMetaDataFactory;
+import org.jboss.classloading.spi.dependency.policy.ClassLoaderPolicyModule;
+import org.jboss.classloading.spi.metadata.ClassLoadingMetaData;
+import org.jboss.managed.api.annotation.ManagementProperty;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public abstract class AbstractClassLoaderFactory extends ClassLoadingMetaData implements BeanMetaDataFactory
+{
+   private static final long serialVersionUID = 1L;
+
+   /** The default name for the classloading system */
+   public static final String DEFAULT_CLASSLOADER_SYSTEM_NAME = "ClassLoaderSystem";
+   
+   /** The name of the classloader system */
+   private String classLoaderSystemName = DEFAULT_CLASSLOADER_SYSTEM_NAME;
+   
+   /** The context name */
+   private String contextName = null;
+ 
+   /**
+    * Get the classLoaderSystemName.
+    * 
+    * @return the classLoaderSystemName.
+    */
+   public String getClassLoaderSystemName()
+   {
+      return classLoaderSystemName;
+   }
+
+   /**
+    * Get the contextName.
+    * 
+    * @return the contextName.
+    */
+   public String getContextName()
+   {
+      return contextName;
+   }
+
+   /**
+    * Get module class.
+    *
+    * @return the module class.
+    */
+   protected abstract Class<? extends ClassLoaderPolicyModule> getModuleClass();
+
+   /**
+    * Set the classLoaderSystemName.
+    * 
+    * @param classLoaderSystemName the classLoaderSystemName.
+    */
+   @ManagementProperty(name="system")
+   @XmlAttribute(name="system")
+   public void setClassLoaderSystemName(String classLoaderSystemName)
+   {
+      if (classLoaderSystemName == null)
+         classLoaderSystemName = DEFAULT_CLASSLOADER_SYSTEM_NAME;
+      this.classLoaderSystemName = classLoaderSystemName;
+   }
+
+   /**
+    * Set the contextName.
+    * 
+    * @param contextName the contextName.
+    */
+   @ManagementProperty(name="context")
+   @XmlAttribute(name="context")
+   public void setContextName(String contextName)
+   {
+      this.contextName = contextName;
+   }
+}

Added: projects/reloaded/trunk/compoundclassloader/src/main/java/org/jboss/reloaded/compoundclassloader/spi/metadata/CompoundClassLoaderFactory.java
===================================================================
--- projects/reloaded/trunk/compoundclassloader/src/main/java/org/jboss/reloaded/compoundclassloader/spi/metadata/CompoundClassLoaderFactory.java	                        (rev 0)
+++ projects/reloaded/trunk/compoundclassloader/src/main/java/org/jboss/reloaded/compoundclassloader/spi/metadata/CompoundClassLoaderFactory.java	2009-03-31 17:36:49 UTC (rev 86540)
@@ -0,0 +1,118 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.reloaded.compoundclassloader.spi.metadata;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlTransient;
+
+import org.jboss.beans.metadata.spi.BeanMetaData;
+import org.jboss.beans.metadata.spi.ValueMetaData;
+import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
+import org.jboss.classloader.spi.ClassLoaderSystem;
+import org.jboss.classloading.spi.version.Version;
+import org.jboss.managed.api.annotation.ManagementProperty;
+import org.jboss.reloaded.compoundclassloader.spi.dependency.CompoundClassLoaderPolicyModule;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class CompoundClassLoaderFactory extends AbstractClassLoaderFactory
+{
+   private static final long serialVersionUID = 1L;
+   private List<String> delegates;
+
+   public CompoundClassLoaderFactory()
+   {
+   }
+   
+   public CompoundClassLoaderFactory(String name)
+   {
+      this(name, Version.DEFAULT_VERSION);
+   }
+   
+   public CompoundClassLoaderFactory(String name, String version)
+   {
+      this(name, Version.parseVersion(version));
+   }
+   
+   public CompoundClassLoaderFactory(String name, Version version)
+   {
+      setName(name);
+      setVersion(version);
+   }
+   
+   @XmlTransient
+   public List<BeanMetaData> getBeans()
+   {
+      // Determine some properties
+      String contextName = getContextName();
+      if (contextName == null)
+         contextName = getName() + ":" + getVersion();
+      String moduleName = contextName + "$MODULE";
+      
+      // Create the module
+      BeanMetaDataBuilder builder = BeanMetaDataBuilder.createBuilder(moduleName, getModuleClass().getName());
+      builder.addConstructorParameter(CompoundClassLoaderFactory.class.getName(), this);
+      builder.addConstructorParameter(String.class.getName(), moduleName);
+      Collection<ValueMetaData> classLoaders = builder.createArray();
+      for(String delegate : delegates)
+         classLoaders.add(builder.createInject(delegate + "$MODULE"));
+      builder.addPropertyMetaData("modules", classLoaders);
+      //builder.addPropertyMetaData("delegates", delegates);
+      builder.setNoClassLoader();
+      builder.addUninstall("removeClassLoader");
+      BeanMetaData module = builder.getBeanMetaData();
+      
+      // Create the classloader
+      builder = BeanMetaDataBuilder.createBuilder(contextName, ClassLoader.class.getName());
+      builder.setNoClassLoader();
+      builder.setFactory(moduleName);
+      builder.setFactoryMethod("registerClassLoaderPolicy");
+      builder.addConstructorParameter(ClassLoaderSystem.class.getName(), builder.createInject(getClassLoaderSystemName()));
+      BeanMetaData classLoader = builder.getBeanMetaData();
+      
+      return Arrays.asList(classLoader, module);
+   }
+
+   public List<String> getDelegates()
+   {
+      return delegates;
+   }
+   
+   @Override
+   protected Class<? extends CompoundClassLoaderPolicyModule> getModuleClass()
+   {
+      return CompoundClassLoaderPolicyModule.class;
+   }
+   
+   @ManagementProperty(name="delegates")
+   @XmlElement(name="delegate")
+   public void setDelegates(List<String> delegates)
+   {
+      this.delegates = delegates;
+   }
+}

Added: projects/reloaded/trunk/compoundclassloader/src/main/java/org/jboss/reloaded/compoundclassloader/spi/metadata/CompoundClassLoaderFactory10.java
===================================================================
--- projects/reloaded/trunk/compoundclassloader/src/main/java/org/jboss/reloaded/compoundclassloader/spi/metadata/CompoundClassLoaderFactory10.java	                        (rev 0)
+++ projects/reloaded/trunk/compoundclassloader/src/main/java/org/jboss/reloaded/compoundclassloader/spi/metadata/CompoundClassLoaderFactory10.java	2009-03-31 17:36:49 UTC (rev 86540)
@@ -0,0 +1,52 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.reloaded.compoundclassloader.spi.metadata;
+
+import javax.xml.bind.annotation.XmlNsForm;
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.jboss.reloaded.compoundclassloader.xb.spi.JaxbSchema;
+import org.jboss.xb.annotations.JBossXmlSchema;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+ at JBossXmlSchema(namespace="urn:jboss:compoundclassloader:1.0", elementFormDefault=XmlNsForm.QUALIFIED)
+ at XmlRootElement(name="classloader")
+public class CompoundClassLoaderFactory10 extends CompoundClassLoaderFactory
+{
+   private static final long serialVersionUID = 1L;
+
+   public static class Schema implements JaxbSchema
+   {
+      public String getNamespace()
+      {
+         return "urn:jboss:compoundclassloader:1.0";
+      }
+   
+      public Class<?> getReference()
+      {
+         return CompoundClassLoaderFactory10.class;
+      }
+   }
+}

Added: projects/reloaded/trunk/compoundclassloader/src/main/java/org/jboss/reloaded/compoundclassloader/spi/metadata/package-info.java
===================================================================
--- projects/reloaded/trunk/compoundclassloader/src/main/java/org/jboss/reloaded/compoundclassloader/spi/metadata/package-info.java	                        (rev 0)
+++ projects/reloaded/trunk/compoundclassloader/src/main/java/org/jboss/reloaded/compoundclassloader/spi/metadata/package-info.java	2009-03-31 17:36:49 UTC (rev 86540)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+ at JBossXmlAdaptedTypes
+({
+   @JBossXmlAdaptedType(type=Version.class, valueAdapter=VersionValueAdapter.class)
+})
+package org.jboss.reloaded.compoundclassloader.spi.metadata;
+
+import org.jboss.classloading.plugins.metadata.VersionValueAdapter;
+import org.jboss.classloading.spi.version.Version;
+import org.jboss.xb.annotations.JBossXmlAdaptedType;
+import org.jboss.xb.annotations.JBossXmlAdaptedTypes;
+

Added: projects/reloaded/trunk/compoundclassloader/src/main/java/org/jboss/reloaded/compoundclassloader/spi/policy/AbstractClassLoaderPolicy.java
===================================================================
--- projects/reloaded/trunk/compoundclassloader/src/main/java/org/jboss/reloaded/compoundclassloader/spi/policy/AbstractClassLoaderPolicy.java	                        (rev 0)
+++ projects/reloaded/trunk/compoundclassloader/src/main/java/org/jboss/reloaded/compoundclassloader/spi/policy/AbstractClassLoaderPolicy.java	2009-03-31 17:36:49 UTC (rev 86540)
@@ -0,0 +1,342 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.reloaded.compoundclassloader.spi.policy;
+
+import java.net.URL;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.jar.Manifest;
+
+import org.jboss.classloader.spi.ClassLoaderPolicy;
+import org.jboss.classloader.spi.DelegateLoader;
+import org.jboss.classloader.spi.filter.ClassFilter;
+import org.jboss.classloader.spi.filter.FilteredDelegateLoader;
+import org.jboss.classloading.spi.metadata.ExportAll;
+import org.jboss.logging.Logger;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public abstract class AbstractClassLoaderPolicy extends ClassLoaderPolicy
+{
+   /** The log */
+   private static Logger log = Logger.getLogger(AbstractClassLoaderPolicy.class);
+
+   /** Tag for no manifest */
+   private static final Manifest NO_MANIFEST = new Manifest();
+
+   /** A name for the policy */
+   private String name;
+   
+   /** The delegates */
+   private List<? extends DelegateLoader> delegates;
+   
+   /** Whether to export all */
+   private ExportAll exportAll;
+
+   /** The included */
+   private ClassFilter included;
+
+   /** The excluded */
+   private ClassFilter excluded;
+   
+   /** The excluded for export */
+   private ClassFilter excludedExport;
+   
+   /** The exported packages */
+   private String[] exportedPackages;
+
+   /** The import all */
+   private boolean importAll;
+
+   /** Whether we are cachable */
+   private boolean cacheable = true;
+   
+   /** Whether we are blacklistable */
+   private boolean blackListable = true;
+   
+   /** Manifest cache */
+   private Map<URL, Manifest> manifestCache = new ConcurrentHashMap<URL, Manifest>();
+   
+   /** JBCL-64, JBVFS-77: CodeSource should use real url **/
+   private boolean useRealURL = true;
+
+   /**
+    * Create a new AbstractClassLoaderPolicy.
+    * 
+    * @param name the name
+    * @throws IllegalArgumentException for null roots
+    */
+   protected AbstractClassLoaderPolicy(String name)
+   {
+      if (name == null)
+         throw new IllegalArgumentException("Null name");
+      this.name = name;
+   }
+
+   @Override
+   public List<? extends DelegateLoader> getDelegates()
+   {
+      return delegates;
+   }
+
+   /**
+    * Set the delegates.
+    * 
+    * @param delegates the delegates.
+    */
+   public void setDelegates(List<? extends DelegateLoader> delegates)
+   {
+      this.delegates = delegates;
+   }
+
+   /**
+    * Get the included.
+    * 
+    * @return the included.
+    */
+   public ClassFilter getIncluded()
+   {
+      return included;
+   }
+
+   /**
+    * Set the included.
+    * 
+    * @param included the included.
+    */
+   public void setIncluded(ClassFilter included)
+   {
+      this.included = included;
+   }
+
+   /**
+    * Get the excluded.
+    * 
+    * @return the excluded.
+    */
+   public ClassFilter getExcluded()
+   {
+      return excluded;
+   }
+
+   /**
+    * Set the excluded.
+    * 
+    * @param excluded the excluded.
+    */
+   public void setExcluded(ClassFilter excluded)
+   {
+      this.excluded = excluded;
+   }
+
+   /**
+    * Get the excludedExport.
+    * 
+    * @return the excludedExport.
+    */
+   public ClassFilter getExcludedExport()
+   {
+      return excludedExport;
+   }
+
+   /**
+    * Set the excludedExport.
+    * 
+    * @param excludedExport the excludedExport.
+    */
+   public void setExcludedExport(ClassFilter excludedExport)
+   {
+      this.excludedExport = excludedExport;
+   }
+
+   /**
+    * Get the exportAll.
+    * 
+    * @return the exportAll.
+    */
+   public ExportAll getExportAll()
+   {
+      return exportAll;
+   }
+
+   /**
+    * Set the exportAll.
+    * 
+    * @param exportAll the exportAll.
+    */
+   public void setExportAll(ExportAll exportAll)
+   {
+      this.exportAll = exportAll;
+      if (exportAll != null)
+      {
+         if (exportedPackages == null)
+         {
+            exportedPackages = determineExportedPackages();
+         }
+      }
+   }
+
+   /**
+    * Get the exported packages
+    * 
+    * @return the exported packages
+    */
+   public String[] getExportedPackages()
+   {
+      return exportedPackages;
+   }
+
+   /**
+    * Set the exportedPackages.
+    * 
+    * @param exportedPackages the exportedPackages.
+    */
+   public void setExportedPackages(String[] exportedPackages)
+   {
+      this.exportedPackages = exportedPackages;
+   }
+
+   @Override
+   public String getName()
+   {
+      return name;
+   }
+
+   @Override
+   public String[] getPackageNames()
+   {
+      return exportedPackages;
+   }
+
+   @Override
+   public boolean isImportAll()
+   {
+      return importAll;
+   }
+
+   /**
+    * Set the importAll.
+    * 
+    * @param importAll the importAll.
+    */
+   public void setImportAll(boolean importAll)
+   {
+      this.importAll = importAll;
+   }
+
+   @Override
+   public boolean isCacheable()
+   {
+      return cacheable;
+   }
+
+   /**
+    * Set the cacheable.
+    * 
+    * @param cacheable the cacheable.
+    */
+   public void setCacheable(boolean cacheable)
+   {
+      this.cacheable = cacheable;
+   }
+
+   @Override
+   public boolean isBlackListable()
+   {
+      return blackListable;
+   }
+
+   /**
+    * Set the blackListable.
+    * 
+    * @param blackListable the blackListable.
+    */
+   public void setBlackListable(boolean blackListable)
+   {
+      this.blackListable = blackListable;
+   }
+
+   @Override
+   public DelegateLoader getExported()
+   {
+      if (getExportAll() != null)
+         return new FilteredDelegateLoader(this, ClassFilter.EVERYTHING);
+      return super.getExported();
+   }
+
+   /**
+    * Do we use real url.
+    *
+    * @return true if real url should be used
+    */
+   public boolean isUseRealURL()
+   {
+      return useRealURL;
+   }
+
+   /**
+    * Set use real url flag.
+    *
+     * @param useRealURL the real url flag
+    */
+   public void setUseRealURL(boolean useRealURL)
+   {
+      this.useRealURL = useRealURL;
+   }
+
+   @Override
+   protected void toLongString(StringBuilder builder)
+   {
+      super.toLongString(builder);
+      if (exportAll != null)
+         builder.append(",exportAll=" + exportAll);
+   }
+
+   /**
+    * Check the filters
+    * 
+    * @param path the path to check
+    * @param context the context
+    * @return true if it fails the filters
+    */
+   protected boolean checkFilters(String path, String context)
+   {
+      if (included != null && included.matchesResourcePath(path) == false)
+      {
+         if (log.isTraceEnabled())
+            log.trace(this + " " + context + " path=" + path + " doesn't match include filter: " + included);
+         return true;
+      }
+      if (excluded != null && excluded.matchesResourcePath(path))
+      {
+         if (log.isTraceEnabled())
+            log.trace(this + " " + context + "  path=" + path + " matches exclude filter: " + excluded);
+         return true;
+      }
+      return false;
+   }
+
+   protected abstract String[] determineExportedPackages();
+}

Added: projects/reloaded/trunk/compoundclassloader/src/main/java/org/jboss/reloaded/compoundclassloader/spi/policy/CompoundClassLoaderPolicy.java
===================================================================
--- projects/reloaded/trunk/compoundclassloader/src/main/java/org/jboss/reloaded/compoundclassloader/spi/policy/CompoundClassLoaderPolicy.java	                        (rev 0)
+++ projects/reloaded/trunk/compoundclassloader/src/main/java/org/jboss/reloaded/compoundclassloader/spi/policy/CompoundClassLoaderPolicy.java	2009-03-31 17:36:49 UTC (rev 86540)
@@ -0,0 +1,88 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.reloaded.compoundclassloader.spi.policy;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Set;
+
+import org.jboss.classloader.spi.ClassLoaderPolicy;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class CompoundClassLoaderPolicy extends AbstractClassLoaderPolicy
+{
+   private List<ClassLoaderPolicy> delegates;
+   
+   /**
+    * @param name
+    * @param delegates
+    */
+   public CompoundClassLoaderPolicy(String name, List<ClassLoaderPolicy> delegates)
+   {
+      super(name);
+      this.delegates = delegates;
+   }
+
+   @Override
+   protected String[] determineExportedPackages()
+   {
+      List<String> exportedPackages = new ArrayList<String>();
+      for(ClassLoaderPolicy delegate : delegates)
+      {
+         exportedPackages.addAll(Arrays.asList(delegate.getPackageNames()));
+      }
+      return exportedPackages.toArray(new String[0]);
+   }
+
+   @Override
+   public URL getResource(String path)
+   {
+      if (checkFilters(path, "getResource"))
+         return null;
+      
+      for(ClassLoaderPolicy delegate : delegates)
+      {
+         URL resource = delegate.getResource(path);
+         if(resource != null)
+            return resource;
+      }
+      return null;
+   }
+
+   @Override
+   public void getResources(String name, Set<URL> urls) throws IOException
+   {
+      if (checkFilters(name, "getResources"))
+         return;
+      
+      for(ClassLoaderPolicy delegate : delegates)
+      {
+         delegate.getResources(name, urls);
+      }
+   }
+}

Added: projects/reloaded/trunk/compoundclassloader/src/main/java/org/jboss/reloaded/compoundclassloader/xb/spi/JaxbSchema.java
===================================================================
--- projects/reloaded/trunk/compoundclassloader/src/main/java/org/jboss/reloaded/compoundclassloader/xb/spi/JaxbSchema.java	                        (rev 0)
+++ projects/reloaded/trunk/compoundclassloader/src/main/java/org/jboss/reloaded/compoundclassloader/xb/spi/JaxbSchema.java	2009-03-31 17:36:49 UTC (rev 86540)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.reloaded.compoundclassloader.xb.spi;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public interface JaxbSchema
+{
+   String getNamespace();
+   Class<?> getReference();
+}

Added: projects/reloaded/trunk/compoundclassloader/src/main/java/org/jboss/reloaded/compoundclassloader/xb/spi/JaxbSchemaService.java
===================================================================
--- projects/reloaded/trunk/compoundclassloader/src/main/java/org/jboss/reloaded/compoundclassloader/xb/spi/JaxbSchemaService.java	                        (rev 0)
+++ projects/reloaded/trunk/compoundclassloader/src/main/java/org/jboss/reloaded/compoundclassloader/xb/spi/JaxbSchemaService.java	2009-03-31 17:36:49 UTC (rev 86540)
@@ -0,0 +1,125 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.reloaded.compoundclassloader.xb.spi;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.jboss.xb.binding.sunday.unmarshalling.SingletonSchemaResolverFactory;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class JaxbSchemaService
+{
+   private static final Pattern nonCommentPattern = Pattern.compile("^([^#]+)");
+   
+   private List<JaxbSchema> schemas;
+   
+   private static <T> List<T> findAllServices(Class<T> serviceClass) throws ServiceInitializationException
+   {
+      try
+      {
+         List<T> services = new ArrayList<T>();
+         ClassLoader loader = Thread.currentThread().getContextClassLoader();
+         Enumeration<URL> resources = loader.getResources("META-INF/services/" + serviceClass.getName());
+         Set<String> names = new HashSet<String>();
+         while (resources.hasMoreElements())
+         {
+            URL url = resources.nextElement();
+            InputStream is = url.openStream();
+            try
+            {
+               names.addAll(factoryNamesFromReader(new BufferedReader(new InputStreamReader(is))));
+            }
+            finally
+            {
+               is.close();
+            }
+         }
+         for (String s : names)
+         {
+            Class<?> cls = loader.loadClass(s);
+            services.add(serviceClass.cast(cls.newInstance()));
+         }
+         return services;
+      }
+      catch (IOException e)
+      {
+         throw new ServiceInitializationException(e);
+      }
+      catch (InstantiationException e)
+      {
+         throw new ServiceInitializationException(e);
+      }
+      catch (IllegalAccessException e)
+      {
+         throw new ServiceInitializationException(e);
+      }
+      catch (ClassNotFoundException e)
+      {
+         throw new ServiceInitializationException(e);
+      }
+   }
+   
+   private static List<String> factoryNamesFromReader(BufferedReader reader) throws IOException
+   {
+      List<String> names = new ArrayList<String>();
+      String line;
+      while ((line = reader.readLine()) != null)
+      {
+         line = line.trim();
+         Matcher m = nonCommentPattern.matcher(line);
+         if (m.find())
+         {
+            names.add(m.group().trim());
+         }
+      }
+      return names;
+   }
+   
+   public void start() throws ServiceInitializationException
+   {
+      schemas = findAllServices(JaxbSchema.class);
+      for(JaxbSchema schema : schemas)
+      {
+         SingletonSchemaResolverFactory.getInstance().addJaxbSchema(schema.getNamespace(), schema.getReference().getName());
+      }
+   }
+   
+   public void stop()
+   {
+      // TODO: can't remove schema
+      schemas.clear();
+   }
+}

Added: projects/reloaded/trunk/compoundclassloader/src/main/java/org/jboss/reloaded/compoundclassloader/xb/spi/ServiceInitializationException.java
===================================================================
--- projects/reloaded/trunk/compoundclassloader/src/main/java/org/jboss/reloaded/compoundclassloader/xb/spi/ServiceInitializationException.java	                        (rev 0)
+++ projects/reloaded/trunk/compoundclassloader/src/main/java/org/jboss/reloaded/compoundclassloader/xb/spi/ServiceInitializationException.java	2009-03-31 17:36:49 UTC (rev 86540)
@@ -0,0 +1,36 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.reloaded.compoundclassloader.xb.spi;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class ServiceInitializationException extends Exception
+{
+   private static final long serialVersionUID = 1L;
+
+   public ServiceInitializationException(Throwable cause)
+   {
+      super(cause);
+   }
+}

Added: projects/reloaded/trunk/compoundclassloader/src/main/resources/META-INF/services/org.jboss.reloaded.compoundclassloader.xb.spi.JaxbSchema
===================================================================
--- projects/reloaded/trunk/compoundclassloader/src/main/resources/META-INF/services/org.jboss.reloaded.compoundclassloader.xb.spi.JaxbSchema	                        (rev 0)
+++ projects/reloaded/trunk/compoundclassloader/src/main/resources/META-INF/services/org.jboss.reloaded.compoundclassloader.xb.spi.JaxbSchema	2009-03-31 17:36:49 UTC (rev 86540)
@@ -0,0 +1,2 @@
+#org.jboss.reloaded.compoundclassloader.spi.metadata.CompoundClassLoaderFactory10.Schema
+org.jboss.reloaded.compoundclassloader.spi.metadata.CompoundClassLoaderFactory10$Schema
\ No newline at end of file

Added: projects/reloaded/trunk/compoundclassloader/src/test/java/org/jboss/reloaded/compoundclassloader/test/simple/ResourceResolver.java
===================================================================
--- projects/reloaded/trunk/compoundclassloader/src/test/java/org/jboss/reloaded/compoundclassloader/test/simple/ResourceResolver.java	                        (rev 0)
+++ projects/reloaded/trunk/compoundclassloader/src/test/java/org/jboss/reloaded/compoundclassloader/test/simple/ResourceResolver.java	2009-03-31 17:36:49 UTC (rev 86540)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.reloaded.compoundclassloader.test.simple;
+
+import java.net.URL;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class ResourceResolver
+{
+   private ClassLoader loader;
+   
+   public ResourceResolver()
+   {
+      loader = Thread.currentThread().getContextClassLoader();
+   }
+   
+   public URL getResource(String name)
+   {
+      return loader.getResource(name);
+   }
+}

Added: projects/reloaded/trunk/compoundclassloader/src/test/java/org/jboss/reloaded/compoundclassloader/test/simple/unit/CompoundCLTestCase.java
===================================================================
--- projects/reloaded/trunk/compoundclassloader/src/test/java/org/jboss/reloaded/compoundclassloader/test/simple/unit/CompoundCLTestCase.java	                        (rev 0)
+++ projects/reloaded/trunk/compoundclassloader/src/test/java/org/jboss/reloaded/compoundclassloader/test/simple/unit/CompoundCLTestCase.java	2009-03-31 17:36:49 UTC (rev 86540)
@@ -0,0 +1,111 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.reloaded.compoundclassloader.test.simple.unit;
+
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URI;
+import java.net.URL;
+import java.util.Properties;
+
+import org.jboss.bootstrap.microcontainer.ServerImpl;
+import org.jboss.bootstrap.spi.ServerConfig;
+import org.jboss.bootstrap.spi.microcontainer.MCServer;
+import org.jboss.reloaded.compoundclassloader.test.simple.ResourceResolver;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class CompoundCLTestCase
+{
+   private static MCServer server;
+   
+   @AfterClass
+   public static void afterClass()
+   {
+      if(server != null && server.isStarted())
+         server.shutdown();
+   }
+   
+   @BeforeClass
+   public static void beforeClass() throws Exception
+   {
+      System.setProperty("basedir", new File(".").toURI().toString());
+      
+      server = new ServerImpl();
+      Properties props = new Properties();
+      // either target or eclipse-target
+      props.put(ServerConfig.HOME_DIR, mkdir("target/bootstrap"));
+      //props.put(ServerConfig.LIBRARY_URL, new File("target/dist/lib").toURI().toURL().toString());
+      props.put(ServerConfig.SERVER_CONFIG_URL, findDirURL("src/test/resources/conf").toString());
+      System.out.println(props);
+      server.init(props);
+      server.start();
+   }
+   
+   private static URL findDirURL(String path) throws IOException
+   {
+      return findDirURI(path).toURL();
+   }
+   
+   private static URI findDirURI(String path) throws IOException
+   {
+      File file = new File(path);
+      boolean success = file.isDirectory();
+      if(!success)
+         throw new IOException("failed to find " + path);
+      return file.toURI();
+   }
+   
+   private static String mkdir(String path) throws IOException
+   {
+      File file = new File(path);
+      boolean success = file.mkdirs() || file.isDirectory();
+      if(!success)
+         throw new IOException("failed to create " + path);
+      return file.getAbsolutePath();
+   }
+   
+   @Test
+   public void test1()
+   {
+      ResourceResolver resolver = (ResourceResolver) server.getKernel().getController().getInstalledContext("ResourceResolver").getTarget();
+      URL url = resolver.getResource("somefile.txt");
+      String spec = url.toString();
+      assertTrue(spec.endsWith("src/test/resources/path1/somefile.txt"));
+   }
+
+   @Test
+   public void test2()
+   {
+      ResourceResolver resolver = (ResourceResolver) server.getKernel().getController().getInstalledContext("ResourceResolver").getTarget();
+      URL url = resolver.getResource("someotherfile.txt");
+      String spec = url.toString();
+      assertTrue(spec.endsWith("src/test/resources/path2/someotherfile.txt"));
+   }
+}

Added: projects/reloaded/trunk/compoundclassloader/src/test/resources/conf/bootstrap/classloader.xml
===================================================================
--- projects/reloaded/trunk/compoundclassloader/src/test/resources/conf/bootstrap/classloader.xml	                        (rev 0)
+++ projects/reloaded/trunk/compoundclassloader/src/test/resources/conf/bootstrap/classloader.xml	2009-03-31 17:36:49 UTC (rev 86540)
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+   The core classloading system
+-->
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+   <classloader><inject bean="bootstrap-classloader:0.0.0"/></classloader>
+
+   <!--
+      The classloader implementation
+   -->
+   <bean name="ClassLoaderSystem" class="org.jboss.classloader.spi.ClassLoaderSystem">
+      <classloader><null/></classloader>
+      <constructor factoryClass="org.jboss.classloader.spi.ClassLoaderSystem" factoryMethod="getInstance"/>
+   </bean>
+
+   <!-- 
+      ClassLoader management and resolution
+   -->
+   <bean name="ClassLoading" class="org.jboss.classloading.spi.dependency.ClassLoading">
+      <classloader><null/></classloader>
+      <incallback method="addModule" state="Configured"/>
+      <uncallback method="removeModule" state="Configured"/>
+   </bean>
+
+   <classloader name="bootstrap-classloader" xmlns="urn:jboss:classloader:1.0" export-all="NON_EMPTY" import-all="true">
+      <!-- System -->
+      <!-- 
+      <root>${jboss.lib.url}jboss-system.jar</root>
+      -->
+   </classloader>
+   
+</deployment>

Added: projects/reloaded/trunk/compoundclassloader/src/test/resources/conf/bootstrap/jbossxb.xml
===================================================================
--- projects/reloaded/trunk/compoundclassloader/src/test/resources/conf/bootstrap/jbossxb.xml	                        (rev 0)
+++ projects/reloaded/trunk/compoundclassloader/src/test/resources/conf/bootstrap/jbossxb.xml	2009-03-31 17:36:49 UTC (rev 86540)
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+   <bean name="JBossXBSchemaService" class="org.jboss.reloaded.compoundclassloader.xb.spi.JaxbSchemaService"/>
+</deployment>

Added: projects/reloaded/trunk/compoundclassloader/src/test/resources/conf/bootstrap/testcompoundcl.xml
===================================================================
--- projects/reloaded/trunk/compoundclassloader/src/test/resources/conf/bootstrap/testcompoundcl.xml	                        (rev 0)
+++ projects/reloaded/trunk/compoundclassloader/src/test/resources/conf/bootstrap/testcompoundcl.xml	2009-03-31 17:36:49 UTC (rev 86540)
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+   <classloader><inject bean="testcompoundcl-classloader:0.0.0"/></classloader>
+   
+   <classloader name="testcompoundcl-classloader" xmlns="urn:jboss:compoundclassloader:1.0" export-all="NON_EMPTY" import-all="false">
+      <delegate>testcompoundcl1-classloader:0.0.0</delegate>
+      <delegate>testcompoundcl2-classloader:0.0.0</delegate>
+   </classloader>
+
+   <classloader name="testcompoundcl1-classloader" xmlns="urn:jboss:classloader:1.0" export-all="NON_EMPTY" import-all="false">
+      <root>${basedir}/src/test/resources/path1</root>
+   </classloader>
+
+   <classloader name="testcompoundcl2-classloader" xmlns="urn:jboss:classloader:1.0" export-all="NON_EMPTY" import-all="false">
+      <root>${basedir}/src/test/resources/path2</root>
+   </classloader>
+   
+   <bean name="ResourceResolver" class="org.jboss.reloaded.compoundclassloader.test.simple.ResourceResolver"/>
+</deployment>

Added: projects/reloaded/trunk/compoundclassloader/src/test/resources/conf/bootstrap.xml
===================================================================
--- projects/reloaded/trunk/compoundclassloader/src/test/resources/conf/bootstrap.xml	                        (rev 0)
+++ projects/reloaded/trunk/compoundclassloader/src/test/resources/conf/bootstrap.xml	2009-03-31 17:36:49 UTC (rev 86540)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+   The list of URLs for mc beans to load during bootstrap.
+-->
+<bootstrap xmlns="urn:jboss:bootstrap:1.0">
+   <url>bootstrap/jbossxb.xml</url>
+   <url>bootstrap/classloader.xml</url>
+   <url>bootstrap/testcompoundcl.xml</url>
+</bootstrap>
\ No newline at end of file

Added: projects/reloaded/trunk/compoundclassloader/src/test/resources/log4j.xml
===================================================================
--- projects/reloaded/trunk/compoundclassloader/src/test/resources/log4j.xml	                        (rev 0)
+++ projects/reloaded/trunk/compoundclassloader/src/test/resources/log4j.xml	2009-03-31 17:36:49 UTC (rev 86540)
@@ -0,0 +1,123 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+
+<!-- ===================================================================== -->
+<!--                                                                       -->
+<!--  Log4j Configuration                                                  -->
+<!--                                                                       -->
+<!-- ===================================================================== -->
+
+<!-- $Id: log4j.xml 68671 2008-01-08 10:04:25Z wolfc $ -->
+
+<!--
+   | For more configuration infromation and examples see the Jakarta Log4j
+   | owebsite: http://jakarta.apache.org/log4j
+ -->
+
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
+
+  <!-- ================================= -->
+  <!-- Preserve messages in a local file -->
+  <!-- ================================= -->
+
+  <!-- A time/date based rolling appender -->
+  <appender name="FILE" class="org.jboss.logging.appender.DailyRollingFileAppender">
+    <param name="File" value="target/test.log"/>
+    <param name="Append" value="false"/>
+
+    <!-- Rollover at midnight each day -->
+    <param name="DatePattern" value="'.'yyyy-MM-dd"/>
+
+    <!-- Rollover at the top of each hour
+    <param name="DatePattern" value="'.'yyyy-MM-dd-HH"/>
+    -->
+
+    <layout class="org.apache.log4j.PatternLayout">
+      <!-- The default pattern: Date Priority [Category] Message\n -->
+      <param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>
+
+      <!-- The full pattern: Date MS Priority [Category] (Thread:NDC) Message\n
+      <param name="ConversionPattern" value="%d %-5r %-5p [%c] (%t:%x) %m%n"/>
+       -->
+    </layout>	    
+  </appender>
+
+  <!-- A size based file rolling appender
+  <appender name="FILE" class="org.jboss.logging.appender.RollingFileAppender">
+    <param name="File" value="${jboss.server.home.dir}/log/server.log"/>
+    <param name="Append" value="false"/>
+    <param name="MaxFileSize" value="500KB"/>
+    <param name="MaxBackupIndex" value="1"/>
+
+    <layout class="org.apache.log4j.PatternLayout">
+      <param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>
+    </layout>	    
+  </appender>
+  -->
+
+  <!-- ============================== -->
+  <!-- Append messages to the console -->
+  <!-- ============================== -->
+
+  <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
+    <param name="Target" value="System.out"/>
+    <param name="Threshold" value="ALL"/>
+
+    <layout class="org.apache.log4j.PatternLayout">
+      <!-- The default pattern: Date Priority [Category] Message\n -->
+      <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}] %m%n"/>
+    </layout>
+  </appender>
+
+
+  <!-- ================ -->
+  <!-- Limit categories -->
+  <!-- ================ -->
+
+  <!-- Limit JBoss categories to INFO
+  <category name="org.jboss">
+    <priority value="INFO" class="org.jboss.logging.XLevel"/>
+  </category>
+  -->
+
+  <!-- Increase the priority threshold for the DefaultDS category
+  <category name="DefaultDS">
+    <priority value="FATAL"/>
+  </category>
+  -->
+
+  <!-- Decrease the priority threshold for the org.jboss.varia category
+  <category name="org.jboss.varia">
+    <priority value="DEBUG"/>
+  </category>
+  -->
+
+  <!--
+     | An example of enabling the custom TRACE level priority that is used
+     | by the JBoss internals to diagnose low level details. This example
+     | turns on TRACE level msgs for the org.jboss.ejb.plugins package and its
+     | subpackages. This will produce A LOT of logging output.
+  <category name="org.jboss.system">
+    <priority value="TRACE" class="org.jboss.logging.XLevel"/>
+  </category>
+  -->
+
+  <category name="org.jboss">
+    <priority value="INFO"/>
+  </category>
+  
+  <category name="org.jboss.reloaded">
+    <priority value="DEBUG"/>
+  </category>
+  
+  <!-- ======================= -->
+  <!-- Setup the Root category -->
+  <!-- ======================= -->
+
+  <root>
+    <priority value="WARN" />
+    <appender-ref ref="CONSOLE"/>
+    <appender-ref ref="FILE"/>
+  </root>
+  
+</log4j:configuration>

Added: projects/reloaded/trunk/compoundclassloader/src/test/resources/path1/somefile.txt
===================================================================
--- projects/reloaded/trunk/compoundclassloader/src/test/resources/path1/somefile.txt	                        (rev 0)
+++ projects/reloaded/trunk/compoundclassloader/src/test/resources/path1/somefile.txt	2009-03-31 17:36:49 UTC (rev 86540)
@@ -0,0 +1,2 @@
+path1
+Purposely named the same as in src/test/resources, but with different content.
\ No newline at end of file

Added: projects/reloaded/trunk/compoundclassloader/src/test/resources/path2/someotherfile.txt
===================================================================
--- projects/reloaded/trunk/compoundclassloader/src/test/resources/path2/someotherfile.txt	                        (rev 0)
+++ projects/reloaded/trunk/compoundclassloader/src/test/resources/path2/someotherfile.txt	2009-03-31 17:36:49 UTC (rev 86540)
@@ -0,0 +1 @@
+path2
\ No newline at end of file

Added: projects/reloaded/trunk/compoundclassloader/src/test/resources/somefile.txt
===================================================================
--- projects/reloaded/trunk/compoundclassloader/src/test/resources/somefile.txt	                        (rev 0)
+++ projects/reloaded/trunk/compoundclassloader/src/test/resources/somefile.txt	2009-03-31 17:36:49 UTC (rev 86540)
@@ -0,0 +1 @@
+Nothing to see (for ResourceResolver test)
\ No newline at end of file




More information about the jboss-cvs-commits mailing list