public class ClassLoaderResolverImpl extends Object implements ClassLoaderResolver
Modifier and Type | Field and Description |
---|---|
protected ClassLoader |
contextLoader
ClassLoader initialised by the context (ExecutionContext).
|
protected int |
contextLoaderHashCode
Hash code cache for performance improvement
|
protected Map<String,Class> |
jreClasses |
protected Map<String,Class> |
loadedClasses
Cache for loaded classes
|
protected Map<String,URL> |
resources
Cache for resources
|
protected ClassLoader |
runtimeLoader
ClassLoader registered to load runtime created classes.
|
protected int |
runtimeLoaderHashCode
Hash code cache for performance improvement
|
protected Map<String,Class> |
unloadedClasses
Cache for loaded classes
|
protected ClassLoader |
userRegisteredLoader
ClassLoader registered to load classes (e.g set in the persistence properties as the primary loader).
|
protected int |
userRegisteredLoaderHashCode
Hash code cache for performance improvement
|
Constructor and Description |
---|
ClassLoaderResolverImpl()
Constructor for non-PersistenceManager cases so there is no
PM context loader.
|
ClassLoaderResolverImpl(ClassLoader ctxLoader)
Constructor for ExecutionContext cases.
|
Modifier and Type | Method and Description |
---|---|
Class |
classForName(String name)
JDO's Class Loading mechanism (Spec 1.0.1 Chapter 12.5).
|
Class |
classForName(String name,
boolean initialize)
JDO's Class Loading mechanism (Spec 1.0.1 Chapter 12.5).
|
Class |
classForName(String name,
ClassLoader primary)
JDO's Class Loading mechanism (Spec 1.0.1 Chapter 12.5).
|
Class |
classForName(String name,
ClassLoader primary,
boolean initialize)
JDO's Class Loading mechanism (Spec 1.0.1 Chapter 12.5).
|
URL |
getResource(String resourceName,
ClassLoader primary)
Finds the resource with the given name.
|
Enumeration |
getResources(String resourceName,
ClassLoader primary)
Finds all the resources with the given name.
|
boolean |
isAssignableFrom(Class class_1,
String class_name_2)
Utility to check the assignability of 2 classes in accordance with JDO's Class Loading mechanism.
|
boolean |
isAssignableFrom(String class_name_1,
Class class_2)
Utility to check the assignability of 2 classes in accordance with JDO's Class Loading mechanism.
|
boolean |
isAssignableFrom(String class_name_1,
String class_name_2)
Utility to check the assignability of 2 classes in accordance with JDO's Class Loading mechanism.
|
protected void |
loadJreClasses() |
void |
registerUserClassLoader(ClassLoader loader)
ClassLoader registered by users to load classes.
|
void |
setPrimary(ClassLoader primary)
Sets the primary classloader for the current thread
|
void |
setRuntimeClassLoader(ClassLoader loader)
ClassLoader registered to load classes created at runtime.
|
String |
toString() |
void |
unsetPrimary()
Unsets the primary classloader for the current thread
|
protected final ClassLoader contextLoader
protected int contextLoaderHashCode
protected ClassLoader runtimeLoader
protected int runtimeLoaderHashCode
protected ClassLoader userRegisteredLoader
protected int userRegisteredLoaderHashCode
public ClassLoaderResolverImpl(ClassLoader ctxLoader)
ctxLoader
- Loader from ExecutionContext initialisation time.public ClassLoaderResolverImpl()
protected void loadJreClasses()
public Class classForName(String name, ClassLoader primary)
classForName
in interface ClassLoaderResolver
name
- Name of the Class to be loadedprimary
- primary ClassLoader to use (or null)ClassNotResolvedException
- if the class can't be found in the classpathpublic Class classForName(String name, ClassLoader primary, boolean initialize)
classForName
in interface ClassLoaderResolver
name
- Name of the Class to be loadedprimary
- the primary ClassLoader to use (or null)initialize
- whether to initialize the class or not.ClassNotResolvedException
- if the class can't be found in the classpathpublic Class classForName(String name)
classForName
in interface ClassLoaderResolver
name
- Name of the Class to be loadedpublic Class classForName(String name, boolean initialize)
classForName
in interface ClassLoaderResolver
name
- Name of the Class to be loadedinitialize
- whether to initialize the class or not.ClassNotResolvedException
- if the class can't be found in the classpathpublic boolean isAssignableFrom(String class_name_1, String class_name_2)
isAssignableFrom
in interface ClassLoaderResolver
class_name_1
- Name of first classclass_name_2
- Name of second classpublic boolean isAssignableFrom(String class_name_1, Class class_2)
isAssignableFrom
in interface ClassLoaderResolver
class_name_1
- Name of first classclass_2
- Second classpublic boolean isAssignableFrom(Class class_1, String class_name_2)
isAssignableFrom
in interface ClassLoaderResolver
class_1
- First classclass_name_2
- Name of second classpublic void setRuntimeClassLoader(ClassLoader loader)
setRuntimeClassLoader
in interface ClassLoaderResolver
loader
- The ClassLoader in which classes are definedpublic void registerUserClassLoader(ClassLoader loader)
loader
.registerUserClassLoader
in interface ClassLoaderResolver
loader
- The ClassLoader in which classes are loadedpublic Enumeration getResources(String resourceName, ClassLoader primary) throws IOException
getResources
in interface ClassLoaderResolver
resourceName
- the resource name. If resourceName
starts with "/", remove it before searching.primary
- the primary ClassLoader to use (or null)IOException
- If I/O errors occurClassLoader.getResources(java.lang.String)
public URL getResource(String resourceName, ClassLoader primary)
getResource
in interface ClassLoaderResolver
resourceName
- the path to resource name relative to the classloader root path. If resourceName
starts with "/", remove it before searching.primary
- the primary ClassLoader to use (or null)ClassLoader.getResource(java.lang.String)
public void setPrimary(ClassLoader primary)
setPrimary
in interface ClassLoaderResolver
primary
- the primary classloaderpublic void unsetPrimary()
unsetPrimary
in interface ClassLoaderResolver
Copyright © 2019. All rights reserved.