org.jboss.classloader.test.support
Class IsolatedClassLoaderTestHelper

java.lang.Object
  extended by org.jboss.classloader.test.support.IsolatedClassLoaderTestHelper

public class IsolatedClassLoaderTestHelper
extends Object

IsolatedClassLoaderTestHelper.

Version:
$Revision: 1.1 $
Author:
Adrian Brock

Constructor Summary
IsolatedClassLoaderTestHelper()
           
 
Method Summary
 ClassLoader createClassLoader(ClassLoaderDomain domain, MockClassLoaderPolicy policy)
          Create a classloader
 ClassLoader createClassLoader(MockClassLoaderPolicy policy)
          Create a classloader
 ClassLoader createClassLoader(String name, boolean importAll, String... packages)
          Create a classloader It exports everything
 ClassLoader createClassLoader(String domainName, MockClassLoaderPolicy policy)
          Create a classloader
 List<? extends DelegateLoader> createDefaultDelegates()
          Create the default delegate loader
 List<? extends DelegateLoader> createDelegates(ClassLoaderPolicy... policies)
          Create delegate loaders from policies
 ClassLoaderDomain createScopedClassLoaderDomain(String name, ParentPolicy parentPolicy)
          Create a scoped classloader domain using the test domain as parent
 ClassLoaderDomain createScopedClassLoaderDomain(String name, ParentPolicy parentPolicy, Loader parent)
          Create a scoped classloader domain
 ClassLoaderDomain createScopedClassLoaderDomainParentFirst(String name)
          Create a scoped classloader domain using the test domain as parent using the parent first policy
 ClassLoaderDomain createScopedClassLoaderDomainParentLast(String name)
          Create a scoped classloader domain using the test domain as parent using the parent last policy
 ClassLoaderDomain getDomain()
          Get the domain.
