org.jboss.classloader.test.support
Class MockClassLoaderPolicy

java.lang.Object
  extended by org.jboss.classloader.spi.base.BaseClassLoaderPolicy
      extended by org.jboss.classloader.spi.ClassLoaderPolicy
          extended by org.jboss.classloader.test.support.MockClassLoaderPolicy

public class MockClassLoaderPolicy
extends ClassLoaderPolicy

MockClassLoaderPolicy.

Version:
$Revision: 1.1 $
Author:
Adrian Brock

Constructor Summary
MockClassLoaderPolicy()
          Create a new MockClassLoaderPolicy filtering org.jboss.* classes with logical name "mock"
MockClassLoaderPolicy(String name)
          Create a new MockClassLoaderPolicy filtering org.jboss.* classes
MockClassLoaderPolicy(String name, ClassFilter nonJDKFilter)
          Create a new MockClassLoaderPolicy filtering the given patterns
MockClassLoaderPolicy(String name, String[] classPatterns, String[] resourcePatterns, String[] packagePatterns)
          Create a new MockClassLoaderPolicy filtering org.jboss.* classes
 
Method Summary
 List<? extends DelegateLoader> getDelegates()
          Get the delegate loaders for imported stuff
 String getName()
          Get a simple name for the classloader
 ObjectName getObjectName()
          Get the object name the classloader is registered in the MBeanServer with
 PackageInformation getPackageInformation(String packageName)
          Get the package information
 String[] getPackageNames()
          Get the exported packages
 String[] getPaths()
          Get the paths to expose
 String getPrefix()
          Get the prefix.
protected  ProtectionDomain getProtectionDomain(String className, String path)
          Get the protection domain
 URL getResource(String path)
          Get the resource
 void getResources(String path, Set<URL> urls)
          Get resources
 boolean isImportAll()
          Whether to import all exports from other classloaders in the domain
protected  ClassLoader isJDKRequest(String name)
          Check whether this a request from the jdk if it is return the relevant classloader
 void setDelegates(List<? extends DelegateLoader> delegates)
          Set the delegates
 void setExcluded(Class<?>... classes)
          Set the excluded classes
 void setExcluded(String... excluded)
          Set the excluded classes
 void setImportAll(boolean importAll)
          Set the importAll.
 void setIncluded(Class<?>... classes)
          Set the included classes
 void setIncluded(String... included)
          Set the included classes
 void setPackageNames(Class<?>... classes)
          Set the exported package names
 void setPackageNames(String... packageNames)
          Set the exported package names
 void setPath(String path)
          Set the path to expose
 void setPaths(Class<?>... classes)
          Set the paths to expose
 void setPaths(String... paths)
          Set the paths to expose
 void setPathsAndPackageNames(Class<?>... classes)
          Set the paths and the exported package names
 void setPathsAndPackageNames(String... packages)
          Set the paths and the exported package names
 void setPrefix(String prefix)
          Set the prefix.
 void toLongString(StringBuilder builder)
          For subclasses to add information for toLongString()
 String toString()
           
 
Methods inherited from class org.jboss.classloader.spi.ClassLoaderPolicy
getClassPackageInformation, getExported, getResourceAsStream, isBlackListable, isCacheable
 
Methods inherited from class org.jboss.classloader.spi.base.BaseClassLoaderPolicy
addTranslator, clearBlackList, getAccessControlContext, getDomainName, getTranslators, removeTranslator, setTranslators, shutdownPolicy, toLongString, transform
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MockClassLoaderPolicy

public MockClassLoaderPolicy()
Create a new MockClassLoaderPolicy filtering org.jboss.* classes with logical name "mock"


MockClassLoaderPolicy

public MockClassLoaderPolicy(String name)
Create a new MockClassLoaderPolicy filtering org.jboss.* classes

Parameters:
name - the logical name of the policy

MockClassLoaderPolicy

public MockClassLoaderPolicy(String name,
                             String[] classPatterns,
                             String[] resourcePatterns,
                             String[] packagePatterns)
Create a new MockClassLoaderPolicy filtering org.jboss.* classes

Parameters:
name - the name
classPatterns - the class patterns
resourcePatterns - the resourcePatterns
packagePatterns - the packagePatterns

MockClassLoaderPolicy

public MockClassLoaderPolicy(String name,
                             ClassFilter nonJDKFilter)
Create a new MockClassLoaderPolicy filtering the given patterns

Parameters:
name - the logical name of the policy
nonJDKFilter - the filter for nonJDK classes
Throws:
IllegalArgumentException - for a null filter
Method Detail

getName

public String getName()
Description copied from class: BaseClassLoaderPolicy
Get a simple name for the classloader

Overrides:
getName in class BaseClassLoaderPolicy
Returns:
the name

getDelegates

public List<? extends DelegateLoader> getDelegates()
Description copied from class: ClassLoaderPolicy
Get the delegate loaders for imported stuff

