|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.lang.ClassLoader java.security.SecureClassLoader java.net.URLClassLoader org.openmrs.module.ModuleClassLoader
public class ModuleClassLoader
Standard implementation of module class loader.
Code adapted from the Java Plug-in Framework (JPF) - LGPL - Copyright (C)
2004-2006 Dmitry Olshansky
Constructor Summary | |
---|---|
|
ModuleClassLoader(Module module,
java.lang.ClassLoader parent)
Creates class instance configured to load classes and resources for given module. |
protected |
ModuleClassLoader(Module module,
java.util.List<java.net.URL> urls)
|
protected |
ModuleClassLoader(Module module,
java.util.List<java.net.URL> urls,
java.lang.ClassLoader parent)
|
protected |
ModuleClassLoader(Module module,
java.util.List<java.net.URL> urls,
java.lang.ClassLoader parent,
java.net.URLStreamHandlerFactory factory)
|
Method Summary | |
---|---|
void |
addAdditionalPackage(java.lang.String additionalPackage)
Convenience method to add another package name to the list of packages provided by this module |
void |
addAllAdditionalPackages(java.util.Collection<java.lang.String> providedPackages)
Convenience method to add a bunch of package names to the list of packages provided by this module |
protected java.io.File |
cacheLibrary(java.net.URL libUrl,
java.lang.String libname)
Saves the given library in the openmrs cache. |
protected void |
checkClassVisibility(java.lang.Class<?> cls,
ModuleClassLoader requestor)
Checking the given class's visibility in this module |
protected void |
collectFilters()
Get and cache the filters for this module (not currently implemented) |
protected void |
collectRequiredModuleImports()
Get and cache the imports for this module. |
void |
dispose()
|
protected java.lang.String |
findLibrary(java.lang.String name)
|
java.net.URL |
findResource(java.lang.String name)
If a resource is found within a jar, that jar URL is converted to a temporary file and a URL to that is returned |
protected java.net.URL |
findResource(java.lang.String name,
ModuleClassLoader requestor,
java.util.Set<java.lang.String> seenModules)
Find a resource (image, file, etc) in the module structure |
protected void |
findResources(java.util.List<java.net.URL> result,
java.lang.String name,
ModuleClassLoader requestor,
java.util.Set<java.lang.String> seenModules)
Find all occurrences of a resource (image, file, etc) in the module structure |
java.util.Enumeration<java.net.URL> |
findResources(java.lang.String name)
|
java.util.Set<java.lang.String> |
getAdditionalPackages()
Package names that this module should try to load. |
static java.io.File |
getLibCacheFolderForModule(Module module)
Get the library cache folder for the given module. |
Module |
getModule()
|
protected boolean |
isResourceVisible(java.lang.String name,
java.net.URL url,
ModuleClassLoader requestor)
Check if the given resource (image, file, etc) is visible by this classloader |
protected java.lang.Class<?> |
loadClass(java.lang.String name,
boolean resolve)
|
protected java.lang.Class<?> |
loadClass(java.lang.String name,
boolean resolve,
ModuleClassLoader requestor,
java.util.Set<java.lang.String> seenModules)
Custom loadClass implementation to allow for loading from a given ModuleClassLoader and skip the modules that have been tried already |
protected void |
modulesSetChanged()
|
void |
setAdditionalPackages(java.util.Set<java.lang.String> additionalPackages)
|
void |
setProbeParentLoaderLast(boolean value)
Allow the probe parent loader last variable to be set. |
java.lang.String |
toString()
|
Methods inherited from class java.net.URLClassLoader |
---|
addURL, definePackage, findClass, getPermissions, getURLs, newInstance, newInstance |
Methods inherited from class java.security.SecureClassLoader |
---|
defineClass, defineClass |
Methods inherited from class java.lang.ClassLoader |
---|
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findLoadedClass, findSystemClass, getPackage, getPackages, getParent, getResource, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, resolveClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
protected ModuleClassLoader(Module module, java.util.List<java.net.URL> urls, java.lang.ClassLoader parent, java.net.URLStreamHandlerFactory factory)
module
- Moduleurls
- resources "managed" by this class loaderparent
- parent class loaderfactory
- URL stream handler factoryURLClassLoader.URLClassLoader(java.net.URL[], java.lang.ClassLoader,
java.net.URLStreamHandlerFactory)
protected ModuleClassLoader(Module module, java.util.List<java.net.URL> urls, java.lang.ClassLoader parent)
module
- the Module
to loadurls
- List
of the resources "managed" by this class loaderparent
- parent ClassLoader
URLClassLoader.URLClassLoader(java.net.URL[], java.lang.ClassLoader)
protected ModuleClassLoader(Module module, java.util.List<java.net.URL> urls)
module
- the Module
to loadurls
- List
of thee resources "managed" by this class loaderURLClassLoader.URLClassLoader(java.net.URL[])
public ModuleClassLoader(Module module, java.lang.ClassLoader parent)
module
- the Module
to loadparent
- parent ClassLoader
Method Detail |
---|
public Module getModule()
public static java.io.File getLibCacheFolderForModule(Module module)
module
- Module which the cache will be used for
protected void collectRequiredModuleImports()
protected void collectFilters()
protected void modulesSetChanged()
modulesSetChanged()
public void dispose()
ModuleFactory.stopModule(Module,boolean)
public void setProbeParentLoaderLast(boolean value)
value
- boolean true/false whether or not to look at the parent classloader lastprotected java.lang.Class<?> loadClass(java.lang.String name, boolean resolve) throws java.lang.ClassNotFoundException
loadClass
in class java.lang.ClassLoader
java.lang.ClassNotFoundException
ClassLoader.loadClass(java.lang.String, boolean)
protected java.lang.Class<?> loadClass(java.lang.String name, boolean resolve, ModuleClassLoader requestor, java.util.Set<java.lang.String> seenModules) throws java.lang.ClassNotFoundException
name
- String path and name of the class to loadresolve
- boolean whether or not to resolve this class before returningrequestor
- ModuleClassLoader with which to try loadingseenModules
- Setjava.lang.ClassNotFoundException
- if no class foundprotected void checkClassVisibility(java.lang.Class<?> cls, ModuleClassLoader requestor) throws java.lang.ClassNotFoundException
cls
- Class to checkrequestor
- ModuleClassLoader to check against
java.lang.ClassNotFoundException
protected java.lang.String findLibrary(java.lang.String name)
findLibrary
in class java.lang.ClassLoader
ClassLoader.findLibrary(java.lang.String)
protected java.io.File cacheLibrary(java.net.URL libUrl, java.lang.String libname)
libUrl
- URL to the library/jar filelibname
- name of the jar that will be the name of the cached file
public java.net.URL findResource(java.lang.String name)
findResource
in class java.net.URLClassLoader
ClassLoader.findResource(java.lang.String)
public java.util.Enumeration<java.net.URL> findResources(java.lang.String name) throws java.io.IOException
findResources
in class java.net.URLClassLoader
java.io.IOException
ClassLoader.findResources(java.lang.String)
protected java.net.URL findResource(java.lang.String name, ModuleClassLoader requestor, java.util.Set<java.lang.String> seenModules)
name
- String path and name of the filerequestor
- ModuleClassLoader in which to lookseenModules
- SetfindResource(String)
protected void findResources(java.util.List<java.net.URL> result, java.lang.String name, ModuleClassLoader requestor, java.util.Set<java.lang.String> seenModules) throws java.io.IOException
result
- URL of the file foundname
- String path and name of the file to findrequestor
- ModuleClassLoader in which to startseenModules
- Setjava.io.IOException
findResources(String)
,
findResource(String, ModuleClassLoader, Set)
protected boolean isResourceVisible(java.lang.String name, java.net.URL url, ModuleClassLoader requestor)
name
- String path and name to checkurl
- URL of the library filerequestor
- ModuleClassLoader in which to look
public java.util.Set<java.lang.String> getAdditionalPackages()
public void setAdditionalPackages(java.util.Set<java.lang.String> additionalPackages)
additionalPackages
- the package names to set that this module contains that are
outside the normal omod and omod/lib folderspublic void addAdditionalPackage(java.lang.String additionalPackage)
additionalPackage
- string package name#setProvidedPackages(Set)
public void addAllAdditionalPackages(java.util.Collection<java.lang.String> providedPackages)
providedPackages
- list/set of strings that are package names#setProvidedPackages(Set)
public java.lang.String toString()
toString
in class java.lang.Object
Object.toString()
|
OpenMRS-1.7.x | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |