public class OpenmrsClassLoader
extends java.net.URLClassLoader
Constructor and Description |
---|
OpenmrsClassLoader()
Normal constructor.
|
OpenmrsClassLoader(java.lang.ClassLoader parent)
Creates the instance for the OpenmrsClassLoader
|
Modifier and Type | Method and Description |
---|---|
protected static void |
clearReferences()
This clears any references this classloader might have that will prevent garbage collection.
|
static void |
deleteOldLibCaches(java.io.File libCacheFolder)
Deletes the old lib cache folders that might not have been deleted when OpenMRS closed
|
static void |
destroyInstance()
Destroy the current instance of the classloader.
|
static java.net.URL |
expandURL(java.net.URL result,
java.io.File folder)
Expand the given URL into the given folder
|
java.net.URL |
findResource(java.lang.String name) |
java.util.Enumeration<java.net.URL> |
findResources(java.lang.String name) |
static void |
flushInstance()
All objects depending on the old classloader should be restarted here Should be called after
destoryInstance() and after the service is restarted
|
static OpenmrsClassLoader |
getInstance()
Get the static/singular instance of the module class loader
|
static java.io.File |
getLibCacheFolder()
Get the temporary "work" directory for expanded jar files
|
java.io.InputStream |
getResourceAsStream(java.lang.String file)
Searches all known module classloaders first, then parent classloaders
|
java.util.Enumeration<java.net.URL> |
getResources(java.lang.String packageName)
Searches all known module classloaders first, then parent classloaders
|
java.lang.Class<?> |
loadClass(java.lang.String name,
boolean resolve)
It loads classes from the web container class loader first (parent class loader) and then
tries module class loaders.
|
protected static boolean |
loadedByThisOrChild(java.lang.Class<?> clazz)
Determine whether a class was loaded by this class loader or one of its child class loaders.
|
protected static void |
nullInstance(java.lang.Object instance)
Used by
clearReferences() upon application close. |
static void |
onShutdown() |
static void |
restoreState()
This method should be called after restoring the instance
|
static void |
saveState()
This method should be called before destroying the instance
|
java.lang.String |
toString() |
addURL, close, definePackage, findClass, getPermissions, getURLs, newInstance, newInstance
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findLibrary, findLoadedClass, findSystemClass, getClassLoadingLock, getPackage, getPackages, getParent, getResource, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, registerAsParallelCapable, resolveClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
public OpenmrsClassLoader(java.lang.ClassLoader parent)
public OpenmrsClassLoader()
public static OpenmrsClassLoader getInstance()
public 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)
public java.net.URL findResource(java.lang.String name)
findResource
in class java.net.URLClassLoader
URLClassLoader.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
URLClassLoader.findResources(java.lang.String)
public java.io.InputStream getResourceAsStream(java.lang.String file)
getResourceAsStream
in class java.net.URLClassLoader
ClassLoader.getResourceAsStream(java.lang.String)
public java.util.Enumeration<java.net.URL> getResources(java.lang.String packageName) throws java.io.IOException
getResources
in class java.lang.ClassLoader
java.io.IOException
ClassLoader.getResources(java.lang.String)
public java.lang.String toString()
toString
in class java.lang.Object
Object.toString()
public static void destroyInstance()
flushInstance()
public static void onShutdown()
protected static void clearReferences()
protected static void nullInstance(java.lang.Object instance)
instance
- the object whose fields need to be nulled outprotected static boolean loadedByThisOrChild(java.lang.Class<?> clazz)
public static void saveState()
destroyInstance()
public static void restoreState()
destroyInstance()
,
saveState()
public static void flushInstance()
destroyInstance()
public static java.io.File getLibCacheFolder()
public static void deleteOldLibCaches(java.io.File libCacheFolder)
libCacheFolder
- public static java.net.URL expandURL(java.net.URL result, java.io.File folder)
result
- URL of the file to expandfolder
- File (directory) to place the expanded fileCopyright © 2018 OpenMRS Inc.. All Rights Reserved.