|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.datanucleus.JDOClassLoaderResolver
public class JDOClassLoaderResolver
A basic implementation of a ClassLoaderResolver for JDO. A ClassLoaderResolver provides a series of methods for resolving classes from their names. It supports up to 3 class loaders.
| Field Summary | |
|---|---|
protected Map<String,Class> |
loadedClasses
Cache for loaded classes |
protected static Localiser |
LOCALISER
Localisation utility for output messages |
protected ClassLoader |
pmContextLoader
ClassLoader initialised by the PM creation. |
protected int |
pmContextLoaderHashCode
Hash code cache for performance improvement |
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 Summary | |
|---|---|
JDOClassLoaderResolver()
Constructor for non-PersistenceManager cases so there is no PM context loader. |
|
JDOClassLoaderResolver(ClassLoader pmLoader)
Constructor for PersistenceManager cases. |
|
| Method Summary | |
|---|---|
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. |
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 |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected static final Localiser LOCALISER
protected final ClassLoader pmContextLoader
protected int pmContextLoaderHashCode
protected ClassLoader runtimeLoader
protected int runtimeLoaderHashCode
protected ClassLoader userRegisteredLoader
protected int userRegisteredLoaderHashCode
protected Map<String,Class> loadedClasses
protected Map<String,Class> unloadedClasses
protected Map<String,URL> resources
| Constructor Detail |
|---|
public JDOClassLoaderResolver(ClassLoader pmLoader)
pmLoader - Loader from PM initialisation time.public JDOClassLoaderResolver()
| Method Detail |
|---|
public Class classForName(String name,
ClassLoader primary)
classForName in interface ClassLoaderResolvername - Name of the Class to be loadedprimary - primary ClassLoader to use (or null)
ClassNotResolvedException - if the class can't be found in the classpath
public Class classForName(String name,
ClassLoader primary,
boolean initialize)
classForName in interface ClassLoaderResolvername - 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 ClassLoaderResolvername - Name of the Class to be loaded
public Class classForName(String name,
boolean initialize)
classForName in interface ClassLoaderResolvername - Name of the Class to be loadedinitialize - whether to initialize the class or not.
ClassNotResolvedException - if the class can't be found in the classpath
public boolean isAssignableFrom(String class_name_1,
String class_name_2)
isAssignableFrom in interface ClassLoaderResolverclass_name_1 - Name of first classclass_name_2 - Name of second class
public boolean isAssignableFrom(String class_name_1,
Class class_2)
isAssignableFrom in interface ClassLoaderResolverclass_name_1 - Name of first classclass_2 - Second class
public boolean isAssignableFrom(Class class_1,
String class_name_2)
isAssignableFrom in interface ClassLoaderResolverclass_1 - First classclass_name_2 - Name of second class
public void setRuntimeClassLoader(ClassLoader loader)
setRuntimeClassLoader in interface ClassLoaderResolverloader - The ClassLoader in which classes are definedpublic void registerUserClassLoader(ClassLoader loader)
loader.
registerUserClassLoader in interface ClassLoaderResolverloader - The ClassLoader in which classes are loaded
public Enumeration getResources(String resourceName,
ClassLoader primary)
throws IOException
getResources in interface ClassLoaderResolverresourceName - 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 ClassLoaderResolverresourceName - 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)
IOException - If I/O errors occurClassLoader.getResource(java.lang.String)public void setPrimary(ClassLoader primary)
setPrimary in interface ClassLoaderResolverprimary - the primary classloaderpublic void unsetPrimary()
unsetPrimary in interface ClassLoaderResolverpublic String toString()
toString in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||