org.ow2.jonas.lib.loader
Class FilteringClassLoader

java.lang.Object
  extended by java.lang.ClassLoader
      extended by java.security.SecureClassLoader
          extended by java.net.URLClassLoader
              extended by org.ow2.jonas.lib.loader.FilteringClassLoader

public class FilteringClassLoader
extends URLClassLoader

ClassLoader that allows to filter the classes or resources that are loaded.
It is extending URLClassLoader as for example Tomcat is looking for getURLs() method, etc.

Author:
Florent Benoit

Field Summary
static String CLASSLOADER_FILTERING_FILE
          Name of the XML file inside modules.
static String DISABLE_FILTERING_PROPERTY_NAME
          System property for disabling the Filtering.
static String MAPPING_FILE
          Mapping file of the XML file.
static String XML_FILE
          Name of the XML file.
 
Constructor Summary
FilteringClassLoader(ClassLoader parentClassLoader)
          Build a new filtering classloader by using the given parent classloader.
 
Method Summary
 URL getDefinitionUrl()
           
 List<String> getFilters()
           
 URL getResource(String name)
          Find the given resource specified by its name.
protected  boolean isFiltered(String name)
          Detects if the given class/resource should be filtered or not.
 boolean isTransparent()
           
 Class<?> loadClass(String name, boolean resolve)
          Loads the class if it is not filtered.
 void setDefinitionUrl(URL definitionUrl)
           
 void setFiltersDefinition(FiltersDefinition filters)
          Sets the filters definition element.
 void setTransparent(boolean transparent)
           
 void start()
           
 
Methods inherited from class java.net.URLClassLoader
addURL, definePackage, findClass, findResource, findResources, getPermissions, getURLs, newInstance, newInstance
 
Methods inherited from class java.security.SecureClassLoader
defineClass, defineClass
 
Methods inherited from class java.lang.ClassLoader
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findLibrary, findLoadedClass, findSystemClass, getPackage, getPackages, getParent, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, resolveClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLASSLOADER_FILTERING_FILE

public static final String CLASSLOADER_FILTERING_FILE
Name of the XML file inside modules.

See Also:
Constant Field Values

XML_FILE

public static final String XML_FILE
Name of the XML file.

See Also:
Constant Field Values

MAPPING_FILE

public static final String MAPPING_FILE
Mapping file of the XML file.

See Also:
Constant Field Values

DISABLE_FILTERING_PROPERTY_NAME

public static final String DISABLE_FILTERING_PROPERTY_NAME
System property for disabling the Filtering.

See Also:
Constant Field Values
Constructor Detail

FilteringClassLoader

public FilteringClassLoader(ClassLoader parentClassLoader)
Build a new filtering classloader by using the given parent classloader.

Parameters:
parentClassLoader - the given parent classloader
Method Detail

isTransparent

public boolean isTransparent()

setTransparent

public void setTransparent(boolean transparent)

getDefinitionUrl

public URL getDefinitionUrl()

setDefinitionUrl

public void setDefinitionUrl(URL definitionUrl)

start

public void start()

loadClass

public Class<?> loadClass(String name,
                          boolean resolve)
                   throws ClassNotFoundException
Loads the class if it is not filtered.

Overrides:
loadClass in class ClassLoader
Parameters:
name - the name of the class.
resolve - if true, resolve the class
Returns:
The resulting Class object
Throws:
ClassNotFoundException - If the class was not found or if it is filtered

getResource

public URL getResource(String name)
Find the given resource specified by its name.

Overrides:
getResource in class ClassLoader
Parameters:
name - the resource name
Returns:
the URL if the resource has been found, else null

isFiltered

protected boolean isFiltered(String name)
Detects if the given class/resource should be filtered or not.

Parameters:
name - the name of the class
Returns:
true if it should be filtered, else false

getFilters

public List<String> getFilters()
Returns:
a cloned filter list (so that it cannot be changed after the start-up).

setFiltersDefinition

public void setFiltersDefinition(FiltersDefinition filters)
Sets the filters definition element.

Parameters:
filters - the filters definition element.


Copyright © 2010 OW2 Consortium. All Rights Reserved.