public class ModuleClassLoader extends URLClassLoader
Modifier | Constructor and Description |
---|---|
|
ModuleClassLoader(Module module,
ClassLoader parent)
Creates class instance configured to load classes and resources for given module.
|
protected |
ModuleClassLoader(Module module,
List<URL> urls) |
protected |
ModuleClassLoader(Module module,
List<URL> urls,
ClassLoader parent) |
protected |
ModuleClassLoader(Module module,
List<URL> urls,
ClassLoader parent,
URLStreamHandlerFactory factory) |
Modifier and Type | Method and Description |
---|---|
void |
addAdditionalPackage(String additionalPackage)
Convenience method to add another package name to the list of packages provided
by this module
|
void |
addAllAdditionalPackages(Collection<String> providedPackages)
Convenience method to add a bunch of package names to the list of packages provided
by this module
|
protected File |
cacheLibrary(URL libUrl,
String libname)
Saves the given library in the openmrs cache.
|
protected void |
checkClassVisibility(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 static Module[] |
collectRequiredModuleImports(Module module)
Get and cache the imports for this module.
|
void |
dispose() |
protected String |
findLibrary(String name) |
URL |
findResource(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 URL |
findResource(String name,
ModuleClassLoader requestor,
Set<String> seenModules)
Find a resource (image, file, etc) in the module structure
|
protected void |
findResources(List<URL> result,
String name,
ModuleClassLoader requestor,
Set<String> seenModules)
Find all occurrences of a resource (image, file, etc) in the module structure
|
Enumeration<URL> |
findResources(String name) |
Set<String> |
getAdditionalPackages()
Package names that this module should try to load.
|
static File |
getLibCacheFolderForModule(Module module)
Get the library cache folder for the given module.
|
Module |
getModule() |
protected boolean |
isResourceVisible(String name,
URL url,
ModuleClassLoader requestor)
Check if the given resource (image, file, etc) is visible by this classloader
|
protected Class<?> |
loadClass(String name,
boolean resolve) |
protected Class<?> |
loadClass(String name,
boolean resolve,
ModuleClassLoader requestor,
Set<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(Set<String> additionalPackages) |
void |
setProbeParentLoaderLast(boolean value)
Allow the probe parent loader last variable to be set.
|
String |
toString() |
addURL, close, definePackage, findClass, getPermissions, getResourceAsStream, getURLs, newInstance, newInstance
defineClass, defineClass
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findLoadedClass, findSystemClass, getClassLoadingLock, getPackage, getPackages, getParent, getResource, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, registerAsParallelCapable, resolveClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
protected ModuleClassLoader(Module module, List<URL> urls, ClassLoader parent, URLStreamHandlerFactory factory)
module
- Moduleurls
- resources "managed" by this class loaderparent
- parent class loaderfactory
- URL stream handler factoryURLClassLoader(java.net.URL[], java.lang.ClassLoader,
java.net.URLStreamHandlerFactory)
protected ModuleClassLoader(Module module, List<URL> urls, ClassLoader parent)
module
- the Module
to loadurls
- List
of the resources "managed" by this class loaderparent
- parent ClassLoader
URLClassLoader(java.net.URL[], java.lang.ClassLoader)
protected ModuleClassLoader(Module module, List<URL> urls)
module
- the Module
to loadurls
- List
of thee resources "managed" by this class loaderURLClassLoader(java.net.URL[])
public ModuleClassLoader(Module module, ClassLoader parent)
module
- the Module
to loadparent
- parent ClassLoader
public Module getModule()
public static File getLibCacheFolderForModule(Module module)
module
- Module which the cache will be used forprotected static Module[] collectRequiredModuleImports(Module module)
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 Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException
loadClass
in class ClassLoader
ClassNotFoundException
ClassLoader.loadClass(java.lang.String, boolean)
protected Class<?> loadClass(String name, boolean resolve, ModuleClassLoader requestor, Set<String> seenModules) throws 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
- SetClassNotFoundException
- if no class foundprotected void checkClassVisibility(Class<?> cls, ModuleClassLoader requestor) throws ClassNotFoundException
cls
- Class to checkrequestor
- ModuleClassLoader to check againstClassNotFoundException
protected String findLibrary(String name)
findLibrary
in class ClassLoader
ClassLoader.findLibrary(java.lang.String)
protected File cacheLibrary(URL libUrl, String libname)
libUrl
- URL to the library/jar filelibname
- name of the jar that will be the name of the cached filepublic URL findResource(String name)
findResource
in class URLClassLoader
ClassLoader.findResource(java.lang.String)
public Enumeration<URL> findResources(String name) throws IOException
findResources
in class URLClassLoader
IOException
ClassLoader.findResources(java.lang.String)
protected URL findResource(String name, ModuleClassLoader requestor, Set<String> seenModules)
name
- String path and name of the filerequestor
- ModuleClassLoader in which to lookseenModules
- SetfindResource(String)
protected void findResources(List<URL> result, String name, ModuleClassLoader requestor, Set<String> seenModules) throws IOException
result
- URL of the file foundname
- String path and name of the file to findrequestor
- ModuleClassLoader in which to startseenModules
- SetIOException
findResources(String)
,
findResource(String, ModuleClassLoader, Set)
protected boolean isResourceVisible(String name, URL url, ModuleClassLoader requestor)
name
- String path and name to checkurl
- URL of the library filerequestor
- ModuleClassLoader in which to lookpublic Set<String> getAdditionalPackages()
public void setAdditionalPackages(Set<String> additionalPackages)
additionalPackages
- the package names to set that this module contains that are
outside the normal omod and omod/lib folderspublic void addAdditionalPackage(String additionalPackage)
additionalPackage
- string package name#setProvidedPackages(Set)
public void addAllAdditionalPackages(Collection<String> providedPackages)
providedPackages
- list/set of strings that are package names#setProvidedPackages(Set)
public String toString()
toString
in class Object
Object.toString()
Copyright © 2020 OpenMRS LLC.. All Rights Reserved.