public class ModuleClassLoader
extends java.net.URLClassLoader
Modifier | Constructor and Description |
---|---|
|
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) |
Modifier and Type | Method and Description |
---|---|
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 static Module[] |
collectAwareOfModuleImports(Module module)
Get and cache the imports for this module.
|
protected static Module[] |
collectRequiredModuleImports(Module module)
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) |
static java.io.File |
getLibCacheFolderForModule(Module module)
Get the library cache folder for the given module.
|
Module |
getModule() |
java.util.Set<java.lang.String> |
getProvidedPackages()
Contains all class packages provided by the module, including those contained in jars.
|
boolean |
isDisposed() |
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 |
setProbeParentLoaderLast(boolean value)
Allow the probe parent loader last variable to be set.
|
java.lang.String |
toString() |
addURL, close, definePackage, findClass, getPermissions, getResourceAsStream, getURLs, newInstance, newInstance
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, 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(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(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(java.net.URL[])
public ModuleClassLoader(Module module, java.lang.ClassLoader parent)
module
- the Module
to loadparent
- parent ClassLoader
public Module getModule()
public boolean isDisposed()
public static java.io.File getLibCacheFolderForModule(Module module)
module
- Module which the cache will be used forprotected static Module[] collectRequiredModuleImports(Module module)
protected static Module[] collectAwareOfModuleImports(Module module)
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 againstjava.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 filepublic 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 lookpublic java.util.Set<java.lang.String> getProvidedPackages()
It is used by OpenmrsClassLoader.loadClass(String, boolean)
and in particular
ModuleFactory.getModuleClassLoadersForPackage(String)
to quickly find
possible loaders for the given class. Although it takes some time to extract all provided
packages from a module, it pays off when loading classes. It is much faster to query a map of
packages than iterating over all class loaders to find which one to use.
public java.lang.String toString()
toString
in class java.lang.Object
Object.toString()
Copyright © 2020 OpenMRS Inc.. All Rights Reserved.