[jboss-cvs] JBossAS SVN: r104686 - in projects/jboss-cl/trunk: classloader/src/main/java/org/jboss/classloader/plugins/loader and 7 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue May 11 11:01:14 EDT 2010
Author: alesj
Date: 2010-05-11 11:01:13 -0400 (Tue, 11 May 2010)
New Revision: 104686
Added:
projects/jboss-cl/trunk/classloader/src/main/java/org/jboss/classloader/spi/CacheLoader.java
projects/jboss-cl/trunk/classloader/src/main/java/org/jboss/classloader/spi/ImportType.java
projects/jboss-cl/trunk/classloading/src/main/java/org/jboss/classloading/spi/metadata/RequirementWithImportType.java
Modified:
projects/jboss-cl/trunk/classloader/src/main/java/org/jboss/classloader/plugins/loader/ClassLoaderToLoaderAdapter.java
projects/jboss-cl/trunk/classloader/src/main/java/org/jboss/classloader/spi/ClassLoaderDomain.java
projects/jboss-cl/trunk/classloader/src/main/java/org/jboss/classloader/spi/DelegateLoader.java
projects/jboss-cl/trunk/classloader/src/main/java/org/jboss/classloader/spi/base/BaseClassLoader.java
projects/jboss-cl/trunk/classloader/src/main/java/org/jboss/classloader/spi/base/BaseClassLoaderDomain.java
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/ClassLoaderInformation.java
projects/jboss-cl/trunk/classloader/src/test/java/org/jboss/test/classloader/domain/test/CustomParentLoaderUnitTestCase.java
projects/jboss-cl/trunk/classloading-vfs/src/main/resources/schema/jboss-classloading-1.0.xsd
projects/jboss-cl/trunk/classloading/src/main/java/org/jboss/classloading/spi/dependency/Module.java
projects/jboss-cl/trunk/classloading/src/main/java/org/jboss/classloading/spi/metadata/helpers/AbstractRequirement.java
projects/jboss-cl/trunk/pom.xml
Log:
[JBCL-159, JBCL-160]; initial work on fixing cache lookup and splitting imports into before and after.
Modified: projects/jboss-cl/trunk/classloader/src/main/java/org/jboss/classloader/plugins/loader/ClassLoaderToLoaderAdapter.java
===================================================================
--- projects/jboss-cl/trunk/classloader/src/main/java/org/jboss/classloader/plugins/loader/ClassLoaderToLoaderAdapter.java 2010-05-11 14:53:23 UTC (rev 104685)
+++ projects/jboss-cl/trunk/classloader/src/main/java/org/jboss/classloader/plugins/loader/ClassLoaderToLoaderAdapter.java 2010-05-11 15:01:13 UTC (rev 104686)
@@ -24,15 +24,13 @@
import java.io.IOException;
import java.lang.reflect.Method;
import java.net.URL;
-import java.security.AccessControlContext;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.security.PrivilegedActionException;
-import java.security.PrivilegedExceptionAction;
+import java.security.*;
+import java.util.Arrays;
import java.util.Enumeration;
import java.util.Set;
-import org.jboss.classloader.spi.Loader;
+import org.jboss.classloader.spi.CacheLoader;
+import org.jboss.classloader.spi.base.BaseClassLoader;
import org.jboss.classloader.spi.base.BaseClassLoaderSource;
import org.jboss.logging.Logger;
@@ -40,9 +38,10 @@
* ClassLoaderToLoaderAdapter.
*
* @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 $
*/
-public class ClassLoaderToLoaderAdapter extends BaseClassLoaderSource implements Loader
+public class ClassLoaderToLoaderAdapter extends BaseClassLoaderSource implements CacheLoader
{
/** The log */
private static final Logger log = Logger.getLogger(ClassLoaderToLoaderAdapter.class);
@@ -56,6 +55,9 @@
/** The get packages method */
private static Method getPackages;
+ /** The find class method */
+ private static Method findLoadedClass;
+
static
{
AccessController.doPrivileged(new PrivilegedAction<Object>()
@@ -80,6 +82,15 @@
{
log.warn("Unable to set accessible on ClassLoader.getPackages()", e);
}
+ try
+ {
+ findLoadedClass = ClassLoader.class.getDeclaredMethod("findLoadedClass", String.class);
+ findLoadedClass.setAccessible(true);
+ }
+ catch (Exception e)
+ {
+ log.warn("Unable to set accessible on ClassLoader.getPackages()", e);
+ }
return null;
}
});
@@ -180,10 +191,10 @@
public Package getPackage(String name)
{
- final ClassLoader classLoader = getClassLoader();
if (getPackage == null)
return null;
+ final ClassLoader classLoader = getClassLoader();
try
{
return (Package) getPackage.invoke(classLoader, name);
@@ -197,13 +208,15 @@
public void getPackages(Set<Package> packages)
{
- final ClassLoader classLoader = getClassLoader();
if (getPackages == null)
return;
+ final ClassLoader classLoader = getClassLoader();
try
{
- getPackages.invoke(classLoader);
+ Package[] pckgs = (Package[]) getPackages.invoke(classLoader);
+ if (pckgs != null)
+ packages.addAll(Arrays.asList(pckgs));
}
catch (Exception e)
{
@@ -211,6 +224,23 @@
}
}
+ public Class<?> checkClassCache(BaseClassLoader bcl, String name, String path, boolean allExports)
+ {
+ if (findLoadedClass == null)
+ return null;
+
+ final ClassLoader classLoader = getClassLoader();
+ try
+ {
+ return (Class<?>) findLoadedClass.invoke(classLoader, name);
+ }
+ catch (Exception e)
+ {
+ log.warn("Unexpected error retrieving found class " + name + " from classloader " + classLoader, e);
+ return null;
+ }
+ }
+
@Override
public String toString()
{
Copied: projects/jboss-cl/trunk/classloader/src/main/java/org/jboss/classloader/spi/CacheLoader.java (from rev 104077, projects/jboss-cl/trunk/classloader/src/main/java/org/jboss/classloader/spi/Loader.java)
===================================================================
--- projects/jboss-cl/trunk/classloader/src/main/java/org/jboss/classloader/spi/CacheLoader.java (rev 0)
+++ projects/jboss-cl/trunk/classloader/src/main/java/org/jboss/classloader/spi/CacheLoader.java 2010-05-11 15:01:13 UTC (rev 104686)
@@ -0,0 +1,43 @@
+/*
+ * 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;
+
+import org.jboss.classloader.spi.base.BaseClassLoader;
+
+/**
+ * Can load from cache.
+ *
+ * @author <a href="ales.justin at jboss.org">Ales Justin</a>
+ */
+public interface CacheLoader extends Loader
+{
+ /**
+ * Check the class cache.
+ *
+ * @param classLoader the reference classloader (possibly null)
+ * @param name the name of the class
+ * @param path the path of the class resource
+ * @param allExports whether to look at all exports
+ * @return the class if cached
+ */
+ Class<?> checkClassCache(BaseClassLoader classLoader, String name, String path, boolean allExports);
+}
\ No newline at end of file
Modified: projects/jboss-cl/trunk/classloader/src/main/java/org/jboss/classloader/spi/ClassLoaderDomain.java
===================================================================
--- projects/jboss-cl/trunk/classloader/src/main/java/org/jboss/classloader/spi/ClassLoaderDomain.java 2010-05-11 14:53:23 UTC (rev 104685)
+++ projects/jboss-cl/trunk/classloader/src/main/java/org/jboss/classloader/spi/ClassLoaderDomain.java 2010-05-11 15:01:13 UTC (rev 104686)
@@ -21,26 +21,21 @@
*/
package org.jboss.classloader.spi;
+import javax.management.MBeanRegistration;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
import java.io.IOException;
import java.net.URL;
import java.security.AccessController;
import java.security.PrivilegedAction;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeSet;
+import java.util.*;
import java.util.Map.Entry;
import java.util.concurrent.CopyOnWriteArrayList;
-import javax.management.MBeanRegistration;
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
-
import org.jboss.classloader.plugins.ClassLoaderUtils;
import org.jboss.classloader.plugins.loader.ClassLoaderToLoaderAdapter;
+import org.jboss.classloader.spi.base.BaseClassLoader;
import org.jboss.classloader.spi.base.BaseClassLoaderDomain;
import org.jboss.classloader.spi.base.BaseClassLoaderSource;
import org.jboss.classloader.spi.filter.ClassFilter;
@@ -51,9 +46,10 @@
* ClassLoaderDomain.
*
* @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 $
*/
-public class ClassLoaderDomain extends BaseClassLoaderDomain implements Loader, ClassLoaderDomainMBean, MBeanRegistration, ClassNotFoundHandler, ClassFoundHandler
+public class ClassLoaderDomain extends BaseClassLoaderDomain implements ClassLoaderDomainMBean, MBeanRegistration, ClassNotFoundHandler, ClassFoundHandler
{
/** The log */
private static final Logger log = Logger.getLogger(ClassLoaderDomain.class);
@@ -1042,4 +1038,43 @@
}
}
}
+
+ @Override
+ protected Class<?> checkCacheBefore(BaseClassLoader classLoader, String name, String path, boolean allExports)
+ {
+ if (parent == null || parent instanceof CacheLoader == false)
+ return null;
+
+ ClassFilter filter = getParentPolicy().getBeforeFilter();
+ if (filter.matchesClassName(name))
+ {
+ CacheLoader loader = (CacheLoader) parent;
+ return loader.checkClassCache(classLoader, name, path, allExports);
+ }
+ return null;
+ }
+
+ /**
+ * Only check parent after if we already blacklisted this resource.
+ *
+ * @param classLoader the classloader (possibly null)
+ * @param name the name
+ * @param path the path of the class resource
+ * @param allExports whether to look at all exports
+ * @return cached result if found in parent
+ */
+ @Override
+ protected Class<?> checkCacheAfter(BaseClassLoader classLoader, String name, String path, boolean allExports)
+ {
+ if (parent == null || parent instanceof CacheLoader == false || isBlackListedClass(name) == false)
+ return null;
+
+ ClassFilter filter = getParentPolicy().getAfterFilter();
+ if (filter.matchesClassName(name))
+ {
+ CacheLoader loader = (CacheLoader) parent;
+ return loader.checkClassCache(classLoader, name, path, allExports);
+ }
+ return null;
+ }
}
Modified: projects/jboss-cl/trunk/classloader/src/main/java/org/jboss/classloader/spi/DelegateLoader.java
===================================================================
--- projects/jboss-cl/trunk/classloader/src/main/java/org/jboss/classloader/spi/DelegateLoader.java 2010-05-11 14:53:23 UTC (rev 104685)
+++ projects/jboss-cl/trunk/classloader/src/main/java/org/jboss/classloader/spi/DelegateLoader.java 2010-05-11 15:01:13 UTC (rev 104686)
@@ -27,10 +27,14 @@
* DelegateLoader.
*
* @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 $
*/
-public class DelegateLoader extends BaseDelegateLoader implements Loader
+public class DelegateLoader extends BaseDelegateLoader
{
+ /** The import type */
+ private ImportType importType = ImportType.BEFORE;
+
/**
* Create a new DelegateLoader.
*
@@ -61,4 +65,26 @@
{
return (ClassLoaderPolicy)super.getPolicy();
}
+
+ /**
+ * Get import type.
+ *
+ * @return the import type
+ */
+ public ImportType getImportType()
+ {
+ return importType;
+ }
+
+ /**
+ * Set import type.
+ *
+ * @param importType the import type
+ */
+ public void setImportType(ImportType importType)
+ {
+ if (importType == null)
+ throw new IllegalArgumentException("Null import type");
+ this.importType = importType;
+ }
}
Copied: projects/jboss-cl/trunk/classloader/src/main/java/org/jboss/classloader/spi/ImportType.java (from rev 104077, projects/jboss-cl/trunk/classloader/src/main/java/org/jboss/classloader/spi/ShutdownPolicy.java)
===================================================================
--- projects/jboss-cl/trunk/classloader/src/main/java/org/jboss/classloader/spi/ImportType.java (rev 0)
+++ projects/jboss-cl/trunk/classloader/src/main/java/org/jboss/classloader/spi/ImportType.java 2010-05-11 15:01:13 UTC (rev 104686)
@@ -0,0 +1,45 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2007, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt 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;
+
+/**
+ * Import type..
+ *
+ * @author <a href="ales.justin at jboss.org">Ales Justin</a>
+ */
+public enum ImportType
+{
+ /**
+ * Check imports before local classloader.
+ */
+ BEFORE,
+
+ /**
+ * Check imports after global classloader.
+ */
+ AFTER,
+
+ /**
+ * Get all imports
+ */
+ ALL
+}
\ No newline at end of file
Modified: projects/jboss-cl/trunk/classloader/src/main/java/org/jboss/classloader/spi/base/BaseClassLoader.java
===================================================================
--- projects/jboss-cl/trunk/classloader/src/main/java/org/jboss/classloader/spi/base/BaseClassLoader.java 2010-05-11 14:53:23 UTC (rev 104685)
+++ projects/jboss-cl/trunk/classloader/src/main/java/org/jboss/classloader/spi/base/BaseClassLoader.java 2010-05-11 15:01:13 UTC (rev 104686)
@@ -21,39 +21,19 @@
*/
package org.jboss.classloader.spi.base;
+import javax.management.ObjectName;
+
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
-import java.security.AccessController;
-import java.security.CodeSource;
-import java.security.PrivilegedAction;
-import java.security.PrivilegedActionException;
-import java.security.PrivilegedExceptionAction;
-import java.security.ProtectionDomain;
-import java.security.SecureClassLoader;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeSet;
+import java.security.*;
+import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.ReentrantLock;
-import javax.management.ObjectName;
-
import org.jboss.classloader.plugins.ClassLoaderUtils;
-import org.jboss.classloader.spi.ClassFoundEvent;
-import org.jboss.classloader.spi.ClassLoaderDomain;
-import org.jboss.classloader.spi.ClassLoaderPolicy;
-import org.jboss.classloader.spi.ClassNotFoundEvent;
-import org.jboss.classloader.spi.DelegateLoader;
-import org.jboss.classloader.spi.Loader;
-import org.jboss.classloader.spi.PackageInformation;
-import org.jboss.classloader.spi.ShutdownPolicy;
+import org.jboss.classloader.spi.*;
import org.jboss.classloader.spi.filter.ClassFilterUtils;
import org.jboss.classloading.spi.RealClassLoader;
import org.jboss.logging.Logger;
@@ -65,6 +45,7 @@
* [TODO] Add meaningful javadoc
*
* @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 $
*/
public class BaseClassLoader extends SecureClassLoader implements BaseClassLoaderMBean, RealClassLoader
@@ -379,7 +360,7 @@
if (domain == null)
return null;
- return domain.checkClassCacheAndBlackList(this, name, null, basePolicy.isImportAll(), false);
+ return domain.checkClassCacheAndBlackList(this, name, null, basePolicy.isImportAll(), failIfBlackListed);
}
@Override
@@ -925,8 +906,14 @@
public Class<?> getCachedClass(String name)
{
- // TODO look in global and/or local cache
- return null;
+ try
+ {
+ return checkCacheAndBlackList(name, false, log.isTraceEnabled());
+ }
+ catch (ClassNotFoundException ignored)
+ {
+ return null;
+ }
}
public URL getCachedResource(String name)
Modified: projects/jboss-cl/trunk/classloader/src/main/java/org/jboss/classloader/spi/base/BaseClassLoaderDomain.java
===================================================================
--- projects/jboss-cl/trunk/classloader/src/main/java/org/jboss/classloader/spi/base/BaseClassLoaderDomain.java 2010-05-11 14:53:23 UTC (rev 104685)
+++ projects/jboss-cl/trunk/classloader/src/main/java/org/jboss/classloader/spi/base/BaseClassLoaderDomain.java 2010-05-11 15:01:13 UTC (rev 104686)
@@ -30,11 +30,9 @@
import java.util.concurrent.CopyOnWriteArrayList;
import org.jboss.classloader.plugins.ClassLoaderUtils;
-import org.jboss.classloader.spi.ClassLoaderPolicy;
-import org.jboss.classloader.spi.DelegateLoader;
-import org.jboss.classloader.spi.Loader;
-import org.jboss.classloader.spi.ShutdownPolicy;
+import org.jboss.classloader.spi.*;
import org.jboss.logging.Logger;
+import org.jboss.util.collection.ConcurrentSet;
/**
* BaseClassLoaderDomain.<p>
@@ -43,9 +41,10 @@
* package access to the protected methods.
*
* @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 $
*/
-public abstract class BaseClassLoaderDomain implements Loader
+public abstract class BaseClassLoaderDomain implements CacheLoader
{
/** The log */
private static final Logger log = Logger.getLogger(BaseClassLoaderDomain.class);
@@ -63,13 +62,15 @@
private Map<String, ClassCacheItem> globalClassCache = new ConcurrentHashMap<String, ClassCacheItem>();
/** The global class black list */
- private Map<String, String> globalClassBlackList = new ConcurrentHashMap<String, String>();
-
+ private Set<String> globalClassBlackList = new ConcurrentSet<String>();
+
+ // TODO -- why the inconsistency / difference between classes and resources?
+
/** The global resource cache */
private Map<String, URL> globalResourceCache = new ConcurrentHashMap<String, URL>();
/** The global resource black list */
- private Map<String, String> globalResourceBlackList = new ConcurrentHashMap<String, String>();
+ private Set<String> globalResourceBlackList = new ConcurrentSet<String>();
/** Keep track of the added order */
private int order = 0;
@@ -100,7 +101,7 @@
public int getResourceBlackListSize()
{
- return globalClassBlackList.size();
+ return globalResourceBlackList.size();
}
public int getResourceCacheSize()
@@ -110,7 +111,7 @@
public Set<String> listClassBlackList()
{
- return Collections.unmodifiableSet(globalClassBlackList.keySet());
+ return Collections.unmodifiableSet(globalClassBlackList);
}
public Map<String, String> listClassCache()
@@ -123,7 +124,7 @@
public Set<String> listResourceBlackList()
{
- return Collections.unmodifiableSet(globalResourceBlackList.keySet());
+ return Collections.unmodifiableSet(globalResourceBlackList);
}
public Map<String, URL> listResourceCache()
@@ -249,10 +250,7 @@
{
Class<?> clazz = loadClassBefore(name);
if (clazz != null)
- {
- globalClassCache.put(path, new ClassCacheItem(clazz));
return clazz;
- }
}
Loader loader = findLoader(classLoader, path, allExports, findInParent);
@@ -273,10 +271,7 @@
{
Class<?> clazz = loadClassAfter(name);
if (clazz != null)
- {
- globalClassCache.put(path, new ClassCacheItem(clazz));
return clazz;
- }
}
// Finally see whether this is the JDK assuming it can load its classes from any classloader
@@ -318,16 +313,16 @@
* Find a loader for a class
*
* @param classLoader the classloader
- * @param name the class resource name
+ * @param path the class resource name
* @param allExports whether we should look at all exports
* @param findInParent should we try the parent
* @return the loader
*/
- Loader findLoader(BaseClassLoader classLoader, String name, boolean allExports, boolean findInParent)
+ Loader findLoader(BaseClassLoader classLoader, String path, boolean allExports, boolean findInParent)
{
boolean trace = log.isTraceEnabled();
if (trace)
- log.trace(this + " findLoader " + name + " classLoader=" + classLoader + " allExports=" + allExports + " findInParent=" + findInParent);
+ log.trace(this + " findLoader " + path + " classLoader=" + classLoader + " allExports=" + allExports + " findInParent=" + findInParent);
if (getClassLoaderSystem() == null)
throw new IllegalStateException("Domain is not registered with a classloader system: " + toLongString());
@@ -335,7 +330,7 @@
// Try the before attempt (e.g. from the parent)
Loader loader = null;
if (findInParent)
- loader = findBeforeLoader(name);
+ loader = findBeforeLoader(path);
if (loader != null)
return loader;
@@ -353,17 +348,17 @@
// Next we try the old "big ball of mud" model
if (allExports)
{
- loader = findLoaderInExports(classLoader, name, trace);
+ loader = findLoaderInExports(classLoader, path, trace);
if (loader != null)
return loader;
}
else if (trace)
- log.trace(this + " not loading " + name + " from all exports");
+ log.trace(this + " not loading " + path + " from all exports");
- // Next we try the imports
+ // Next we try the before imports
if (info != null)
{
- loader = findLoaderInImports(info, name, trace);
+ loader = findLoaderInImports(info, path, ImportType.BEFORE, trace);
if (loader != null)
return loader;
}
@@ -372,14 +367,28 @@
if (classLoader != null)
{
if (trace)
- log.trace(this + " trying to load " + name + " from requesting " + classLoader);
- if (classLoader.getResourceLocally(name) != null)
- return classLoader.getLoader();
+ log.trace(this + " trying to load " + path + " from requesting " + classLoader);
+ if (classLoader.getResourceLocally(path) != null)
+ {
+ loader = classLoader.getLoader();
+ policy = classLoader.getPolicy();
+ if (policy.isCacheable())
+ globalClassCache.put(path, new ClassCacheItem(loader));
+ return loader;
+ }
}
+ // Next we try the after imports
+ if (info != null)
+ {
+ loader = findLoaderInImports(info, path, ImportType.AFTER, trace);
+ if (loader != null)
+ return loader;
+ }
+
// Try the after attempt (e.g. from the parent)
if (findInParent)
- return findAfterLoader(name);
+ return findAfterLoader(path);
return null;
}
@@ -396,6 +405,9 @@
{
boolean trace = log.isTraceEnabled();
+ // TODO -- check why is this different?
+ // TODO -- why only checking for cache and blacklisting in exports?
+
// Try the classloader first
if (classLoader != null)
{
@@ -442,7 +454,7 @@
// Next we try the imports
if (info != null)
{
- result = getResourceFromImports(info, name, trace);
+ result = getResourceFromImports(info, name, ImportType.ALL, trace);
if (result != null)
return result;
}
@@ -495,7 +507,7 @@
// Next we try the imports
if (info != null)
- getResourcesFromImports(info, name, urls, trace);
+ getResourcesFromImports(info, name, urls, ImportType.ALL, trace);
// Finally use any requesting classloader
if (classLoader != null)
@@ -550,10 +562,10 @@
else if (trace)
log.trace(this + " not getting package " + name + " from all exports");
- // Next we try the imports
+ // Next we try the before imports
if (info != null)
{
- result = getPackageFromImports(info, name, trace);
+ result = getPackageFromImports(info, name, ImportType.BEFORE, trace);
if (result != null)
return result;
}
@@ -572,6 +584,14 @@
}
}
+ // Next we try the after imports
+ if (info != null)
+ {
+ result = getPackageFromImports(info, name, ImportType.AFTER, trace);
+ if (result != null)
+ return result;
+ }
+
// Try the after attempt
result = afterGetPackage(name);
if (result != null)
@@ -617,7 +637,7 @@
// Next we try the imports
if (info != null)
- getPackagesFromImports(info, packages, trace);
+ getPackagesFromImports(info, packages, ImportType.ALL, trace);
// Finally use any requesting classloader
if (classLoader != null)
@@ -653,12 +673,13 @@
}
}
- if (globalClassBlackList.containsKey(name))
+ if (isBlackListedClass(name))
{
if (trace)
log.trace(this + " class is black listed " + name);
return null;
}
+
boolean canCache = true;
boolean canBlackList = true;
@@ -689,12 +710,23 @@
}
// Here is not found in the exports so can we blacklist it?
if (canBlackList)
- globalClassBlackList.put(name, name);
+ globalClassBlackList.add(name); // TODO -- why already blacklisting here?
return null;
}
-
+
/**
+ * Check whether this is a black listed class
+ *
+ * @param name the class name
+ * @return true when black listed, false otherwise
+ */
+ protected boolean isBlackListedClass(String name)
+ {
+ return globalClassBlackList.contains(name);
+ }
+
+ /**
* Load a resource from the exports
*
* @param classLoader the classloader
@@ -711,12 +743,13 @@
log.trace(this + " got resource from cache " + name);
}
- if (globalResourceBlackList.containsKey(name))
+ if (globalResourceBlackList.contains(name))
{
if (trace)
log.trace(this + " resource is black listed, not looking at exports " + name);
return null;
}
+
boolean canCache = true;
boolean canBlackList = true;
@@ -748,7 +781,8 @@
}
// Here is not found in the exports so can we blacklist it?
if (canBlackList)
- globalResourceBlackList.put(name, name);
+ globalResourceBlackList.add(name);
+
return null;
}
@@ -829,15 +863,16 @@
/**
* Find a loader for a class in imports
- *
+ *
* @param info the classloader information
* @param name the class resource name
+ * @param type the import type
* @param trace whether trace is enabled
* @return the loader
*/
- Loader findLoaderInImports(ClassLoaderInformation info, String name, boolean trace)
+ Loader findLoaderInImports(ClassLoaderInformation info, String name, ImportType type, boolean trace)
{
- List<? extends DelegateLoader> delegates = info.getDelegates();
+ List<? extends DelegateLoader> delegates = info.getDelegates(type);
if (delegates == null || delegates.isEmpty())
{
if (trace)
@@ -870,7 +905,8 @@
return delegate;
}
}
- info.blackListClass(name);
+ if (type == ImportType.AFTER) // TODO -- is this really OK?
+ info.blackListClass(name);
return null;
}
@@ -879,12 +915,13 @@
*
* @param info the classloader information
* @param name the resource name
+ * @param type the import type
* @param trace whether trace is enabled
* @return the url
*/
- private URL getResourceFromImports(ClassLoaderInformation info, String name, boolean trace)
+ private URL getResourceFromImports(ClassLoaderInformation info, String name, ImportType type, boolean trace)
{
- List<? extends DelegateLoader> delegates = info.getDelegates();
+ List<? extends DelegateLoader> delegates = info.getDelegates(type);
if (delegates == null || delegates.isEmpty())
{
if (trace)
@@ -919,7 +956,8 @@
return result;
}
}
- info.blackListResource(name);
+ if (type == ImportType.AFTER) // TODO -- check
+ info.blackListResource(name);
return null;
}
@@ -929,13 +967,14 @@
* @param info the classloader info
* @param name the resource name
* @param urls the urls to add to
+ * @param type the import type
* @param trace whether trace is enabled
* @throws IOException for any error
*/
// FindBugs: The Set doesn't use equals/hashCode
- void getResourcesFromImports(ClassLoaderInformation info, String name, Set<URL> urls, boolean trace) throws IOException
+ void getResourcesFromImports(ClassLoaderInformation info, String name, Set<URL> urls, ImportType type, boolean trace) throws IOException
{
- List<? extends DelegateLoader> delegates = info.getDelegates();
+ List<? extends DelegateLoader> delegates = info.getDelegates(type);
if (delegates == null || delegates.isEmpty())
{
if (trace)
@@ -953,12 +992,13 @@
*
* @param info the classloader information
* @param name the pacakge name
+ * @param type the import type
* @param trace whether trace is enabled
* @return the package
*/
- private Package getPackageFromImports(ClassLoaderInformation info, String name, boolean trace)
+ private Package getPackageFromImports(ClassLoaderInformation info, String name, ImportType type, boolean trace)
{
- List<? extends DelegateLoader> delegates = info.getDelegates();
+ List<? extends DelegateLoader> delegates = info.getDelegates(type);
if (delegates == null || delegates.isEmpty())
{
if (trace)
@@ -983,11 +1023,12 @@
*
* @param info the classloader info
* @param packages the packages to add to
+ * @param type the import type
* @param trace whether trace is enabled
*/
- void getPackagesFromImports(ClassLoaderInformation info, Set<Package> packages, boolean trace)
+ void getPackagesFromImports(ClassLoaderInformation info, Set<Package> packages, ImportType type, boolean trace)
{
- List<? extends DelegateLoader> delegates = info.getDelegates();
+ List<? extends DelegateLoader> delegates = info.getDelegates(type);
if (delegates == null || delegates.isEmpty())
{
if (trace)
@@ -1499,6 +1540,23 @@
return result;
}
+ public Class<?> checkClassCache(BaseClassLoader classLoader, String name, String path, boolean allExports)
+ {
+ Class<?> result = checkCacheBefore(classLoader, name, path, allExports);
+ if (result != null)
+ return result;
+
+ result = checkCacheAfter(classLoader, name, path, allExports);
+ if (result != null)
+ return result;
+
+ result = checkClassCacheLocally(classLoader, name, path, allExports);
+ if (result != null)
+ return result;
+
+ return null;
+ }
+
/**
* Check the class cache
*
@@ -1508,7 +1566,7 @@
* @param allExports whether to look at all exports
* @return the class if cached
*/
- Class<?> checkClassCache(BaseClassLoader classLoader, String name, String path, boolean allExports)
+ Class<?> checkClassCacheLocally(BaseClassLoader classLoader, String name, String path, boolean allExports)
{
if (allExports)
{
@@ -1516,7 +1574,7 @@
if (item != null)
{
if (log.isTraceEnabled())
- log.trace("Found " + name + " in global cache");
+ log.trace("Found " + name + " in global cache: " + this);
return item.clazz;
}
}
@@ -1539,7 +1597,7 @@
{
if (allExports)
{
- if (failIfBlackListed && globalClassBlackList.containsKey(path))
+ if (failIfBlackListed && isBlackListedClass(path))
{
if (log.isTraceEnabled())
log.trace("Found " + name + " in global blacklist");
@@ -1566,17 +1624,47 @@
{
if (path == null)
path = ClassLoaderUtils.classNameToPath(name);
-
- Class<?> result = checkClassCache(classLoader, name, path, allExports);
- if (result != null)
- return result;
-
+
+ Class<?> cached = checkClassCache(classLoader, name, path, allExports);
+ if (cached != null)
+ return cached;
+
checkClassBlackList(classLoader, name, path, allExports, failIfBlackListed);
return null;
}
/**
+ * Check the cache before checking this domain.
+ * e.g. check parent's domain cache
+ *
+ * @param classLoader the classloader (possibly null)
+ * @param name the name
+ * @param path the path of the class resource
+ * @param allExports whether to look at all exports
+ * @return the class when found in the cache
+ */
+ protected Class<?> checkCacheBefore(BaseClassLoader classLoader, String name, String path, boolean allExports)
+ {
+ return null;
+ }
+
+ /**
+ * Check the cache after checking before domain.
+ * e.g. check parent's domain cache only if this one blacklisted the resource
+ *
+ * @param classLoader the classloader (possibly null)
+ * @param name the name
+ * @param path the path of the class resource
+ * @param allExports whether to look at all exports
+ * @return the class when found in the cache
+ */
+ protected Class<?> checkCacheAfter(BaseClassLoader classLoader, String name, String path, boolean allExports)
+ {
+ return null;
+ }
+
+ /**
* Cleans the entry with the given name from the blackList
*
* @param name the name of the resource to clear from the blackList
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-11 14:53:23 UTC (rev 104685)
+++ projects/jboss-cl/trunk/classloader/src/main/java/org/jboss/classloader/spi/base/BaseDelegateLoader.java 2010-05-11 15:01:13 UTC (rev 104686)
@@ -25,18 +25,19 @@
import java.net.URL;
import java.util.Set;
+import org.jboss.classloader.spi.CacheLoader;
import org.jboss.classloader.spi.ClassLoaderPolicy;
import org.jboss.classloader.spi.ClassLoaderPolicyFactory;
-import org.jboss.classloader.spi.Loader;
import org.jboss.logging.Logger;
/**
* Base DelegateLoader.
*
* @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 $
*/
-public class BaseDelegateLoader implements Loader
+public class BaseDelegateLoader implements CacheLoader
{
/** The log */
private static final Logger log = Logger.getLogger(BaseDelegateLoader.class);
@@ -167,7 +168,19 @@
}
classLoader.getPackagesLocally(packages);
}
-
+
+ public Class<?> checkClassCache(BaseClassLoader classLoader, String name, String path, boolean allExports)
+ {
+ BaseClassLoaderPolicy policy = getPolicy();
+ if (policy != null)
+ {
+ BaseClassLoaderDomain domain = policy.getClassLoaderDomain();
+ if (domain != null)
+ return domain.checkClassCache(classLoader, name, path, allExports);
+ }
+ return null;
+ }
+
/**
* A long version of toString()
*
Modified: projects/jboss-cl/trunk/classloader/src/main/java/org/jboss/classloader/spi/base/ClassLoaderInformation.java
===================================================================
--- projects/jboss-cl/trunk/classloader/src/main/java/org/jboss/classloader/spi/base/ClassLoaderInformation.java 2010-05-11 14:53:23 UTC (rev 104685)
+++ projects/jboss-cl/trunk/classloader/src/main/java/org/jboss/classloader/spi/base/ClassLoaderInformation.java 2010-05-11 15:01:13 UTC (rev 104686)
@@ -22,17 +22,19 @@
package org.jboss.classloader.spi.base;
import java.net.URL;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import org.jboss.classloader.spi.DelegateLoader;
+import org.jboss.classloader.spi.ImportType;
import org.jboss.classloader.spi.Loader;
+import org.jboss.util.collection.ConcurrentSet;
/**
* ClassLoaderInformation.
*
* @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 $
*/
public class ClassLoaderInformation
@@ -47,7 +49,7 @@
private int order;
/** The delegates */
- private List<? extends DelegateLoader> delegates;
+ private Map<ImportType, List<DelegateLoader>> delegates;
/** The exports of the classloader */
private BaseDelegateLoader exported;
@@ -56,13 +58,13 @@
private Map<String, Loader> classCache;
/** The class black list */
- private Map<String, String> classBlackList;
+ private Set<String> classBlackList;
/** The resource cache */
private Map<String, URL> resourceCache;
/** The resource black list */
- private Map<String, String> resourceBlackList;
+ private Set<String> resourceBlackList;
/**
* Create a new ClassLoaderInformation.
@@ -82,16 +84,33 @@
this.policy = policy;
this.order = order;
this.exported = policy.getExported();
- this.delegates = policy.getDelegates();
boolean canCache = policy.isCacheable();
boolean canBlackList = policy.isBlackListable();
+
+ List<? extends DelegateLoader> delegates = policy.getDelegates();
if (delegates != null && delegates.isEmpty() == false)
{
+ this.delegates = new HashMap<ImportType, List<DelegateLoader>>();
+ // prepare ALL
+ List<DelegateLoader> all = new ArrayList<DelegateLoader>();
+ this.delegates.put(ImportType.ALL, all);
+
for (DelegateLoader delegate : delegates)
{
if (delegate == null)
throw new IllegalStateException(policy + " null delegate in " + delegates);
+
+ ImportType importType = delegate.getImportType();
+ List<DelegateLoader> loaders = this.delegates.get(importType);
+ if (loaders == null)
+ {
+ loaders = new ArrayList<DelegateLoader>();
+ this.delegates.put(importType, loaders);
+ }
+ loaders.add(delegate); // add to specific type
+ all.add(delegate); // add to all
+
BaseDelegateLoader baseDelegate = delegate;
BaseClassLoaderPolicy delegatePolicy = baseDelegate.getPolicy();
if (delegatePolicy == null || delegatePolicy.isCacheable() == false)
@@ -109,8 +128,8 @@
if (canBlackList)
{
- classBlackList = new ConcurrentHashMap<String, String>();
- resourceBlackList = new ConcurrentHashMap<String, String>();
+ classBlackList = new ConcurrentSet<String>();
+ resourceBlackList = new ConcurrentSet<String>();
}
}
@@ -173,13 +192,29 @@
* Get the delegates.
*
* @return the delegates.
+ * @deprecated use same method with import type parameter
*/
+ @Deprecated
public List<? extends DelegateLoader> getDelegates()
{
- return delegates;
+ return getDelegates(ImportType.BEFORE);
}
/**
+ * Get the delegates.
+ *
+ * @param type the import type
+ * @return the delegates.
+ */
+ public List<? extends DelegateLoader> getDelegates(ImportType type)
+ {
+ if (delegates == null)
+ return Collections.emptyList();
+
+ return delegates.get(type);
+ }
+
+ /**
* Get the cached loader for a class
*
* @param name the class name
@@ -214,10 +249,8 @@
*/
public boolean isBlackListedClass(String name)
{
- Map<String, String> classBlackList = this.classBlackList;
- if (classBlackList != null)
- return classBlackList.containsKey(name);
- return false;
+ Set<String> classBlackList = this.classBlackList;
+ return classBlackList != null && classBlackList.contains(name);
}
/**
@@ -227,9 +260,9 @@
*/
public void blackListClass(String name)
{
- Map<String, String> classBlackList = this.classBlackList;
+ Set<String> classBlackList = this.classBlackList;
if (classBlackList != null)
- classBlackList.put(name, name);
+ classBlackList.add(name);
}
/**
@@ -267,10 +300,8 @@
*/
public boolean isBlackListedResource(String name)
{
- Map<String, String> resourceBlackList = this.resourceBlackList;
- if (resourceBlackList != null)
- return resourceBlackList.containsKey(name);
- return false;
+ Set<String> resourceBlackList = this.resourceBlackList;
+ return resourceBlackList != null && resourceBlackList.contains(name);
}
/**
@@ -280,9 +311,9 @@
*/
public void blackListResource(String name)
{
- Map<String, String> resourceBlackList = this.resourceBlackList;
+ Set<String> resourceBlackList = this.resourceBlackList;
if (resourceBlackList != null)
- resourceBlackList.put(name, name);
+ resourceBlackList.add(name);
}
/**
Modified: projects/jboss-cl/trunk/classloader/src/test/java/org/jboss/test/classloader/domain/test/CustomParentLoaderUnitTestCase.java
===================================================================
--- projects/jboss-cl/trunk/classloader/src/test/java/org/jboss/test/classloader/domain/test/CustomParentLoaderUnitTestCase.java 2010-05-11 14:53:23 UTC (rev 104685)
+++ projects/jboss-cl/trunk/classloader/src/test/java/org/jboss/test/classloader/domain/test/CustomParentLoaderUnitTestCase.java 2010-05-11 15:01:13 UTC (rev 104686)
@@ -21,21 +21,13 @@
*/
package org.jboss.test.classloader.domain.test;
+import javax.management.MBeanRegistration;
+
import java.util.HashSet;
import java.util.Set;
-import javax.management.MBeanRegistration;
-
-import junit.framework.Test;
-
import org.jboss.classloader.plugins.ClassLoaderUtils;
-import org.jboss.classloader.spi.ClassFoundHandler;
-import org.jboss.classloader.spi.ClassLoaderDomain;
-import org.jboss.classloader.spi.ClassLoaderDomainMBean;
-import org.jboss.classloader.spi.ClassLoaderSystem;
-import org.jboss.classloader.spi.ClassNotFoundHandler;
-import org.jboss.classloader.spi.Loader;
-import org.jboss.classloader.spi.ParentPolicy;
+import org.jboss.classloader.spi.*;
import org.jboss.classloader.spi.base.BaseClassLoaderDomain;
import org.jboss.classloader.spi.filter.ClassFilterUtils;
import org.jboss.classloader.test.support.MockClassLoaderPolicy;
@@ -43,6 +35,8 @@
import org.jboss.test.classloader.domain.support.MockLoader;
import org.jboss.test.classloader.domain.support.NoMatchClassFilter;
+import junit.framework.Test;
+
/**
* ParentPolicyUnitTestCase.
*
@@ -161,7 +155,7 @@
ClassLoader classLoader = system.registerClassLoaderPolicy(domain, policy);
assertLoadClass(ClassLoaderDomain.class, classLoader);
- checkGetResource(loader, ClassLoaderDomain.class, BaseClassLoaderDomain.class, ClassLoaderDomainMBean.class, MBeanRegistration.class, Loader.class, ClassNotFoundHandler.class, ClassFoundHandler.class, Object.class);
+ checkGetResource(loader, ClassLoaderDomain.class, BaseClassLoaderDomain.class, ClassLoaderDomainMBean.class, MBeanRegistration.class, Loader.class, CacheLoader.class, ClassNotFoundHandler.class, ClassFoundHandler.class, Object.class);
checkLoadClass(loader);
}
Modified: projects/jboss-cl/trunk/classloading/src/main/java/org/jboss/classloading/spi/dependency/Module.java
===================================================================
--- projects/jboss-cl/trunk/classloading/src/main/java/org/jboss/classloading/spi/dependency/Module.java 2010-05-11 14:53:23 UTC (rev 104685)
+++ projects/jboss-cl/trunk/classloading/src/main/java/org/jboss/classloading/spi/dependency/Module.java 2010-05-11 15:01:13 UTC (rev 104686)
@@ -25,49 +25,30 @@
import java.net.URL;
import java.security.AccessController;
import java.security.PrivilegedAction;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.HashSet;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.CopyOnWriteArraySet;
-import org.jboss.classloader.spi.ClassLoaderSystem;
-import org.jboss.classloader.spi.DelegateLoader;
-import org.jboss.classloader.spi.ParentPolicy;
-import org.jboss.classloader.spi.ShutdownPolicy;
+import org.jboss.classloader.spi.*;
import org.jboss.classloader.spi.base.BaseClassLoader;
import org.jboss.classloader.spi.filter.ClassFilter;
import org.jboss.classloading.plugins.metadata.PackageCapability;
import org.jboss.classloading.plugins.metadata.PackageRequirement;
import org.jboss.classloading.spi.helpers.NameAndVersionSupport;
-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.metadata.ExportPackages;
-import org.jboss.classloading.spi.metadata.OptionalPackages;
-import org.jboss.classloading.spi.metadata.Requirement;
+import org.jboss.classloading.spi.metadata.*;
import org.jboss.classloading.spi.visitor.ResourceFilter;
import org.jboss.classloading.spi.visitor.ResourceVisitor;
import org.jboss.dependency.plugins.ResolvedState;
-import org.jboss.dependency.spi.Controller;
-import org.jboss.dependency.spi.ControllerContext;
-import org.jboss.dependency.spi.ControllerState;
-import org.jboss.dependency.spi.DependencyInfo;
-import org.jboss.dependency.spi.DependencyItem;
+import org.jboss.dependency.spi.*;
import org.jboss.logging.Logger;
/**
* Module.
*
* @author <a href="adrian at jboss.org">Adrian Brock</a>
+ * @author <a href="ales.justin at jboss.org">Ales Justin</a>
* @version $Revision: 1.1 $
*/
public abstract class Module extends NameAndVersionSupport
@@ -744,6 +725,7 @@
if (requirement.isDynamic())
{
DelegateLoader delegate = createLazyDelegateLoader(checkDomain(), item);
+ delegate.setImportType(getImportType(requirement));
dynamic.add(delegate);
continue;
}
@@ -788,7 +770,8 @@
// Determine the delegate loader for the module
DelegateLoader delegate = iDependOnModule.getDelegateLoader(module, requirement);
if (delegate == null)
- throw new IllegalStateException("Cannot obtain delegate for: " + requirement);
+ throw new IllegalStateException("Cannot obtain delegate for: " + requirement);
+ delegate.setImportType(getImportType(requirement));
delegates.add(delegate);
}
}
@@ -805,6 +788,23 @@
}
/**
+ * Get requirement's import type.
+ * By default we return BEFORE.
+ *
+ * @param requirement the requirement to check
+ * @return requirement's import type
+ */
+ protected static ImportType getImportType(Requirement requirement)
+ {
+ if (requirement instanceof RequirementWithImportType)
+ {
+ RequirementWithImportType rwit = (RequirementWithImportType) requirement;
+ return rwit.getImportType();
+ }
+ return ImportType.BEFORE;
+ }
+
+ /**
* Create a lazy delegate loader
*
* @param domain the domain
Copied: projects/jboss-cl/trunk/classloading/src/main/java/org/jboss/classloading/spi/metadata/RequirementWithImportType.java (from rev 104077, projects/jboss-cl/trunk/classloading/src/main/java/org/jboss/classloading/spi/metadata/Requirement.java)
===================================================================
--- projects/jboss-cl/trunk/classloading/src/main/java/org/jboss/classloading/spi/metadata/RequirementWithImportType.java (rev 0)
+++ projects/jboss-cl/trunk/classloading/src/main/java/org/jboss/classloading/spi/metadata/RequirementWithImportType.java 2010-05-11 15:01:13 UTC (rev 104686)
@@ -0,0 +1,41 @@
+/*
+ * 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.classloading.spi.metadata;
+
+import org.jboss.classloader.spi.ImportType;
+
+/**
+ * Requirement with import type.
+ *
+ * TODO -- remove this mixin interface with next major version
+ *
+ * @author <a href="ales.justin at jboss.org">Ales Justin</a>
+ */
+public interface RequirementWithImportType extends Requirement
+{
+ /**
+ * Get import type.
+ *
+ * @return the import type.
+ */
+ ImportType getImportType();
+}
\ No newline at end of file
Modified: projects/jboss-cl/trunk/classloading/src/main/java/org/jboss/classloading/spi/metadata/helpers/AbstractRequirement.java
===================================================================
--- projects/jboss-cl/trunk/classloading/src/main/java/org/jboss/classloading/spi/metadata/helpers/AbstractRequirement.java 2010-05-11 14:53:23 UTC (rev 104685)
+++ projects/jboss-cl/trunk/classloading/src/main/java/org/jboss/classloading/spi/metadata/helpers/AbstractRequirement.java 2010-05-11 15:01:13 UTC (rev 104686)
@@ -23,17 +23,20 @@
import javax.xml.bind.annotation.XmlAttribute;
+import org.jboss.classloader.spi.ImportType;
import org.jboss.classloading.spi.helpers.NameAndVersionRangeSupport;
import org.jboss.classloading.spi.metadata.Requirement;
+import org.jboss.classloading.spi.metadata.RequirementWithImportType;
import org.jboss.classloading.spi.version.VersionRange;
/**
* AbstractRequirement.
*
* @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 $
*/
-public class AbstractRequirement extends NameAndVersionRangeSupport implements Requirement
+public class AbstractRequirement extends NameAndVersionRangeSupport implements RequirementWithImportType
{
/** The serialVersionUID */
private static final long serialVersionUID = -7898148730704557596L;
@@ -46,7 +49,10 @@
/** Whether to re-export */
private boolean reExport = false;
-
+
+ /** The import type */
+ private ImportType importType = ImportType.BEFORE;
+
/**
* Create a new AbstractRequirement
*/
@@ -129,7 +135,18 @@
{
this.reExport = reExport;
}
-
+
+ public ImportType getImportType()
+ {
+ return importType;
+ }
+
+ @XmlAttribute(name = "importType")
+ public void setImportType(ImportType importType)
+ {
+ this.importType = importType;
+ }
+
public boolean isConsistent(Requirement other)
{
return isConsistent(other, null);
Modified: projects/jboss-cl/trunk/classloading-vfs/src/main/resources/schema/jboss-classloading-1.0.xsd
===================================================================
--- projects/jboss-cl/trunk/classloading-vfs/src/main/resources/schema/jboss-classloading-1.0.xsd 2010-05-11 14:53:23 UTC (rev 104685)
+++ projects/jboss-cl/trunk/classloading-vfs/src/main/resources/schema/jboss-classloading-1.0.xsd 2010-05-11 15:01:13 UTC (rev 104686)
@@ -345,6 +345,15 @@
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
+ <xsd:attribute name="importType" type="xsd:string" use="optional">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ Define requirements import type.
+ ]]>
+ </xsd:documentation>
+ </xsd:annotation>
+ </xsd:attribute>
</xsd:complexType>
<xsd:simpleType name="version">
Modified: projects/jboss-cl/trunk/pom.xml
===================================================================
--- projects/jboss-cl/trunk/pom.xml 2010-05-11 14:53:23 UTC (rev 104685)
+++ projects/jboss-cl/trunk/pom.xml 2010-05-11 15:01:13 UTC (rev 104686)
@@ -33,14 +33,14 @@
<version.jboss.vfs>3.0.0.CR3</version.jboss.vfs>
<version.jboss.man>2.1.1.SP1</version.jboss.man>
<version.jboss.mdr>2.2.0.Alpha2</version.jboss.mdr>
- <version.jboss.kernel>2.2.0-SNAPSHOT</version.jboss.kernel>
+ <version.jboss.kernel>2.2.0.Alpha10</version.jboss.kernel>
<version.jboss.common.core>2.2.17.GA</version.jboss.common.core>
<version.jboss.logging.spi>2.2.0.CR1</version.jboss.logging.spi>
<version.jboss.classloading.spi>6.0.0-Alpha8</version.jboss.classloading.spi>
<version.jbossxb>2.0.2.Beta6</version.jbossxb>
<version.org.jboss.test>1.1.5.GA</version.org.jboss.test>
<version.junit>4.4</version.junit>
- <version.javassist>3.12.0-SNAPSHOT</version.javassist>
+ <version.javassist>3.12.0.GA</version.javassist>
</properties>
<build>
More information about the jboss-cvs-commits
mailing list