static Set<String> getParentPackages()
          Get the packages that should not be isolated (and by transience their dependent classes, e.g.
 ClassLoaderPolicy getPolicy()
          Get the policy.
 ClassLoaderSystem getSystem()
          Get the system.
 Class<?> initializeClassLoader(Class<?> clazz, boolean importAll, Class<?>... packages)
          Initialize the classloader system
 Class<?> initializeClassLoader(Class<?> clazz, ClassFilter parentFilter, boolean importAll, Class<?>... packages)
          Initialize the classloader system
 Class<?> initializeClassLoader(Class<?> clazz, ClassFilter parentFilter, ClassLoaderPolicy policy)
          Initialize the classloader system
 Class<?> initializeClassLoader(Class<?> clazz, ClassLoaderPolicy policy)
          Initialize the classloader system
 Class<?> initializeClassLoader(Class<?> clazz, ClassLoaderSystem system, ClassFilter beforeFilter, ClassFilter afterFilter, ClassLoaderPolicy policy)
          Initialize the classloader system
 Class<?> initializeClassLoader(Class<?> clazz, ClassLoaderSystem system, ClassFilter parentFilter, ClassLoaderPolicy policy)
          Initialize the classloader system
 Class<?> initializeClassLoader(Class<?> clazz, ClassLoaderSystem system, ClassLoaderDomain domain, ClassLoaderPolicy policy)
          Initialize the classloader system
 Class<?> initializeClassLoader(Class<?> clazz, ClassLoaderSystem system, ClassLoaderPolicy policy)
          Initialize the classloader system
 Class<?> initializeClassLoader(Class<?> clazz, ClassLoaderSystem system, ClassLoaderPolicy policy, Set<String> parentPackages)
          Initialize the classloader system
 Class<?> initializeClassLoader(Class<?> clazz, ClassLoaderSystem system, ClassLoaderPolicy policy, String... parentPackages)
          Initialize the classloader system
 Class<?> initializeClassLoader(Class<?> clazz, ClassLoaderSystem system, ParentPolicy parentPolicy, ClassLoaderPolicy policy)
          Initialize the classloader system
 void setPolicy(ClassLoaderPolicy policy)
          Set the policy.
 void unregisterClassLoader(ClassLoader classLoader)
          Unregister a classloader
 void unregisterDomain(String name)
          Unregister a domain
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IsolatedClassLoaderTestHelper

public IsolatedClassLoaderTestHelper()
Method Detail

getDomain

public ClassLoaderDomain getDomain()
Get the domain.

Returns:
the domain.

getSystem

public ClassLoaderSystem getSystem()
Get the system.

Returns:
the system.

getPolicy

public ClassLoaderPolicy getPolicy()
Get the policy.

Returns:
the policy.

setPolicy

public void setPolicy(ClassLoaderPolicy policy)
Set the policy.

Parameters:
policy - the policy.

getParentPackages

public static Set<String> getParentPackages()
Get the packages that should not be isolated (and by transience their dependent classes, e.g. log4j in the classpath)

NOTE: The transient packages cannot be used directly by the test unless explicity mentioned in this list. The list can be expanded by using the jboss.test.parent.pkgs system property with a comma-separated list of package names, e.g.
-Djboss.test.parent.pkgs=org.jboss.package1, org.jboss.package2

Returns:
the test support packages

initializeClassLoader

public Class<?> initializeClassLoader(Class<?> clazz,
                                      boolean importAll,
                                      Class<?>... packages)
Initialize the classloader system

Parameters:
clazz - the original clazz
importAll - whether to import all
packages - the reference classes for the packages
Returns:
the clazz loaded from the new classloading system

initializeClassLoader

public Class<?> initializeClassLoader(Class<?> clazz,
                                      ClassLoaderPolicy policy)
Initialize the classloader system

Parameters:
clazz - the original clazz
policy - the policy
Returns:
the clazz loaded from the new classloading system

initializeClassLoader

public Class<?> initializeClassLoader(Class<?> clazz,
                                      ClassLoaderSystem system,
                                      ClassLoaderPolicy policy)
Initialize the classloader system

Parameters:
clazz - the original clazz
system - the system
policy - the policy
Returns:
the clazz loaded from the new classloading system

initializeClassLoader

public Class<?> initializeClassLoader(Class<?> clazz,
                                      ClassLoaderSystem system,
                                      ClassLoaderPolicy policy,
                                      Set<String> parentPackages)
Initialize the classloader system

Parameters:
clazz - the original clazz
system - the system
policy - the policy
parentPackages - the parentPackages
Returns:
the clazz loaded from the new classloading system

initializeClassLoader

public Class<?> initializeClassLoader(Class<?> clazz,
                                      ClassLoaderSystem system,
                                      ClassLoaderPolicy policy,
                                      String... parentPackages)
Initialize the classloader system

Parameters:
clazz - the original clazz
system - the system
policy - the policy
parentPackages - the parentPackages
Returns:
the clazz loaded from the new classloading system

initializeClassLoader

public Class<?> initializeClassLoader(Class<?> clazz,
                                      ClassFilter parentFilter,
                                      boolean importAll,
                                      Class<?>... packages)
Initialize the classloader system

Parameters:
clazz - the original clazz
parentFilter - the parent filter
importAll - whether to import all
packages - the reference classes for the packages
Returns:
the clazz loaded from the new classloading system

initializeClassLoader

public Class<?> initializeClassLoader(Class<?> clazz,
                                      ClassFilter parentFilter,
                                      ClassLoaderPolicy policy)
Initialize the classloader system

Parameters:
clazz - the original clazz
parentFilter - the parent filter
policy - the policy
Returns:
the clazz loaded from the new classloading system

initializeClassLoader

public Class<?> initializeClassLoader(Class<?> clazz,
                                      ClassLoaderSystem system,
                                      ClassFilter parentFilter,
                                      ClassLoaderPolicy policy)
Initialize the classloader system

Parameters:
clazz - the original clazz
system - the system
parentFilter - the parent filter
policy - the policy
Returns:
the clazz loaded from the new classloading system

initializeClassLoader

public Class<?> initializeClassLoader(Class<?> clazz,
                                      ClassLoaderSystem system,
                                      ClassFilter beforeFilter,
                                      ClassFilter afterFilter,
                                      ClassLoaderPolicy policy)
Initialize the classloader system

Parameters:
clazz - the original clazz
system - the system
beforeFilter - the before filter
afterFilter - the after filter
policy - the policy
Returns:
the clazz loaded from the new classloading system

initializeClassLoader

public Class<?> initializeClassLoader(Class<?> clazz,
                                      ClassLoaderSystem system,
                                      ParentPolicy parentPolicy,
                                      ClassLoaderPolicy policy)
Initialize the classloader system

Parameters:
clazz - the original clazz
system - the system
parentPolicy - the parent policy
policy - the policy
Returns:
the clazz loaded from the new classloading system

initializeClassLoader

public Class<?> initializeClassLoader(Class<?> clazz,
                                      ClassLoaderSystem system,
                                      ClassLoaderDomain domain,
                                      ClassLoaderPolicy policy)
Initialize the classloader system

Parameters:
clazz - the original clazz
system - the system
domain - the domain
policy - the policy
Returns:
the clazz loaded from the new classloading system

createClassLoader

public ClassLoader createClassLoader(String name,
                                     boolean importAll,
                                     String... packages)
                              throws Exception
Create a classloader It exports everything

Parameters:
name - the name
importAll - whether to import all
packages - the packages
Returns:
the classloader
Throws:
Exception - for any error

createClassLoader

public ClassLoader createClassLoader(MockClassLoaderPolicy policy)
                              throws Exception
Create a classloader

Parameters:
policy - the policy
Returns:
the classloader
Throws:
Exception - for any error

createClassLoader

public ClassLoader createClassLoader(String domainName,
                                     MockClassLoaderPolicy policy)
                              throws Exception
Create a classloader

Parameters:
domainName - the domainName
policy - the policy
Returns:
the classloader
Throws:
Exception - for any error

createClassLoader

public ClassLoader createClassLoader(ClassLoaderDomain domain,
                                     MockClassLoaderPolicy policy)
                              throws Exception
Create a classloader

Parameters:
domain - the domain
policy - the policy
Returns:
the classloader
Throws:
Exception - for any error

unregisterClassLoader

public void unregisterClassLoader(ClassLoader classLoader)
                           throws Exception
Unregister a classloader

Parameters:
classLoader - the classloader
Throws:
Exception - for any error

createDefaultDelegates

public List<? extends DelegateLoader> createDefaultDelegates()
Create the default delegate loader

Returns:
the loaders

createDelegates

public List<? extends DelegateLoader> createDelegates(ClassLoaderPolicy... policies)
Create delegate loaders from policies

Parameters:
policies - the policies
Returns:
the loaders

createScopedClassLoaderDomainParentFirst

public ClassLoaderDomain createScopedClassLoaderDomainParentFirst(String name)
Create a scoped classloader domain using the test domain as parent using the parent first policy

Parameters:
name - the name
Returns:
the domain

createScopedClassLoaderDomainParentLast

public ClassLoaderDomain createScopedClassLoaderDomainParentLast(String name)
Create a scoped classloader domain using the test domain as parent using the parent last policy

Parameters:
name - the name
Returns:
the domain

createScopedClassLoaderDomain

public ClassLoaderDomain createScopedClassLoaderDomain(String name,
                                                       ParentPolicy parentPolicy)
Create a scoped classloader domain using the test domain as parent

Parameters:
name - the name
parentPolicy - the parent policy
Returns:
the domain

createScopedClassLoaderDomain

public ClassLoaderDomain createScopedClassLoaderDomain(String name,
                                                       ParentPolicy parentPolicy,
                                                       Loader parent)
Create a scoped classloader domain

Parameters:
name - the name
parentPolicy - the parent policy
parent - the parent
Returns:
the domain

unregisterDomain

public void unregisterDomain(String name)
Unregister a domain

Parameters:
name - the domain name


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