There are no imports by default

NOTE: Protected access for security reasons

Overrides:
getDelegates in class ClassLoaderPolicy
Returns:
the delegate loaders

setDelegates

public void setDelegates(List<? extends DelegateLoader> delegates)
Set the delegates

Parameters:
delegates - the delegate imports

getPrefix

public String getPrefix()
Get the prefix.

Returns:
the prefix.

setPrefix

public void setPrefix(String prefix)
Set the prefix.

Parameters:
prefix - the prefix.

getPaths

public String[] getPaths()
Get the paths to expose

Returns:
the paths

setPath

public void setPath(String path)
Set the path to expose

Parameters:
path - the path

setPaths

public void setPaths(String... paths)
Set the paths to expose

Parameters:
paths - the paths to expose

setPaths

public void setPaths(Class<?>... classes)
Set the paths to expose

Parameters:
classes - the classes to reference to determine the package paths

getPackageNames

public String[] getPackageNames()
Description copied from class: ClassLoaderPolicy
Get the exported packages

Provides a hint for indexing

No packages are exported by default

The returned package names can be null to indicate nothing is exported, but if an array is returned it should not include a null package element.

Overrides:
getPackageNames in class ClassLoaderPolicy
Returns:
the package names

setPackageNames

public void setPackageNames(String... packageNames)
Set the exported package names

Parameters:
packageNames - the exported packages

setPackageNames

public void setPackageNames(Class<?>... classes)
Set the exported package names

Parameters:
classes - the classes to reference to determine the package names

setIncluded

public void setIncluded(String... included)
Set the included classes

Parameters:
included - the classes to include from the paths

setIncluded

public void setIncluded(Class<?>... classes)
Set the included classes

Parameters:
classes - the classes to include from the paths

setExcluded

public void setExcluded(String... excluded)
Set the excluded classes

Parameters:
excluded - the classes to include from the paths

setExcluded

public void setExcluded(Class<?>... classes)
Set the excluded classes

Parameters:
classes - the classes to exclude from the paths

setPathsAndPackageNames

public void setPathsAndPackageNames(Class<?>... classes)
Set the paths and the exported package names

Parameters:
classes - the classes to reference

setPathsAndPackageNames

public void setPathsAndPackageNames(String... packages)
Set the paths and the exported package names

Parameters:
packages - the packages

isImportAll

public boolean isImportAll()
Description copied from class: ClassLoaderPolicy
Whether to import all exports from other classloaders in the domain

False by default

Overrides:
isImportAll in class ClassLoaderPolicy
Returns:
true to import all

setImportAll

public void setImportAll(boolean importAll)
Set the importAll.

Parameters:
importAll - the importAll.

getResource

public URL getResource(String path)
Description copied from class: ClassLoaderPolicy
Get the resource

Specified by:
getResource in class ClassLoaderPolicy
Parameters:
path - the path
Returns:
the url or null if not found

getResources

public void getResources(String path,
                         Set<URL> urls)
                  throws IOException
Description copied from class: ClassLoaderPolicy
Get resources

Specified by:
getResources in class ClassLoaderPolicy
Parameters:
path - the resource name
urls - the list of urls to add to
Throws:
IOException - for any error

getProtectionDomain

protected ProtectionDomain getProtectionDomain(String className,
                                               String path)
Description copied from class: ClassLoaderPolicy
Get the protection domain

By default there is no protection domain

NOTE: Protected access for security reasons

Overrides:
getProtectionDomain in class ClassLoaderPolicy
Parameters:
className - the class name
path - the path
Returns:
the protection domain

getPackageInformation

public PackageInformation getPackageInformation(String packageName)
Description copied from class: ClassLoaderPolicy
Get the package information

There is no package information by default

Overrides:
getPackageInformation in class ClassLoaderPolicy
Parameters:
packageName - the package information
Returns:
the information or null if there is none

isJDKRequest

protected ClassLoader isJDKRequest(String name)
Description copied from class: ClassLoaderPolicy
Check whether this a request from the jdk if it is return the relevant classloader

By default this uses the and returns the system classloader if true.

Overrides:
isJDKRequest in class ClassLoaderPolicy
Parameters:
name - the class name
Returns:
the classloader

getObjectName

public ObjectName getObjectName()
Description copied from class: BaseClassLoaderPolicy
Get the object name the classloader is registered in the MBeanServer with

Overrides:
getObjectName in class ClassLoaderPolicy
Returns:
the object name

toLongString

public void toLongString(StringBuilder builder)
Description copied from class: BaseClassLoaderPolicy
For subclasses to add information for toLongString()

Overrides:
toLongString in class ClassLoaderPolicy
Parameters:
builder - the builder

toString

public String toString()
Overrides:
toString in class BaseClassLoaderPolicy


Copyright © 2011 JBoss, a division of Red Hat, Inc.. All Rights Reserved.