[jboss-cvs] JBossAS SVN: r86462 - in projects/reloaded/trunk: repoclassloader and 29 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Mar 30 04:26:42 EDT 2009
Author: wolfc
Date: 2009-03-30 04:26:42 -0400 (Mon, 30 Mar 2009)
New Revision: 86462
Added:
projects/reloaded/trunk/repoclassloader/
projects/reloaded/trunk/repoclassloader/.classpath
projects/reloaded/trunk/repoclassloader/.project
projects/reloaded/trunk/repoclassloader/.settings/
projects/reloaded/trunk/repoclassloader/.settings/org.eclipse.jdt.core.prefs
projects/reloaded/trunk/repoclassloader/.settings/org.maven.ide.eclipse.prefs
projects/reloaded/trunk/repoclassloader/pom.xml
projects/reloaded/trunk/repoclassloader/src/
projects/reloaded/trunk/repoclassloader/src/main/
projects/reloaded/trunk/repoclassloader/src/main/java/
projects/reloaded/trunk/repoclassloader/src/main/java/org/
projects/reloaded/trunk/repoclassloader/src/main/java/org/jboss/
projects/reloaded/trunk/repoclassloader/src/main/java/org/jboss/reloaded/
projects/reloaded/trunk/repoclassloader/src/main/java/org/jboss/reloaded/repoclassloader/
projects/reloaded/trunk/repoclassloader/src/main/java/org/jboss/reloaded/repoclassloader/RepoResolver.java
projects/reloaded/trunk/repoclassloader/src/main/java/org/jboss/reloaded/repoclassloader/ivy/
projects/reloaded/trunk/repoclassloader/src/main/java/org/jboss/reloaded/repoclassloader/ivy/IvyRepoResolver.java
projects/reloaded/trunk/repoclassloader/src/main/java/org/jboss/reloaded/repoclassloader/ivy/xb/
projects/reloaded/trunk/repoclassloader/src/main/java/org/jboss/reloaded/repoclassloader/ivy/xb/XBExcludeRule.java
projects/reloaded/trunk/repoclassloader/src/main/java/org/jboss/reloaded/repoclassloader/protocol/
projects/reloaded/trunk/repoclassloader/src/main/java/org/jboss/reloaded/repoclassloader/protocol/data/
projects/reloaded/trunk/repoclassloader/src/main/java/org/jboss/reloaded/repoclassloader/protocol/data/Handler.java
projects/reloaded/trunk/repoclassloader/src/main/java/org/jboss/reloaded/repoclassloader/schema/
projects/reloaded/trunk/repoclassloader/src/main/java/org/jboss/reloaded/repoclassloader/schema/RepoClassLoaderSchemaResolverFactory.java
projects/reloaded/trunk/repoclassloader/src/main/java/org/jboss/reloaded/repoclassloader/spi/
projects/reloaded/trunk/repoclassloader/src/main/java/org/jboss/reloaded/repoclassloader/spi/dependency/
projects/reloaded/trunk/repoclassloader/src/main/java/org/jboss/reloaded/repoclassloader/spi/dependency/RepoClassLoaderPolicyModule.java
projects/reloaded/trunk/repoclassloader/src/main/java/org/jboss/reloaded/repoclassloader/spi/metadata/
projects/reloaded/trunk/repoclassloader/src/main/java/org/jboss/reloaded/repoclassloader/spi/metadata/RepoClassLoaderFactory.java
projects/reloaded/trunk/repoclassloader/src/main/java/org/jboss/reloaded/repoclassloader/spi/metadata/RepoClassLoaderFactory10.java
projects/reloaded/trunk/repoclassloader/src/main/java/org/jboss/reloaded/repoclassloader/spi/metadata/package-info.java
projects/reloaded/trunk/repoclassloader/src/main/java/org/jboss/reloaded/repoclassloader/spi/policy/
projects/reloaded/trunk/repoclassloader/src/main/java/org/jboss/reloaded/repoclassloader/spi/policy/RepoClassLoaderPolicy.java
projects/reloaded/trunk/repoclassloader/src/main/resources/
projects/reloaded/trunk/repoclassloader/src/test/
projects/reloaded/trunk/repoclassloader/src/test/java/
projects/reloaded/trunk/repoclassloader/src/test/java/org/
projects/reloaded/trunk/repoclassloader/src/test/java/org/jboss/
projects/reloaded/trunk/repoclassloader/src/test/java/org/jboss/reloaded/
projects/reloaded/trunk/repoclassloader/src/test/java/org/jboss/reloaded/repoclassloader/
projects/reloaded/trunk/repoclassloader/src/test/java/org/jboss/reloaded/repoclassloader/test/
projects/reloaded/trunk/repoclassloader/src/test/java/org/jboss/reloaded/repoclassloader/test/simple/
projects/reloaded/trunk/repoclassloader/src/test/java/org/jboss/reloaded/repoclassloader/test/simple/unit/
projects/reloaded/trunk/repoclassloader/src/test/java/org/jboss/reloaded/repoclassloader/test/simple/unit/SimpleTestCase.java
projects/reloaded/trunk/repoclassloader/src/test/resources/
projects/reloaded/trunk/repoclassloader/src/test/resources/conf/
projects/reloaded/trunk/repoclassloader/src/test/resources/conf/bootstrap.xml
projects/reloaded/trunk/repoclassloader/src/test/resources/conf/bootstrap/
projects/reloaded/trunk/repoclassloader/src/test/resources/conf/bootstrap/aop.xml
projects/reloaded/trunk/repoclassloader/src/test/resources/conf/bootstrap/classloader.xml
projects/reloaded/trunk/repoclassloader/src/test/resources/conf/bootstrap/repo.xml
projects/reloaded/trunk/repoclassloader/src/test/resources/log4j.xml
Log:
JBAS-6700: a very rough prototype
Property changes on: projects/reloaded/trunk/repoclassloader
___________________________________________________________________
Name: svn:ignore
+ eclipse-target
target
Added: projects/reloaded/trunk/repoclassloader/.classpath
===================================================================
--- projects/reloaded/trunk/repoclassloader/.classpath (rev 0)
+++ projects/reloaded/trunk/repoclassloader/.classpath 2009-03-30 08:26:42 UTC (rev 86462)
@@ -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/repoclassloader/.project
===================================================================
--- projects/reloaded/trunk/repoclassloader/.project (rev 0)
+++ projects/reloaded/trunk/repoclassloader/.project 2009-03-30 08:26:42 UTC (rev 86462)
@@ -0,0 +1,18 @@
+<projectDescription>
+ <name>jboss-reloaded-repoclassloader</name>
+ <comment>This is a counterpart of VFS ClassLoader Factory which doesn't use
+ VFS as a backend, but a repository.</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/repoclassloader/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- projects/reloaded/trunk/repoclassloader/.settings/org.eclipse.jdt.core.prefs (rev 0)
+++ projects/reloaded/trunk/repoclassloader/.settings/org.eclipse.jdt.core.prefs 2009-03-30 08:26:42 UTC (rev 86462)
@@ -0,0 +1,5 @@
+#Fri Mar 27 11:14:43 CET 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/repoclassloader/.settings/org.maven.ide.eclipse.prefs
===================================================================
--- projects/reloaded/trunk/repoclassloader/.settings/org.maven.ide.eclipse.prefs (rev 0)
+++ projects/reloaded/trunk/repoclassloader/.settings/org.maven.ide.eclipse.prefs 2009-03-30 08:26:42 UTC (rev 86462)
@@ -0,0 +1,8 @@
+#Fri Mar 27 11:45:35 CET 2009
+activeProfiles=eclipse
+eclipse.preferences.version=1
+fullBuildGoals=
+includeModules=false
+resolveWorkspaceProjects=false
+resourceFilterGoals=
+version=1
Added: projects/reloaded/trunk/repoclassloader/pom.xml
===================================================================
--- projects/reloaded/trunk/repoclassloader/pom.xml (rev 0)
+++ projects/reloaded/trunk/repoclassloader/pom.xml 2009-03-30 08:26:42 UTC (rev 86462)
@@ -0,0 +1,93 @@
+<!--
+ 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</groupId>
+ <artifactId>jboss-parent</artifactId>
+ <version>4</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.jboss.reloaded</groupId>
+ <artifactId>jboss-reloaded-repoclassloader</artifactId>
+ <version>0.1.0-SNAPSHOT</version>
+ <packaging>jar</packaging>
+ <name>JBoss Reloaded Repository ClassLoader</name>
+ <url>http://www.jboss.org</url>
+ <description>
+ This is a counterpart of VFS ClassLoader Factory which doesn't use
+ VFS as a backend, but a repository.
+ </description>
+
+ <build>
+ <outputDirectory>${outputDirectory}</outputDirectory>
+ <testOutputDirectory>${testOutputDirectory}</testOutputDirectory>
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.4</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.ivy</groupId>
+ <artifactId>ivy</artifactId>
+ <version>2.0.0</version>
+ <scope>compile</scope>
+ </dependency>
+ <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.3.GA</version>
+ </dependency>
+ <!-- TODO: remove -->
+ <!--
+ <dependency>
+ <groupId>org.jboss.deployers</groupId>
+ <artifactId>jboss-deployers-vfs</artifactId>
+ <version>2.0.5.GA</version>
+ <scope>runtime</scope>
+ </dependency>
+ -->
+ <dependency>
+ <groupId>org.jboss.logging</groupId>
+ <artifactId>jboss-logging-log4j</artifactId>
+ <version>2.0.6.GA</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.man</groupId>
+ <artifactId>jboss-managed</artifactId>
+ <version>2.0.0.GA</version>
+ </dependency>
+ </dependencies>
+
+ <profiles>
+ <profile>
+ <id>default</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+ <properties>
+ <outputDirectory>target/classes</outputDirectory>
+ <testOutputDirectory>target/test-classes</testOutputDirectory>
+ </properties>
+ </profile>
+
+ <profile>
+ <id>eclipse</id>
+ <properties>
+ <outputDirectory>eclipse-target/classes</outputDirectory>
+ <testOutputDirectory>eclipse-target/test-classes</testOutputDirectory>
+ </properties>
+ </profile>
+ </profiles>
+</project>
Added: projects/reloaded/trunk/repoclassloader/src/main/java/org/jboss/reloaded/repoclassloader/RepoResolver.java
===================================================================
--- projects/reloaded/trunk/repoclassloader/src/main/java/org/jboss/reloaded/repoclassloader/RepoResolver.java (rev 0)
+++ projects/reloaded/trunk/repoclassloader/src/main/java/org/jboss/reloaded/repoclassloader/RepoResolver.java 2009-03-30 08:26:42 UTC (rev 86462)
@@ -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.repoclassloader;
+
+import java.net.URI;
+import java.util.List;
+
+import org.apache.ivy.core.module.descriptor.ExcludeRule;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public interface RepoResolver
+{
+ URI[] resolve(String name, List<String> artifacts, List<ExcludeRule> excludes);
+}
Added: projects/reloaded/trunk/repoclassloader/src/main/java/org/jboss/reloaded/repoclassloader/ivy/IvyRepoResolver.java
===================================================================
--- projects/reloaded/trunk/repoclassloader/src/main/java/org/jboss/reloaded/repoclassloader/ivy/IvyRepoResolver.java (rev 0)
+++ projects/reloaded/trunk/repoclassloader/src/main/java/org/jboss/reloaded/repoclassloader/ivy/IvyRepoResolver.java 2009-03-30 08:26:42 UTC (rev 86462)
@@ -0,0 +1,191 @@
+/*
+ * 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.repoclassloader.ivy;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URL;
+import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import org.apache.ivy.Ivy;
+import org.apache.ivy.core.module.descriptor.Configuration;
+import org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor;
+import org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor;
+import org.apache.ivy.core.module.descriptor.DependencyDescriptor;
+import org.apache.ivy.core.module.descriptor.ExcludeRule;
+import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
+import org.apache.ivy.core.module.id.ModuleRevisionId;
+import org.apache.ivy.core.report.ArtifactDownloadReport;
+import org.apache.ivy.core.report.ResolveReport;
+import org.apache.ivy.core.resolve.ResolveOptions;
+import org.apache.ivy.core.settings.IvySettings;
+import org.jboss.logging.Logger;
+import org.jboss.reloaded.repoclassloader.RepoResolver;
+import org.jboss.reloaded.repoclassloader.ivy.xb.XBExcludeRule;
+import org.jboss.reloaded.repoclassloader.protocol.data.Handler;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class IvyRepoResolver implements RepoResolver
+{
+ private static Logger log = Logger.getLogger(IvyRepoResolver.class);
+
+ private IvySettings settings;
+ private Ivy ivy;
+
+ /**
+ * @param organisation
+ * @param name
+ * @param revision
+ * @return
+ */
+ private DependencyDescriptor createDependencyDescriptor(ModuleDescriptor descriptor, String organisation, String name, String revision)
+ {
+ ModuleRevisionId mrid = ModuleRevisionId.newInstance(organisation, name, revision);
+ boolean force = false;
+ boolean changing = false;
+ // FIXME: oh brother
+ if(revision.endsWith("-SNAPSHOT"))
+ changing = true;
+ boolean transitive = true;
+ DefaultDependencyDescriptor dependency = new DefaultDependencyDescriptor(descriptor, mrid, force, changing, transitive);
+ dependency.addDependencyConfiguration("runtime", "runtime");
+ return dependency;
+ }
+
+ public URI[] resolve(String classLoaderName, List<String> artifacts, List<ExcludeRule> excludes)
+ {
+ // make sure we don't create another ivy instance somewhere
+ ivy.pushContext();
+ try
+ {
+ ModuleRevisionId id = ModuleRevisionId.newInstance("org.jboss.reloaded", classLoaderName, "working");
+ String status = ivy.getSettings().getStatusManager().getDefaultStatus();
+ Date pubDate = new Date();
+ DefaultModuleDescriptor descriptor = new DefaultModuleDescriptor(id, status, pubDate);
+ //descriptor.setLastModified(System.currentTimeMillis());
+
+ String confs[] = { "runtime" };
+ //boolean transitive = true;
+ //boolean changing = false;
+ //DefaultModuleDescriptor descriptor = DefaultModuleDescriptor.newCallerInstance(mrid, confs, transitive, changing);
+ for(int i = 0; i < confs.length; i++)
+ {
+ Configuration conf = new Configuration(confs[i]);
+ descriptor.addConfiguration(conf);
+ }
+
+ for(String artifact : artifacts)
+ {
+ StringTokenizer st = new StringTokenizer(artifact, ":");
+ if(st.countTokens() != 3)
+ throw new IllegalArgumentException("artifact must conform to <group>:<name>:<version>");
+ String organisation = st.nextToken();
+ String name = st.nextToken();
+ String revision = st.nextToken();
+
+ DependencyDescriptor dependency = createDependencyDescriptor(descriptor, organisation, name, revision);
+ descriptor.addDependency(dependency);
+ }
+
+ if(excludes != null)
+ {
+ for(ExcludeRule rule : excludes)
+ {
+ // FIXME: somewhere else so that the lifecyle of XBExcludeRule is better managed
+ if(rule instanceof XBExcludeRule)
+ ((XBExcludeRule) rule).setSettings(settings);
+ descriptor.addExcludeRule(rule);
+ }
+ }
+
+ ResolveOptions options = new ResolveOptions();
+ options.setConfs(confs);
+ //options.setUseCacheOnly(true);
+
+
+ ResolveReport report = ivy.resolve(descriptor, options);
+ if(report.hasError())
+ throw new IllegalArgumentException("Resolving artifacts failed");
+
+ List<URI> files = new ArrayList<URI>();
+ ArtifactDownloadReport artifactReports[] = report.getAllArtifactsReports();
+ for(ArtifactDownloadReport a : artifactReports)
+ {
+ File file = a.getLocalFile();
+ log.debug("found " + file);
+ files.add(file.toURI());
+ }
+ return files.toArray(new URI[0]);
+ }
+ catch(ParseException e)
+ {
+ throw new RuntimeException(e);
+ }
+ catch (IOException e)
+ {
+ throw new RuntimeException(e);
+ }
+ finally
+ {
+ ivy.popContext();
+ }
+ }
+
+ public void start()
+ {
+ if(settings == null)
+ throw new IllegalStateException("settings is null");
+ ivy = Ivy.newInstance(settings);
+ }
+
+ public void setSettings(String s)
+ {
+ try
+ {
+ URL url = Handler.createURL(s);
+ settings = new IvySettings();
+ settings.load(url);
+ settings.validate();
+ }
+ catch(MalformedURLException e)
+ {
+ throw new RuntimeException(e);
+ }
+ catch(IOException e)
+ {
+ throw new RuntimeException(e);
+ }
+ catch(ParseException e)
+ {
+ throw new IllegalArgumentException(e);
+ }
+ }
+}
Added: projects/reloaded/trunk/repoclassloader/src/main/java/org/jboss/reloaded/repoclassloader/ivy/xb/XBExcludeRule.java
===================================================================
--- projects/reloaded/trunk/repoclassloader/src/main/java/org/jboss/reloaded/repoclassloader/ivy/xb/XBExcludeRule.java (rev 0)
+++ projects/reloaded/trunk/repoclassloader/src/main/java/org/jboss/reloaded/repoclassloader/ivy/xb/XBExcludeRule.java 2009-03-30 08:26:42 UTC (rev 86462)
@@ -0,0 +1,161 @@
+/*
+ * 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.repoclassloader.ivy.xb;
+
+import java.util.Map;
+
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlTransient;
+
+import org.apache.ivy.core.module.descriptor.ExcludeRule;
+import org.apache.ivy.core.module.id.ArtifactId;
+import org.apache.ivy.core.module.id.ModuleId;
+import org.apache.ivy.core.settings.IvySettings;
+import org.apache.ivy.plugins.matcher.PatternMatcher;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class XBExcludeRule implements ExcludeRule
+{
+ private transient IvySettings settings;
+
+ private String org;
+ private String module;
+ private String ext;
+ private String type;
+
+ public String getAttribute(String attName)
+ {
+ // TODO Auto-generated method stub
+ //return null;
+ throw new RuntimeException("NYI");
+ }
+
+ public Map<?, ?> getAttributes()
+ {
+ // TODO Auto-generated method stub
+ //return null;
+ throw new RuntimeException("NYI");
+ }
+
+ public String[] getConfigurations()
+ {
+ // FIXME: should be ANY_EXPRESSION and ultimately configurable
+ return new String[] { "runtime" };
+ }
+
+ private PatternMatcher getDefaultMatcher()
+ {
+ return settings.getMatcher(PatternMatcher.EXACT);
+ }
+
+ public String getExtraAttribute(String attName)
+ {
+ // TODO Auto-generated method stub
+ //return null;
+ throw new RuntimeException("NYI");
+ }
+
+ public Map<?, ?> getExtraAttributes()
+ {
+ // TODO Auto-generated method stub
+ //return null;
+ throw new RuntimeException("NYI");
+ }
+
+ public ArtifactId getId()
+ {
+ String name = PatternMatcher.ANY_EXPRESSION;
+// String name = substitute(this.name);
+// if (name == null) {
+// name = substitute(this.artifact);
+// if (name == null) {
+// name = "artifact".equals(tag) ? dd.getDependencyId().getName()
+// : PatternMatcher.ANY_EXPRESSION;
+// }
+// }
+ String type = substitute(this.type);
+ if (type == null) {
+// type = "artifact".equals(tag) ? "jar" : PatternMatcher.ANY_EXPRESSION;
+ type = PatternMatcher.ANY_EXPRESSION;
+ }
+ String ext = substitute(this.ext);
+ ext = ext != null ? ext : type;
+
+ String org = substitute(this.org);
+ org = org == null ? PatternMatcher.ANY_EXPRESSION : org;
+ String module = substitute(this.module);
+ module = module == null ? PatternMatcher.ANY_EXPRESSION : module;
+ ArtifactId aid = new ArtifactId(new ModuleId(org, module), name, type, ext);
+ return aid;
+ }
+
+ public PatternMatcher getMatcher()
+ {
+ String s = null;
+ String matcherName = settings.substitute(s);
+ PatternMatcher matcher = matcherName == null ? getDefaultMatcher() : settings.getMatcher(matcherName);
+ if (matcher == null) {
+ throw new IllegalArgumentException("unknown matcher " + matcherName);
+ }
+ return matcher;
+ }
+
+ public Map<?, ?> getQualifiedExtraAttributes()
+ {
+ // TODO Auto-generated method stub
+ //return null;
+ throw new RuntimeException("NYI");
+ }
+
+ @XmlAttribute
+ public void setExt(String ext)
+ {
+ this.ext = ext;
+ }
+
+ @XmlAttribute
+ public void setModule(String module)
+ {
+ this.module = module;
+ }
+
+ @XmlAttribute
+ public void setOrg(String org)
+ {
+ this.org = org;
+ }
+
+ @XmlTransient
+ public void setSettings(IvySettings settings)
+ {
+ this.settings = settings;
+ }
+
+ private String substitute(String s)
+ {
+ return settings.substitute(s);
+ //return s;
+ }
+}
Added: projects/reloaded/trunk/repoclassloader/src/main/java/org/jboss/reloaded/repoclassloader/protocol/data/Handler.java
===================================================================
--- projects/reloaded/trunk/repoclassloader/src/main/java/org/jboss/reloaded/repoclassloader/protocol/data/Handler.java (rev 0)
+++ projects/reloaded/trunk/repoclassloader/src/main/java/org/jboss/reloaded/repoclassloader/protocol/data/Handler.java 2009-03-30 08:26:42 UTC (rev 86462)
@@ -0,0 +1,90 @@
+/*
+ * 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.repoclassloader.protocol.data;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLConnection;
+import java.net.URLDecoder;
+import java.net.URLEncoder;
+import java.net.URLStreamHandler;
+
+/**
+ * RFC 2397
+ *
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class Handler extends URLStreamHandler
+{
+ static
+ {
+ String pkgs = System.getProperty("java.protocol.handler.pkgs", "");
+ if(pkgs.length() > 0)
+ pkgs += "|";
+ String pkgname = Handler.class.getPackage().getName();
+ pkgs += pkgname.substring(0, pkgname.length() - ".data".length());
+ System.setProperty("java.protocol.handler.pkgs", pkgs);
+ }
+
+ public static URL createURL(String data) throws MalformedURLException
+ {
+ try
+ {
+ return new URL("data:," + URLEncoder.encode(data, "UTF-8"));
+ }
+ catch(UnsupportedEncodingException e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ @Override
+ protected URLConnection openConnection(URL u) throws IOException
+ {
+ // TODO: all the parsing stuff
+ String s = u.toString();
+
+ int i = s.indexOf(',');
+ if(i == -1)
+ throw new IOException("url has no data (missing ,) " + s);
+ String encoded = s.substring(i + 1);
+ // TODO: correct encoding
+ final String data = URLDecoder.decode(encoded, "UTF-8");
+ return new URLConnection(u) {
+ @Override
+ public void connect() throws IOException
+ {
+ }
+
+ @Override
+ public InputStream getInputStream() throws IOException
+ {
+ return new ByteArrayInputStream(data.getBytes());
+ }
+ };
+ }
+}
Added: projects/reloaded/trunk/repoclassloader/src/main/java/org/jboss/reloaded/repoclassloader/schema/RepoClassLoaderSchemaResolverFactory.java
===================================================================
--- projects/reloaded/trunk/repoclassloader/src/main/java/org/jboss/reloaded/repoclassloader/schema/RepoClassLoaderSchemaResolverFactory.java (rev 0)
+++ projects/reloaded/trunk/repoclassloader/src/main/java/org/jboss/reloaded/repoclassloader/schema/RepoClassLoaderSchemaResolverFactory.java 2009-03-30 08:26:42 UTC (rev 86462)
@@ -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.repoclassloader.schema;
+
+import org.jboss.reloaded.repoclassloader.spi.metadata.RepoClassLoaderFactory10;
+import org.jboss.xb.binding.sunday.unmarshalling.SingletonSchemaResolverFactory;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class RepoClassLoaderSchemaResolverFactory
+{
+ public void start()
+ {
+ SingletonSchemaResolverFactory.getInstance().addJaxbSchema("urn:jboss:repoclassloader:1.0", RepoClassLoaderFactory10.class.getName());
+ }
+
+ public void stop()
+ {
+ // TODO: can't remove
+ //SingletonSchemaResolverFactory.getInstance().removeJaxbSchema("urn:jboss:repoclassloader:1.0");
+ }
+}
Added: projects/reloaded/trunk/repoclassloader/src/main/java/org/jboss/reloaded/repoclassloader/spi/dependency/RepoClassLoaderPolicyModule.java
===================================================================
--- projects/reloaded/trunk/repoclassloader/src/main/java/org/jboss/reloaded/repoclassloader/spi/dependency/RepoClassLoaderPolicyModule.java (rev 0)
+++ projects/reloaded/trunk/repoclassloader/src/main/java/org/jboss/reloaded/repoclassloader/spi/dependency/RepoClassLoaderPolicyModule.java 2009-03-30 08:26:42 UTC (rev 86462)
@@ -0,0 +1,264 @@
+/*
+ * 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.repoclassloader.spi.dependency;
+
+import java.net.URI;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+import org.apache.ivy.core.module.descriptor.ExcludeRule;
+import org.jboss.beans.metadata.api.annotations.Inject;
+import org.jboss.classloader.spi.filter.ClassFilter;
+import org.jboss.classloading.plugins.vfs.PackageVisitor;
+import org.jboss.classloading.plugins.vfs.VFSResourceVisitor;
+import org.jboss.classloading.spi.dependency.policy.ClassLoaderPolicyModule;
+import org.jboss.classloading.spi.metadata.Capability;
+import org.jboss.classloading.spi.metadata.ClassLoadingMetaDataFactory;
+import org.jboss.classloading.spi.metadata.ExportAll;
+import org.jboss.classloading.spi.visitor.ResourceFilter;
+import org.jboss.classloading.spi.visitor.ResourceVisitor;
+import org.jboss.kernel.spi.dependency.KernelControllerContext;
+import org.jboss.reloaded.repoclassloader.RepoResolver;
+import org.jboss.reloaded.repoclassloader.spi.metadata.RepoClassLoaderFactory;
+import org.jboss.reloaded.repoclassloader.spi.policy.RepoClassLoaderPolicy;
+import org.jboss.virtual.VFS;
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class RepoClassLoaderPolicyModule extends ClassLoaderPolicyModule
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 1L;
+
+ /** The artifacts */
+ private List<String> artifacts;
+
+ private List<ExcludeRule> excludes;
+
+ /** Our cached vfs roots */
+ private VirtualFile[] vfsRoots;
+
+ private RepoResolver resolver;
+
+ /**
+ * Create a new VFSClassLoaderPolicyModule.
+ *
+ * @param classLoadingMetaData the classloading metadata
+ * @param contextName the context name
+ */
+ public RepoClassLoaderPolicyModule(RepoClassLoaderFactory classLoadingMetaData, String contextName)
+ {
+ super(classLoadingMetaData, contextName);
+ }
+
+ /**
+ * Get the artifacts.
+ *
+ * @return the artifacts.
+ */
+ public List<String> getArtifacts()
+ {
+ return artifacts;
+ }
+
+ /**
+ * Set the artifacts.
+ *
+ * @param artifacts the artifacts.
+ */
+ public void setArtifacts(List<String> artifacts)
+ {
+ this.artifacts = artifacts;
+ }
+
+ public void setExcludes(List<ExcludeRule> excludes)
+ {
+ this.excludes = excludes;
+ }
+
+ @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 RepoClassLoaderFactory getClassLoadingMetaData()
+ {
+ return (RepoClassLoaderFactory) super.getClassLoadingMetaData();
+ }
+
+ /**
+ * Get the virtual file roots
+ *
+ * @return the roots
+ */
+ protected VirtualFile[] determineVFSRoots()
+ {
+ if (vfsRoots != null)
+ return vfsRoots;
+
+ if (artifacts == null)
+ {
+ vfsRoots = new VirtualFile[0];
+ }
+ else
+ {
+ List<VirtualFile> vfsRoots = new ArrayList<VirtualFile>();
+ URI uris[] = resolver.resolve(getName(), artifacts, excludes);
+ for(URI uri : uris)
+ {
+ try
+ {
+ vfsRoots.add(getVirtualFile(uri));
+ }
+ catch (RuntimeException e)
+ {
+ throw e;
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException("Error creating VFS file for " + uri, e);
+ }
+ }
+ this.vfsRoots = vfsRoots.toArray(new VirtualFile[0]);
+ }
+ return vfsRoots;
+ }
+
+ /**
+ * Get virtual file for uri.
+ *
+ * @param uri the uri
+ * @return virtual file for uri
+ * @throws Exception for any error
+ */
+ protected VirtualFile getVirtualFile(URI uri) throws Exception
+ {
+ if (isCacheable())
+ return VFS.getRoot(uri);
+ else
+ return VFS.createNewRoot(uri);
+ }
+
+ @Override
+ public RepoClassLoaderPolicy getPolicy()
+ {
+ return (RepoClassLoaderPolicy) super.getPolicy();
+ }
+
+ @Override
+ protected RepoClassLoaderPolicy determinePolicy()
+ {
+
+ VirtualFile[] roots = determineVFSRoots();
+ RepoClassLoaderPolicy policy = RepoClassLoaderPolicy.createRepoClassLoaderPolicy(getContextName(), roots);
+
+ 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();
+ vfsRoots = null;
+ }
+
+ @Inject
+ public void setRepoResolver(RepoResolver resolver)
+ {
+ this.resolver = resolver;
+ }
+
+ @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);
+ }
+ }
+}
Added: projects/reloaded/trunk/repoclassloader/src/main/java/org/jboss/reloaded/repoclassloader/spi/metadata/RepoClassLoaderFactory.java
===================================================================
--- projects/reloaded/trunk/repoclassloader/src/main/java/org/jboss/reloaded/repoclassloader/spi/metadata/RepoClassLoaderFactory.java (rev 0)
+++ projects/reloaded/trunk/repoclassloader/src/main/java/org/jboss/reloaded/repoclassloader/spi/metadata/RepoClassLoaderFactory.java 2009-03-30 08:26:42 UTC (rev 86462)
@@ -0,0 +1,203 @@
+/*
+ * 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.repoclassloader.spi.metadata;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlTransient;
+
+import org.apache.ivy.core.module.descriptor.ExcludeRule;
+import org.jboss.beans.metadata.spi.BeanMetaData;
+import org.jboss.beans.metadata.spi.BeanMetaDataFactory;
+import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
+import org.jboss.classloader.spi.ClassLoaderSystem;
+import org.jboss.classloading.spi.metadata.ClassLoadingMetaData;
+import org.jboss.classloading.spi.version.Version;
+import org.jboss.managed.api.annotation.ManagementProperty;
+import org.jboss.reloaded.repoclassloader.ivy.xb.XBExcludeRule;
+import org.jboss.reloaded.repoclassloader.spi.dependency.RepoClassLoaderPolicyModule;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class RepoClassLoaderFactory 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;
+
+ /** The artifacts in the form of <i>group</i>:<i>name</i>:<i>version</i> */
+ private List<String> artifacts = new CopyOnWriteArrayList<String>();
+
+ private List<ExcludeRule> excludes;
+
+ public RepoClassLoaderFactory()
+ {
+ }
+
+ public RepoClassLoaderFactory(String name)
+ {
+ this(name, Version.DEFAULT_VERSION);
+ }
+
+ public RepoClassLoaderFactory(String name, String version)
+ {
+ this(name, Version.parseVersion(version));
+ }
+
+ public RepoClassLoaderFactory(String name, Version version)
+ {
+ setName(name);
+ setVersion(version);
+ }
+
+ /**
+ * Get the classLoaderSystemName.
+ *
+ * @return the classLoaderSystemName.
+ */
+ public String getClassLoaderSystemName()
+ {
+ return classLoaderSystemName;
+ }
+
+ /**
+ * 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;
+ }
+
+ /**
+ * Get the contextName.
+ *
+ * @return the contextName.
+ */
+ public String getContextName()
+ {
+ return contextName;
+ }
+
+ /**
+ * Set the contextName.
+ *
+ * @param contextName the contextName.
+ */
+ @ManagementProperty(name="context")
+ @XmlAttribute(name="context")
+ public void setContextName(String contextName)
+ {
+ this.contextName = contextName;
+ }
+
+ /**
+ * Get the artifacts.
+ *
+ * @return the artifacts.
+ */
+ public List<String> getArtifacts()
+ {
+ return artifacts;
+ }
+
+ /**
+ * Set the artifacts.
+ *
+ * @param artifacts the artifacts.
+ */
+ @ManagementProperty(name="artifacts")
+ @XmlElement(name="artifact")
+ public void setArtifacts(List<String> artifacts)
+ {
+ if (artifacts == null)
+ artifacts = new CopyOnWriteArrayList<String>();
+ this.artifacts = artifacts;
+ }
+
+ /**
+ * Get module class.
+ *
+ * @return the module class.
+ */
+ protected Class<? extends RepoClassLoaderPolicyModule> getModuleClass()
+ {
+ return RepoClassLoaderPolicyModule.class;
+ }
+
+ @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(RepoClassLoaderFactory.class.getName(), this);
+ builder.addConstructorParameter(String.class.getName(), moduleName);
+ builder.addPropertyMetaData("artifacts", artifacts);
+ builder.addPropertyMetaData("excludes", excludes);
+ 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(classLoaderSystemName));
+ BeanMetaData classLoader = builder.getBeanMetaData();
+
+ return Arrays.asList(classLoader, module);
+ }
+
+ @ManagementProperty(name="excludes")
+ @XmlElement(name="exclude",type=XBExcludeRule.class)
+ public void setExcludes(List<ExcludeRule> excludes)
+ {
+ if (excludes == null)
+ excludes = new CopyOnWriteArrayList<ExcludeRule>();
+ this.excludes = excludes;
+ }
+}
Added: projects/reloaded/trunk/repoclassloader/src/main/java/org/jboss/reloaded/repoclassloader/spi/metadata/RepoClassLoaderFactory10.java
===================================================================
--- projects/reloaded/trunk/repoclassloader/src/main/java/org/jboss/reloaded/repoclassloader/spi/metadata/RepoClassLoaderFactory10.java (rev 0)
+++ projects/reloaded/trunk/repoclassloader/src/main/java/org/jboss/reloaded/repoclassloader/spi/metadata/RepoClassLoaderFactory10.java 2009-03-30 08:26:42 UTC (rev 86462)
@@ -0,0 +1,38 @@
+/*
+ * 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.repoclassloader.spi.metadata;
+
+import javax.xml.bind.annotation.XmlNsForm;
+import javax.xml.bind.annotation.XmlRootElement;
+
+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:repoclassloader:1.0", elementFormDefault=XmlNsForm.QUALIFIED)
+ at XmlRootElement(name="classloader")
+public class RepoClassLoaderFactory10 extends RepoClassLoaderFactory
+{
+ private static final long serialVersionUID = 1L;
+}
Added: projects/reloaded/trunk/repoclassloader/src/main/java/org/jboss/reloaded/repoclassloader/spi/metadata/package-info.java
===================================================================
--- projects/reloaded/trunk/repoclassloader/src/main/java/org/jboss/reloaded/repoclassloader/spi/metadata/package-info.java (rev 0)
+++ projects/reloaded/trunk/repoclassloader/src/main/java/org/jboss/reloaded/repoclassloader/spi/metadata/package-info.java 2009-03-30 08:26:42 UTC (rev 86462)
@@ -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.repoclassloader.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/repoclassloader/src/main/java/org/jboss/reloaded/repoclassloader/spi/policy/RepoClassLoaderPolicy.java
===================================================================
--- projects/reloaded/trunk/repoclassloader/src/main/java/org/jboss/reloaded/repoclassloader/spi/policy/RepoClassLoaderPolicy.java (rev 0)
+++ projects/reloaded/trunk/repoclassloader/src/main/java/org/jboss/reloaded/repoclassloader/spi/policy/RepoClassLoaderPolicy.java 2009-03-30 08:26:42 UTC (rev 86462)
@@ -0,0 +1,723 @@
+/*
+ * 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.repoclassloader.spi.policy;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.security.CodeSource;
+import java.security.PermissionCollection;
+import java.security.Policy;
+import java.security.ProtectionDomain;
+import java.security.cert.Certificate;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.jar.Manifest;
+
+import org.jboss.classloader.plugins.ClassLoaderUtils;
+import org.jboss.classloader.spi.ClassLoaderPolicy;
+import org.jboss.classloader.spi.DelegateLoader;
+import org.jboss.classloader.spi.PackageInformation;
+import org.jboss.classloader.spi.filter.ClassFilter;
+import org.jboss.classloader.spi.filter.FilteredDelegateLoader;
+import org.jboss.classloading.plugins.vfs.PackageVisitor;
+import org.jboss.classloading.spi.metadata.ExportAll;
+import org.jboss.logging.Logger;
+import org.jboss.util.collection.SoftValueHashMap;
+import org.jboss.virtual.VFSUtils;
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class RepoClassLoaderPolicy extends ClassLoaderPolicy
+{
+ /** The log */
+ private static Logger log = Logger.getLogger(RepoClassLoaderPolicy.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;
+
+ /** The roots */
+ private VirtualFile[] roots;
+
+ /** The excluded roots */
+ private VirtualFile[] excludedRoots;
+
+ /** 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>();
+
+ /** Cache of virtual file information by path */
+ @SuppressWarnings("unchecked")
+ private Map<String, VirtualFileInfo> vfsCache = Collections.synchronizedMap(new SoftValueHashMap());
+
+ /** JBCL-64, JBVFS-77: CodeSource should use real url **/
+ private boolean useRealURL = true;
+
+ /**
+ * Determine a name from the roots
+ *
+ * @param roots the roots
+ * @return the name
+ */
+ private static String determineName(VirtualFile[] roots)
+ {
+ if (roots == null)
+ return "";
+
+ try
+ {
+ for (VirtualFile root : roots)
+ return root.toURL().toString();
+ }
+ catch (Exception ignored)
+ {
+ }
+ return "";
+ }
+
+ /**
+ * Create a new RepoClassLoaderPolicy.
+ *
+ * @param roots the roots
+ * @return the classloader policy
+ * @throws IllegalArgumentException for null roots
+ */
+ public static RepoClassLoaderPolicy createRepoClassLoaderPolicy(VirtualFile... roots)
+ {
+ return new RepoClassLoaderPolicy(roots);
+ }
+
+ /**
+ * Create a new RepoClassLoaderPolicy.
+ *
+ * @param name a name of the policy
+ * @param roots the roots
+ * @return the classloader policy
+ * @throws IllegalArgumentException for null roots
+ */
+ public static RepoClassLoaderPolicy createRepoClassLoaderPolicy(String name, VirtualFile... roots)
+ {
+ return new RepoClassLoaderPolicy(name, roots);
+ }
+
+ /**
+ * Create a new RepoClassLoaderPolicy.
+ *
+ * @param roots the roots
+ * @param excludedRoots the excluded roots
+ * @return the classloader policy
+ * @throws IllegalArgumentException for null roots
+ */
+ public static RepoClassLoaderPolicy createRepoClassLoaderPolicy(VirtualFile[] roots, VirtualFile[] excludedRoots)
+ {
+ return new RepoClassLoaderPolicy(roots, excludedRoots);
+ }
+
+ /**
+ * Create a new RepoClassLoaderPolicy.
+ *
+ * @param name a name of the policy
+ * @param roots the roots
+ * @param excludedRoots the excluded roots
+ * @return the classloader policy
+ * @throws IllegalArgumentException for null roots
+ */
+ public static RepoClassLoaderPolicy createRepoClassLoaderPolicy(String name, VirtualFile[] roots, VirtualFile[] excludedRoots)
+ {
+ return new RepoClassLoaderPolicy(name, roots, excludedRoots);
+ }
+
+
+ /**
+ * Create a new RepoClassLoaderPolicy.
+ *
+ * @param roots the roots
+ * @throws IllegalArgumentException for null roots
+ */
+ public RepoClassLoaderPolicy(VirtualFile[] roots)
+ {
+ this(determineName(roots), roots);
+ }
+
+ /**
+ * Create a new RepoClassLoaderPolicy.
+ *
+ * @param roots the roots
+ * @param excludedRoots the excluded roots
+ * @throws IllegalArgumentException for null roots
+ */
+ public RepoClassLoaderPolicy(VirtualFile[] roots, VirtualFile[] excludedRoots)
+ {
+ this(determineName(roots), roots, excludedRoots);
+ }
+
+ /**
+ * Create a new RepoClassLoaderPolicy.
+ *
+ * @param name the name
+ * @param roots the roots
+ * @throws IllegalArgumentException for null roots
+ */
+ public RepoClassLoaderPolicy(String name, VirtualFile[] roots)
+ {
+ this(name, roots, null);
+ }
+
+ /**
+ * Create a new RepoClassLoaderPolicy.
+ *
+ * @param name the name
+ * @param roots the roots
+ * @param excludedRoots the excluded roots
+ * @throws IllegalArgumentException for null roots
+ */
+ public RepoClassLoaderPolicy(String name, VirtualFile[] roots, VirtualFile[] excludedRoots)
+ {
+ if (name == null)
+ throw new IllegalArgumentException("Null name");
+ if (roots == null)
+ throw new IllegalArgumentException("Null roots");
+ for (VirtualFile root : roots)
+ {
+ if (root == null)
+ throw new IllegalArgumentException("Null root in " + Arrays.asList(roots));
+ }
+ if (excludedRoots != null)
+ {
+ for (VirtualFile excludedRoot : excludedRoots)
+ {
+ if (excludedRoot == null)
+ throw new IllegalArgumentException("Null excluded root in " + Arrays.asList(excludedRoots));
+ }
+ }
+
+ this.name = name;
+ this.roots = roots;
+ this.excludedRoots = excludedRoots;
+ }
+
+ @Override
+ public String getName()
+ {
+ return 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)
+ {
+ Set<String> exported = PackageVisitor.determineAllPackages(roots, excludedRoots, exportAll, included, excluded, excludedExport);
+ exportedPackages = exported.toArray(new String[exported.size()]);
+ }
+ }
+ }
+
+ /**
+ * 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[] 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();
+ }
+
+ @Override
+ public URL getResource(String path)
+ {
+ if (checkFilters(path, "getResource"))
+ return null;
+
+ VirtualFile child = findChild(path);
+ if (child != null)
+ {
+ try
+ {
+ return child.toURL();
+ }
+ catch (Exception ignored)
+ {
+ log.debug("Error determining URL for " + child, ignored);
+ return null;
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public InputStream getResourceAsStream(String path)
+ {
+ if (checkFilters(path, "getResourceAsStream"))
+ return null;
+
+ VirtualFile child = findChild(path);
+ if (child != null)
+ {
+ try
+ {
+ return child.openStream();
+ }
+ catch (Exception ignored)
+ {
+ log.debug("Error opening stream for " + child, ignored);
+ return null;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * 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
+ public void getResources(String name, Set<URL> urls) throws IOException
+ {
+ if (checkFilters(name, "getResources"))
+ return;
+
+ for (VirtualFile root : roots)
+ {
+ try
+ {
+ VirtualFile child = root.getChild(name);
+ if (child != null)
+ urls.add(child.toURL());
+ }
+ catch (Exception e)
+ {
+ log.debug("Error getting resources for " + root, e);
+ }
+ }
+ }
+
+ /**
+ * Find a child from a path
+ *
+ * @param path the path
+ * @return the child if found in the roots
+ */
+ protected VirtualFile findChild(String path)
+ {
+ VirtualFileInfo vfi = findVirtualFileInfo(path);
+ if (vfi == null)
+ return null;
+ return vfi.getFile();
+ }
+
+ /**
+ * Find a root from a path
+ *
+ * @param path the path
+ * @return the root if found in the roots
+ */
+ protected VirtualFile findRoot(String path)
+ {
+ VirtualFileInfo vfi = findVirtualFileInfo(path);
+ if (vfi == null)
+ return null;
+ return vfi.getRoot();
+ }
+
+ /**
+ * Find the virtual file information for a path
+ *
+ * @param path the path
+ * @return the virtual file information
+ */
+ protected VirtualFileInfo findVirtualFileInfo(String path)
+ {
+ VirtualFileInfo result = vfsCache.get(path);
+ if (result != null)
+ return result;
+
+ for (VirtualFile root : roots)
+ {
+ try
+ {
+ VirtualFile file = root.getChild(path);
+ if (file != null)
+ {
+ result = new VirtualFileInfo(file, root);
+ vfsCache.put(path, result);
+ return result;
+ }
+ }
+ catch (Exception ignored)
+ {
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public PackageInformation getClassPackageInformation(String className, String packageName)
+ {
+ String path = ClassLoaderUtils.classNameToPath(className);
+ VirtualFile root = findRoot(path);
+ Manifest manifest = null;
+ URL rootURL = null;
+ if (root != null)
+ {
+ try
+ {
+ rootURL = root.toURL();
+ manifest = manifestCache.get(rootURL);
+ if (manifest == null)
+ {
+ manifest = VFSUtils.getManifest(root);
+ if (manifest == null)
+ manifestCache.put(rootURL, NO_MANIFEST);
+ else
+ manifestCache.put(rootURL, manifest);
+ }
+
+ if (manifest == NO_MANIFEST)
+ manifest = null;
+ }
+ catch (Exception ignored)
+ {
+ if (log.isTraceEnabled())
+ log.trace("Unable to retrieve manifest for " + path + " url=" + rootURL + " error=" + ignored.getMessage());
+ }
+ }
+ return new PackageInformation(packageName, manifest);
+ }
+
+ @Override
+ protected void toLongString(StringBuilder builder)
+ {
+ builder.append(" roots=").append(Arrays.asList(roots)).append(" ");
+ super.toLongString(builder);
+ if (exportAll != null)
+ builder.append(exportAll);
+ }
+
+ @Override
+ protected ProtectionDomain getProtectionDomain(String className, String path)
+ {
+ VirtualFile clazz = findChild(path);
+ if (clazz == null)
+ {
+ if (log.isTraceEnabled())
+ log.trace("Unable to determine class file for " + className);
+
+ return null;
+ }
+ try
+ {
+ VirtualFile root = findRoot(path);
+ URL codeSourceURL = isUseRealURL() ? VFSUtils.getRealURL(root) : root.toURL();
+
+ if (log.isTraceEnabled())
+ log.trace("getProtectionDomain:className="+ className + " path="+ path + " codeSourceURL=" + codeSourceURL);
+
+ Certificate[] certs = null; // TODO JBCL-67 determine certificates
+ CodeSource cs = new CodeSource(codeSourceURL, certs);
+ PermissionCollection permissions = Policy.getPolicy().getPermissions(cs);
+ return new ProtectionDomain(cs, permissions);
+ }
+ catch (Exception e)
+ {
+ throw new Error("Error determining protection domain for " + clazz, e);
+ }
+ }
+
+ /**
+ * 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;
+ }
+
+ /**
+ * VirtualFileInfo. */
+ private static class VirtualFileInfo
+ {
+ /** The file */
+ private VirtualFile file;
+
+ /** The root */
+ private VirtualFile root;
+
+ public VirtualFileInfo(VirtualFile file, VirtualFile root)
+ {
+ this.file = file;
+ this.root = root;
+ }
+
+ /**
+ * Get the file.
+ *
+ * @return the file.
+ */
+ public VirtualFile getFile()
+ {
+ return file;
+ }
+
+ /**
+ * Get the root.
+ *
+ * @return the root.
+ */
+ public VirtualFile getRoot()
+ {
+ return root;
+ }
+ }
+}
Added: projects/reloaded/trunk/repoclassloader/src/test/java/org/jboss/reloaded/repoclassloader/test/simple/unit/SimpleTestCase.java
===================================================================
--- projects/reloaded/trunk/repoclassloader/src/test/java/org/jboss/reloaded/repoclassloader/test/simple/unit/SimpleTestCase.java (rev 0)
+++ projects/reloaded/trunk/repoclassloader/src/test/java/org/jboss/reloaded/repoclassloader/test/simple/unit/SimpleTestCase.java 2009-03-30 08:26:42 UTC (rev 86462)
@@ -0,0 +1,94 @@
+/*
+ * 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.repoclassloader.test.simple.unit;
+
+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.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 SimpleTestCase
+{
+ private static MCServer server;
+
+ @AfterClass
+ public static void afterClass()
+ {
+ if(server != null && server.isStarted())
+ server.shutdown();
+ }
+
+ @BeforeClass
+ public static void beforeClass() throws Exception
+ {
+ 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()
+ {
+
+ }
+}
Copied: projects/reloaded/trunk/repoclassloader/src/test/resources/conf/bootstrap/aop.xml (from rev 86365, projects/reloaded/trunk/vdf-bootstrap/src/main/resources/server/default/conf/bootstrap/aop.xml)
===================================================================
--- projects/reloaded/trunk/repoclassloader/src/test/resources/conf/bootstrap/aop.xml (rev 0)
+++ projects/reloaded/trunk/repoclassloader/src/test/resources/conf/bootstrap/aop.xml 2009-03-30 08:26:42 UTC (rev 86462)
@@ -0,0 +1,106 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ AOP configuration
+-->
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <classloader><inject bean="aop-classloader:0.0.0"/></classloader>
+
+ <classloader name="aop-classloader" xmlns="urn:jboss:repoclassloader:1.0" export-all="NON_EMPTY" import-all="true">
+ <artifact>org.jboss.aop:jboss-aop-asintegration-core:2.1.0.CR1</artifact>
+ <artifact>org.jboss.aop:jboss-aop-asintegration-jmx:2.1.0.CR1</artifact>
+ <artifact>org.jboss.aop:jboss-aop-asintegration-mc:2.1.0.CR1</artifact>
+ <!-- artifact>org.jboss.jbossas:jboss-as-aspects:5.0.1.GA</artifact -->
+ <!-- TODO: see EJBTHREE-1734
+ <artifact>${jboss.lib.url}jboss-aop-jboss5.jar</artifact>
+ -->
+ <artifact>org.jboss.ejb3:jboss-ejb3-aop-deployers:0.1.0-SNAPSHOT</artifact>
+ <!-- TODO: some weird ivy side-effect? -->
+ <exclude org="org.jboss.jbossas" module="jboss-as-j2se" ext="test-jar"/>
+ </classloader>
+
+ <!-- Integration -->
+ <bean name="AOPClassLoaderScopingPolicy" class="org.jboss.aop.asintegration.jboss5.VFSClassLoaderScopingPolicy"/>
+
+ <bean name="AOPClassPoolFactory" class="org.jboss.aop.classpool.jbosscl.JBossClDelegatingClassPoolFactory">
+ <constructor>
+ <parameter><inject bean="AOPClassLoaderScopingPolicy" property="registry"/></parameter>
+ <parameter><inject bean="AOPRegisterModuleCallback"/></parameter>
+ </constructor>
+ </bean>
+
+ <bean name="AOPJBossIntegration" class="org.jboss.aop.asintegration.jboss5.JBoss5Integration">
+ <property name="classPoolFactory"><inject bean="AOPClassPoolFactory"/></property>
+ <property name="aopClassLoaderScopingPolicy"><inject bean="AOPClassLoaderScopingPolicy"/></property>
+ </bean>
+
+ <bean name="DefaultAspectManager" class="org.jboss.aop.microcontainer.beans.metadata.DefaultAspectManager">
+ <property name="managerBean">AspectManager</property>
+ <property name="managerProperty">aspectManager</property>
+ </bean>
+
+ <!-- bean name="AOPBootstrap" class="org.jboss.aop.asintegration.jboss5.AOPBootstrap" -->
+ <!-- This one lives in AS 5 source tree -->
+ <!-- property name="policy"><inject bean="AOPClassLoaderScopingPolicy"/></property>
+ <property name="manager"><inject bean="AspectManager" property="aspectManager"/></property>
+ </bean-->
+
+ <bean name="AOPRegisterModuleCallback" class="org.jboss.aop.asintegration.jboss5.RegisterModuleCallback">
+ <!-- classloader><null/></classloader -->
+ <incallback method="addModule" state="Installed"/>
+ <uncallback method="removeModule" state="Installed"/>
+ </bean>
+ <!--
+ Valid values for the AspectManager bean for use with enableTransformer=true are:
+ * org.jboss.aop.deployers.AspectManagerJDK5 - works with the -javaagent:pluggable-instrumentor.jar switch
+ * org.jboss.aop.deployers.AspectManagerJRockit - works with JRockit and the -Xmanagement:class=org.jboss.aop.hook.JRockitPluggableClassPreProcessor switch
+ -->
+ <bean name="AspectManager" class="org.jboss.aop.deployers.AspectManagerJDK5">
+ <constructor>
+ <parameter><![CDATA[
+ <aop>
+ <aspect name="mainDeployer" class="org.jboss.profileservice.aop.MainDeployerAspect"/>
+ <bind pointcut="execution(* $instanceof{org.jboss.deployers.spi.deployment.MainDeployer}->process(..))">
+ <advice name="process" aspect="mainDeployer"/>
+ </bind>
+ <aspect name="persist" class="org.jboss.profileservice.aop.PersistAspect"/>
+ <bind pointcut="execution(* $instanceof{org.jboss.managed.api.ManagedProperty}->setValue(..))">
+ <advice name="setValue" aspect="persist"/>
+ </bind>
+ </aop>]]>
+ </parameter>
+ </constructor>
+
+ <property name="jbossIntegration"><inject bean="AOPJBossIntegration"/></property>
+
+ <property name="enableLoadtimeWeaving">false</property>
+ <!-- only relevant when EnableLoadtimeWeaving is true.
+ When transformer is on, every loaded class gets
+ transformed. If AOP can't find the class, then it
+ throws an exception. Sometimes, classes may not have
+ all the classes they reference. So, the Suppressing
+ is needed. (i.e. Jboss cache in the default configuration -->
+ <property name="suppressTransformationErrors">true</property>
+ <property name="prune">true</property>
+ <property name="include">org.jboss.test., org.jboss.injbossaop.</property>
+ <property name="exclude">org.jboss.</property>
+ <!-- This avoids instrumentation of hibernate cglib enhanced proxies
+ <property name="ignore">*$$EnhancerByCGLIB$$*</property> -->
+ <property name="optimized">true</property>
+ <property name="verbose">false</property>
+ <!--
+ Available choices for this attribute are:
+ org.jboss.aop.instrument.ClassicInstrumentor (default)
+ org.jboss.aop.instrument.GeneratedAdvisorInstrumentor
+ <property name="instrumentor">org.jboss.aop.instrument.ClassicInstrumentor</property>
+ -->
+ <!--
+ By default the deployment of the aspects contained in
+ ../deployers/jboss-aop-jboss5.deployer/base-aspects.xml
+ are not deployed. To turn on deployment uncomment this property
+ <property name="useBaseXml">true</property>
+ -->
+ </bean>
+
+</deployment>
Property changes on: projects/reloaded/trunk/repoclassloader/src/test/resources/conf/bootstrap/aop.xml
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:mergeinfo
+
Name: svn:eol-style
+ native
Copied: projects/reloaded/trunk/repoclassloader/src/test/resources/conf/bootstrap/classloader.xml (from rev 86365, projects/reloaded/trunk/vdf-bootstrap/src/main/resources/server/default/conf/bootstrap/classloader.xml)
===================================================================
--- projects/reloaded/trunk/repoclassloader/src/test/resources/conf/bootstrap/classloader.xml (rev 0)
+++ projects/reloaded/trunk/repoclassloader/src/test/resources/conf/bootstrap/classloader.xml 2009-03-30 08:26:42 UTC (rev 86462)
@@ -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:repoclassloader:1.0" export-all="NON_EMPTY" import-all="true">
+ <!-- System -->
+ <!--
+ <root>${jboss.lib.url}jboss-system.jar</root>
+ -->
+ </classloader>
+
+</deployment>
Property changes on: projects/reloaded/trunk/repoclassloader/src/test/resources/conf/bootstrap/classloader.xml
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:mergeinfo
+
Name: svn:eol-style
+ native
Added: projects/reloaded/trunk/repoclassloader/src/test/resources/conf/bootstrap/repo.xml
===================================================================
--- projects/reloaded/trunk/repoclassloader/src/test/resources/conf/bootstrap/repo.xml (rev 0)
+++ projects/reloaded/trunk/repoclassloader/src/test/resources/conf/bootstrap/repo.xml 2009-03-30 08:26:42 UTC (rev 86462)
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Boot up the repository resolver for the class loader factory
+-->
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+ <classloader><inject bean="repo-classloader:0.0.0"/></classloader>
+
+ <bean name="RepoClassLoaderSchema" class="org.jboss.reloaded.repoclassloader.schema.RepoClassLoaderSchemaResolverFactory"/>
+
+ <bean name="IvyRepoResolver" class="org.jboss.reloaded.repoclassloader.ivy.IvyRepoResolver">
+ <property name="settings">
+ <![CDATA[
+ <ivysettings>
+ <settings defaultResolver="default"/>
+ <include url="${ivy.default.settings.dir}/ivysettings-public.xml"/>
+ <include url="${ivy.default.settings.dir}/ivysettings-shared.xml"/>
+ <include url="${ivy.default.settings.dir}/ivysettings-local.xml"/>
+ <resolvers>
+ <ibiblio name="snapshots.jboss.org" m2compatible="true" usepoms="true" root="http://snapshots.jboss.org/maven2"/>
+ <ibiblio name="repository.jboss.org" m2compatible="true" usepoms="true" root="http://repository.jboss.org/maven2"/>
+ <chain name="main" dual="true">
+ <resolver ref="shared"/>
+ <resolver ref="repository.jboss.org"/>
+ <resolver ref="snapshots.jboss.org"/>
+ <resolver ref="public"/>
+ </chain>
+ </resolvers>
+ <include url="${ivy.default.settings.dir}/ivysettings-default-chain.xml"/>
+ </ivysettings>
+ ]]>
+ </property>
+ </bean>
+
+ <classloader name="repo-classloader:0.0.0">
+ <null/>
+ </classloader>
+</deployment>
\ No newline at end of file
Added: projects/reloaded/trunk/repoclassloader/src/test/resources/conf/bootstrap.xml
===================================================================
--- projects/reloaded/trunk/repoclassloader/src/test/resources/conf/bootstrap.xml (rev 0)
+++ projects/reloaded/trunk/repoclassloader/src/test/resources/conf/bootstrap.xml 2009-03-30 08:26:42 UTC (rev 86462)
@@ -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/repo.xml</url>
+ <url>bootstrap/classloader.xml</url>
+ <url>bootstrap/aop.xml</url>
+</bootstrap>
\ No newline at end of file
Added: projects/reloaded/trunk/repoclassloader/src/test/resources/log4j.xml
===================================================================
--- projects/reloaded/trunk/repoclassloader/src/test/resources/log4j.xml (rev 0)
+++ projects/reloaded/trunk/repoclassloader/src/test/resources/log4j.xml 2009-03-30 08:26:42 UTC (rev 86462)
@@ -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>
More information about the jboss-cvs-commits
mailing list