Class DefaultClassRealm
java.lang.Object
org.codehaus.classworlds.DefaultClassRealm
- All Implemented Interfaces:
ClassRealm
Implementation of
ClassRealm. The realm is the class loading gateway.
The search is proceded as follows:
- Search the parent class loader (passed via the constructor) if there is one.
- Search the imports.
- Search this realm's constituents.
- Search the parent realm.
- Version:
- $Id: DefaultClassRealm.java 126 2006-01-12 04:17:51Z $
- Author:
- bob mcwhirter, Jason van Zyl
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate RealmClassLoaderprivate ClassLoaderprivate Stringprivate TreeSetprivate ClassRealmprivate ClassWorld -
Constructor Summary
ConstructorsConstructorDescriptionDefaultClassRealm(ClassWorld world, String id) DefaultClassRealm(ClassWorld world, String id, ClassLoader foreignClassLoader) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddConstituent(String constituent, byte[] b) Adds a byte[] class definition as a constituent for locating classes.voidaddConstituent(URL constituent) voiddisplay()findResources(String name) URL[]getId()getResource(String name) getResourceAsStream(String name) getWorld()voidimportFrom(String realmId, String packageName) locateSourceRealm(String classname) voidsetParent(ClassRealm parent) private voidshowUrls(ClassRealm classRealm)
-
Field Details
-
world
-
id
-
imports
-
foreignClassLoader
-
classLoader
-
parent
-
-
Constructor Details
-
DefaultClassRealm
-
DefaultClassRealm
-
-
Method Details
-
getConstituents
- Specified by:
getConstituentsin interfaceClassRealm
-
getParent
- Specified by:
getParentin interfaceClassRealm
-
setParent
- Specified by:
setParentin interfaceClassRealm
-
getId
- Specified by:
getIdin interfaceClassRealm
-
getWorld
- Specified by:
getWorldin interfaceClassRealm
-
importFrom
- Specified by:
importFromin interfaceClassRealm- Throws:
NoSuchRealmException
-
addConstituent
- Specified by:
addConstituentin interfaceClassRealm
-
addConstituent
Adds a byte[] class definition as a constituent for locating classes. Currently uses BytesURLStreamHandler to hold a reference of the byte[] in memory. This ensures we have a unifed URL resource model for all constituents. The code to cache to disk is commented out - maybe a property to choose which method?- Parameters:
constituent- class nameb- the class definition as a byte[]- Throws:
ClassNotFoundException
-
locateSourceRealm
- Specified by:
locateSourceRealmin interfaceClassRealm
-
getClassLoader
- Specified by:
getClassLoaderin interfaceClassRealm
-
createChildRealm
- Specified by:
createChildRealmin interfaceClassRealm- Throws:
DuplicateRealmException
-
loadClass
- Specified by:
loadClassin interfaceClassRealm- Throws:
ClassNotFoundException
-
getResource
- Specified by:
getResourcein interfaceClassRealm
-
getResourceAsStream
- Specified by:
getResourceAsStreamin interfaceClassRealm
-
findResources
- Specified by:
findResourcesin interfaceClassRealm- Throws:
IOException
-
display
public void display()- Specified by:
displayin interfaceClassRealm
-
showUrls
-