[jboss-cvs] JBossAS SVN: r104778 - in projects/jboss-cl/trunk: classloading/src/main/java/org/jboss/classloading/spi/dependency/policy and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu May 13 16:16:51 EDT 2010
Author: alesj
Date: 2010-05-13 16:16:49 -0400 (Thu, 13 May 2010)
New Revision: 104778
Removed:
projects/jboss-cl/trunk/classloader/src/main/java/org/jboss/classloader/spi/base/ClassLoadingTaskAwareLoader.java
projects/jboss-cl/trunk/classloader/src/main/java/org/jboss/classloader/spi/base/ClassLoadingTaskInfo.java
Modified:
projects/jboss-cl/trunk/classloader/src/main/java/org/jboss/classloader/spi/base/BaseClassLoaderPolicy.java
projects/jboss-cl/trunk/classloader/src/main/java/org/jboss/classloader/spi/base/ClassLoaderManager.java
projects/jboss-cl/trunk/classloader/src/main/java/org/jboss/classloader/spi/base/ClassLoadingTask.java
projects/jboss-cl/trunk/classloading/src/main/java/org/jboss/classloading/spi/dependency/policy/WildcardClassLoaderPolicy.java
projects/jboss-cl/trunk/classloading/src/main/java/org/jboss/classloading/spi/dependency/policy/WildcardDelegateLoader.java
Log:
Remove public access to BaseClassLoader from delegate loader.
Modified: projects/jboss-cl/trunk/classloader/src/main/java/org/jboss/classloader/spi/base/BaseClassLoaderPolicy.java
===================================================================
--- projects/jboss-cl/trunk/classloader/src/main/java/org/jboss/classloader/spi/base/BaseClassLoaderPolicy.java 2010-05-13 18:22:49 UTC (rev 104777)
+++ projects/jboss-cl/trunk/classloader/src/main/java/org/jboss/classloader/spi/base/BaseClassLoaderPolicy.java 2010-05-13 20:16:49 UTC (rev 104778)
@@ -350,8 +350,23 @@
shutdownPolicy();
this.domain = null;
}
-
+
/**
+ * Get the classloader based on classloading task.
+ *
+ * Since ClassLoadingTask ctor is package protected
+ * this method cannot be easily abused, since the only
+ * code that can instantiate ClassLoadingTask is our ClassLoaderManager.
+ *
+ * @param task the classloading task info
+ * @return the classloader
+ */
+ protected synchronized BaseClassLoader getClassLoader(ClassLoadingTask task)
+ {
+ return getClassLoader();
+ }
+
+ /**
* Get the classloader
*
* @return the classloader
Modified: projects/jboss-cl/trunk/classloader/src/main/java/org/jboss/classloader/spi/base/ClassLoaderManager.java
===================================================================
--- projects/jboss-cl/trunk/classloader/src/main/java/org/jboss/classloader/spi/base/ClassLoaderManager.java 2010-05-13 18:22:49 UTC (rev 104777)
+++ projects/jboss-cl/trunk/classloader/src/main/java/org/jboss/classloader/spi/base/ClassLoaderManager.java 2010-05-13 20:16:49 UTC (rev 104778)
@@ -339,18 +339,13 @@
List<ThreadTask> taskList;
BaseClassLoader classLoader = null;
- if (loader instanceof ClassLoadingTaskAwareLoader)
+ if (loader instanceof BaseDelegateLoader)
{
- ClassLoadingTaskAwareLoader cltal = (ClassLoadingTaskAwareLoader) loader;
- classLoader = cltal.getBaseClassLoader(task);
- }
- if (classLoader == null && loader instanceof BaseDelegateLoader)
- {
BaseDelegateLoader delegateLoader = (BaseDelegateLoader) loader;
BaseClassLoaderPolicy policy = delegateLoader.getPolicy();
if (policy == null)
throw new IllegalStateException("Null policy for " + delegateLoader);
- classLoader = policy.getClassLoader();
+ classLoader = policy.getClassLoader(task);
}
synchronized (loadClassThreads)
Modified: projects/jboss-cl/trunk/classloader/src/main/java/org/jboss/classloader/spi/base/ClassLoadingTask.java
===================================================================
--- projects/jboss-cl/trunk/classloader/src/main/java/org/jboss/classloader/spi/base/ClassLoadingTask.java 2010-05-13 18:22:49 UTC (rev 104777)
+++ projects/jboss-cl/trunk/classloader/src/main/java/org/jboss/classloader/spi/base/ClassLoadingTask.java 2010-05-13 20:16:49 UTC (rev 104778)
@@ -34,13 +34,17 @@
/**
* ClassLoadingTask.
+ *
+ * Make the class public, so others can use it,
+ * but the ctor is still package protected
+ * so only classes in this package can instantiate it.
*
* @author Scott.Stark at jboss.org
* @author <a href="adrian at jboss.com">Adrian Brock</a>
* @author <a href="ales.justin at jboss.org">Ales Justin</a>
* @version $Revision: 1.1 $
*/
-class ClassLoadingTask implements ClassLoadingTaskInfo
+public class ClassLoadingTask
{
/** The log */
protected static Logger log = Logger.getLogger("org.jboss.detailed.classloader.ClassLoadingTask");
@@ -403,18 +407,13 @@
BaseClassLoader getClassLoader()
{
BaseClassLoader classLoader = null;
- if (loader instanceof ClassLoadingTaskAwareLoader)
+ if (loader instanceof BaseDelegateLoader)
{
- ClassLoadingTaskAwareLoader cltal = (ClassLoadingTaskAwareLoader) loader;
- classLoader = cltal.getBaseClassLoader(getLoadTask());
- }
- if (classLoader == null && loader instanceof BaseDelegateLoader)
- {
BaseDelegateLoader delegateLoader = (BaseDelegateLoader) loader;
BaseClassLoaderPolicy policy = delegateLoader.getPolicy();
if (policy == null)
throw new IllegalStateException("Null classloader policy for " + loader);
- classLoader = policy.getClassLoader();
+ classLoader = policy.getClassLoader(getLoadTask());
}
return classLoader;
}
@@ -452,7 +451,7 @@
/**
* Run the class load
*
- * @throws ClassNotFoundException
+ * @throws ClassNotFoundException if class cannot be loaded
*/
void run() throws ClassNotFoundException
{
Deleted: projects/jboss-cl/trunk/classloader/src/main/java/org/jboss/classloader/spi/base/ClassLoadingTaskAwareLoader.java
===================================================================
--- projects/jboss-cl/trunk/classloader/src/main/java/org/jboss/classloader/spi/base/ClassLoadingTaskAwareLoader.java 2010-05-13 18:22:49 UTC (rev 104777)
+++ projects/jboss-cl/trunk/classloader/src/main/java/org/jboss/classloader/spi/base/ClassLoadingTaskAwareLoader.java 2010-05-13 20:16:49 UTC (rev 104778)
@@ -1,38 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2010, 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;
-
-/**
- * Loader that knows how to get BaseClassLoader based on task
- * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
- */
-public interface ClassLoadingTaskAwareLoader
-{
- /**
- * Get classloader.
- *
- * @param task the current classloading task
- * @return matching classloader or null
- */
- BaseClassLoader getBaseClassLoader(ClassLoadingTaskInfo task);
-}
Deleted: projects/jboss-cl/trunk/classloader/src/main/java/org/jboss/classloader/spi/base/ClassLoadingTaskInfo.java
===================================================================
--- projects/jboss-cl/trunk/classloader/src/main/java/org/jboss/classloader/spi/base/ClassLoadingTaskInfo.java 2010-05-13 18:22:49 UTC (rev 104777)
+++ projects/jboss-cl/trunk/classloader/src/main/java/org/jboss/classloader/spi/base/ClassLoadingTaskInfo.java 2010-05-13 20:16:49 UTC (rev 104778)
@@ -1,37 +0,0 @@
-/*
- * 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;
-
-/**
- * ClassLoadingTaskInfo.
- *
- * @author <a href="ales.justin at jboss.org">Ales Justin</a>
- */
-public interface ClassLoadingTaskInfo
-{
- /**
- * Get the className.
- *
- * @return the className.
- */
- String getClassName();
-}
\ No newline at end of file
Modified: projects/jboss-cl/trunk/classloading/src/main/java/org/jboss/classloading/spi/dependency/policy/WildcardClassLoaderPolicy.java
===================================================================
--- projects/jboss-cl/trunk/classloading/src/main/java/org/jboss/classloading/spi/dependency/policy/WildcardClassLoaderPolicy.java 2010-05-13 18:22:49 UTC (rev 104777)
+++ projects/jboss-cl/trunk/classloading/src/main/java/org/jboss/classloading/spi/dependency/policy/WildcardClassLoaderPolicy.java 2010-05-13 20:16:49 UTC (rev 104778)
@@ -26,8 +26,10 @@
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
+import org.jboss.classloader.plugins.ClassLoaderUtils;
import org.jboss.classloader.spi.ClassLoaderPolicy;
import org.jboss.classloader.spi.base.BaseClassLoader;
+import org.jboss.classloader.spi.base.ClassLoadingTask;
import org.jboss.classloader.spi.filter.ClassFilter;
import org.jboss.classloading.plugins.metadata.PackageRequirement;
import org.jboss.classloading.spi.dependency.*;
@@ -237,4 +239,14 @@
}
return null;
}
+
+ @Override
+ protected BaseClassLoader getClassLoader(ClassLoadingTask task)
+ {
+ if (task == null)
+ throw new IllegalArgumentException("Null task");
+
+ String path = ClassLoaderUtils.classNameToPath(task.getClassName());
+ return getBaseClassLoader(path);
+ }
}
Modified: projects/jboss-cl/trunk/classloading/src/main/java/org/jboss/classloading/spi/dependency/policy/WildcardDelegateLoader.java
===================================================================
--- projects/jboss-cl/trunk/classloading/src/main/java/org/jboss/classloading/spi/dependency/policy/WildcardDelegateLoader.java 2010-05-13 18:22:49 UTC (rev 104777)
+++ projects/jboss-cl/trunk/classloading/src/main/java/org/jboss/classloading/spi/dependency/policy/WildcardDelegateLoader.java 2010-05-13 20:16:49 UTC (rev 104778)
@@ -22,12 +22,9 @@
package org.jboss.classloading.spi.dependency.policy;
-import org.jboss.classloader.plugins.ClassLoaderUtils;
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.ClassLoadingTaskAwareLoader;
-import org.jboss.classloader.spi.base.ClassLoadingTaskInfo;
import org.jboss.classloader.spi.filter.ClassFilter;
import org.jboss.classloader.spi.filter.FilteredDelegateLoader;
@@ -36,7 +33,7 @@
*
* @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
*/
-public class WildcardDelegateLoader extends FilteredDelegateLoader implements ClassLoadingTaskAwareLoader
+public class WildcardDelegateLoader extends FilteredDelegateLoader
{
public WildcardDelegateLoader(ClassLoaderPolicyFactory factory, ClassFilter filter)
{
@@ -53,10 +50,4 @@
WildcardClassLoaderPolicy wclp = (WildcardClassLoaderPolicy) policy;
return wclp.getBaseClassLoader(context);
}
-
- public BaseClassLoader getBaseClassLoader(ClassLoadingTaskInfo task)
- {
- String path = ClassLoaderUtils.classNameToPath(task.getClassName());
- return getBaseClassLoader(null, path);
- }
}
More information about the jboss-cvs-commits
mailing list