classpathhelper
Interface CGClassLoaderFilter

All Known Implementing Classes:
CGClassLoaderFilterAdapter

public interface CGClassLoaderFilter

Filtering class used by CGClassLoader to determine if it should include a class store on its class path as well as a filter for changing the search order of specific classes. In some cases (such as the J2EE servlet spec and WEB-INF/lib jars containing javax.servlet.* classes) a class loader should ignore certain jars (or ClassStores).

Instances of this filter are also used to determine if a resource (or class) should have its blocked location or unresolved references calculated.

The use of this filter will not effect whether or not a location is returned by CGClassLoader.getLocations(), but it will effect the Location.isIgnored() value.

Usage

Implementations of this inteface can be passed into some of the constructors for CGClassLoader.

Since:
1.0
Author:
bharris

Method Summary
 boolean acceptItem(CGClassLoader classLoader, ClassStore classStore)
          Filtering method used to determine if a class store should be allowed by the classloader.
 boolean allowInUnresolved(CGClassLoader classLoader, java.lang.String className)
          Method used to indicate that a class should not be added as unresolved.
 boolean allowsHasBlocked(CGClassLoader classLoader, java.lang.String resourceName)
          Method used to indicate if the resource with the supplied name should have its blocked byte code values calculated.
 boolean invertSearchOrder(CGClassLoader classLoader, java.lang.String className)
          Filtering method used to allow some classes to invert the classloading search order for specific classes.
 

Method Detail

acceptItem

public boolean acceptItem(CGClassLoader classLoader,
                          ClassStore classStore)

Filtering method used to determine if a class store should be allowed by the classloader.

This method is called during initial construction to determine which class stores and locations to include. It is not called when looking up classes or ClassDetails.

Parameters:
classLoader - The classloader where this class store resides.
classStore - The ClassStore.
Returns:
true If this class store should be included on the classpath, otherwise false.
Since:
1.0

invertSearchOrder

public boolean invertSearchOrder(CGClassLoader classLoader,
                                 java.lang.String className)

Filtering method used to allow some classes to invert the classloading search order for specific classes. The practical application of this filtering method is to allow some classes (such as XML parsers) to be searched via the parent classloader even if the classloader is configured to search itself first.

The prefix invert is used to indicate that classes accepted by this filtering method will have the opposite searching order as to that of the class loader. So if a class loader is configured to search itself before its parents an invertedSearchOrder class will search the parent first. If a class loader is configured to search its parent first (the default) an invertedSearchOrder will search the class loader first.

Parameters:
classLoader - The class loader this class is being looked up in.
className - The class to look for inverted searching.
Returns:
true If the classes search order should be inverted, otherwise false.
Since:
1.0

allowsHasBlocked

public boolean allowsHasBlocked(CGClassLoader classLoader,
                                java.lang.String resourceName)

Method used to indicate if the resource with the supplied name should have its blocked byte code values calculated. In some cases (such as META-INF/MANIFEST.MF blocked bytes are not relavent because that resource is loaded via ClassLoader.getResources(String).

Parameters:
classLoader - The class loader this filter applies to.
resourceName - The name of the resource (since using resources, class names appear as package1/package2/SomeClass.class not package1.package2.SomeClass
Returns:
true if this resource should have blocked info calculated otherwise, false
Since:
1.1

allowInUnresolved

public boolean allowInUnresolved(CGClassLoader classLoader,
                                 java.lang.String className)

Method used to indicate that a class should not be added as unresolved. In cases where a class is known not to exist (or its non existence is not important), this will allow the class to not appear as unresolved.

Parameters:
classLoader - The class loader the class is from.
className - The name of the class not to add as unresolved.
Returns:
true if this class is allowed to be in other classes unresolved list. Otherwise, false.
Since:
1.1