[jboss-cvs] JBossAS SVN: r105302 - in projects/jboss-cl/trunk: classloading/src/main/java/org/jboss/classloading/spi/dependency/wildcard and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu May 27 09:59:28 EDT 2010
Author: alesj
Date: 2010-05-27 09:59:27 -0400 (Thu, 27 May 2010)
New Revision: 105302
Added:
projects/jboss-cl/trunk/classloader/src/main/java/org/jboss/classloader/spi/base/ResourcePathAdapter.java
Modified:
projects/jboss-cl/trunk/classloader/src/main/java/org/jboss/classloader/spi/base/BaseDelegateLoader.java
projects/jboss-cl/trunk/classloading/src/main/java/org/jboss/classloading/spi/dependency/wildcard/WildcardDelegateLoader.java
Log:
Make things lazy for to-resource adaption.
Modified: projects/jboss-cl/trunk/classloader/src/main/java/org/jboss/classloader/spi/base/BaseDelegateLoader.java
===================================================================
--- projects/jboss-cl/trunk/classloader/src/main/java/org/jboss/classloader/spi/base/BaseDelegateLoader.java 2010-05-27 10:13:26 UTC (rev 105301)
+++ projects/jboss-cl/trunk/classloader/src/main/java/org/jboss/classloader/spi/base/BaseDelegateLoader.java 2010-05-27 13:59:27 UTC (rev 105302)
@@ -42,7 +42,13 @@
{
/** The log */
private static final Logger log = Logger.getLogger(BaseDelegateLoader.class);
-
+
+ /** The class to path */
+ private static final ResourcePathAdapter CLASS_TO_PATH = new ClassToPathResourceAdapter();
+
+ /** The package to path */
+ private static final ResourcePathAdapter PACKAGE_TO_PATH = new PackageToPathResourceAdapter();
+
/** The delegate loader policy */
private volatile BaseClassLoaderPolicy delegate;
@@ -129,10 +135,22 @@
log.warn("Not " + message + context + " from policy that has no classLoader: " + toLongString());
return result;
}
-
+
+ /**
+ * Transform, if needed, to resource path.
+ *
+ * @param context the context
+ * @param adapter the adapter
+ * @return potential transformation result
+ */
+ protected String toResourcePath(String context, ResourcePathAdapter adapter)
+ {
+ return context; // do nothing
+ }
+
public Class<?> loadClass(String className)
{
- String path = ClassLoaderUtils.classNameToPath(className);
+ String path = toResourcePath(className, CLASS_TO_PATH);
BaseClassLoader classLoader = getBaseClassLoader("loading class ", path);
if (classLoader != null)
return classLoader.loadClassLocally(className);
@@ -157,7 +175,7 @@
public Package getPackage(String name)
{
- String path = ClassLoaderUtils.packageToPath(name);
+ String path = toResourcePath(name, PACKAGE_TO_PATH);
BaseClassLoader classLoader = getBaseClassLoader("getting package ", path);
if (classLoader != null)
return classLoader.getPackageLocally(name);
@@ -227,4 +245,20 @@
builder.append('}');
return builder.toString();
}
+
+ protected static class ClassToPathResourceAdapter implements ResourcePathAdapter
+ {
+ public String toResourcePath(String context)
+ {
+ return ClassLoaderUtils.classNameToPath(context);
+ }
+ }
+
+ protected static class PackageToPathResourceAdapter implements ResourcePathAdapter
+ {
+ public String toResourcePath(String context)
+ {
+ return ClassLoaderUtils.packageToPath(context);
+ }
+ }
}
Copied: projects/jboss-cl/trunk/classloader/src/main/java/org/jboss/classloader/spi/base/ResourcePathAdapter.java (from rev 105242, projects/jboss-cl/trunk/classloader/src/main/java/org/jboss/classloader/spi/base/BaseDelegateLoader.java)
===================================================================
--- projects/jboss-cl/trunk/classloader/src/main/java/org/jboss/classloader/spi/base/ResourcePathAdapter.java (rev 0)
+++ projects/jboss-cl/trunk/classloader/src/main/java/org/jboss/classloader/spi/base/ResourcePathAdapter.java 2010-05-27 13:59:27 UTC (rev 105302)
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, 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.classloader.spi.base;
+
+/**
+ * Resource path adapter.
+ *
+ * @author <a href="ales.justin at jboss.org">Ales Justin</a>
+ */
+public interface ResourcePathAdapter
+{
+ /**
+ * Transform current context into resource path.
+ *
+ * @param context the current context
+ * @return context's resource path
+ */
+ String toResourcePath(String context);
+}
\ No newline at end of file
Modified: projects/jboss-cl/trunk/classloading/src/main/java/org/jboss/classloading/spi/dependency/wildcard/WildcardDelegateLoader.java
===================================================================
--- projects/jboss-cl/trunk/classloading/src/main/java/org/jboss/classloading/spi/dependency/wildcard/WildcardDelegateLoader.java 2010-05-27 10:13:26 UTC (rev 105301)
+++ projects/jboss-cl/trunk/classloading/src/main/java/org/jboss/classloading/spi/dependency/wildcard/WildcardDelegateLoader.java 2010-05-27 13:59:27 UTC (rev 105302)
@@ -25,6 +25,7 @@
import org.jboss.classloader.spi.ClassLoaderPolicy;
import org.jboss.classloader.spi.ClassLoaderPolicyFactory;
import org.jboss.classloader.spi.base.BaseClassLoader;
+import org.jboss.classloader.spi.base.ResourcePathAdapter;
import org.jboss.classloader.spi.filter.ClassFilter;
import org.jboss.classloader.spi.filter.FilteredDelegateLoader;
@@ -41,6 +42,12 @@
}
@Override
+ protected String toResourcePath(String context, ResourcePathAdapter adapter)
+ {
+ return adapter.toResourcePath(context);
+ }
+
+ @Override
protected BaseClassLoader getBaseClassLoader(String message, String context)
{
ClassLoaderPolicy policy = getPolicy();
More information about the jboss-cvs-commits
mailing list