Package ortus.boxlang.runtime.loader
Class DynamicClassLoader
java.lang.Object
java.lang.ClassLoader
java.security.SecureClassLoader
java.net.URLClassLoader
ortus.boxlang.runtime.loader.DynamicClassLoader
- All Implemented Interfaces:
Closeable
,AutoCloseable
-
Constructor Summary
ConstructorsConstructorDescriptionDynamicClassLoader
(Key name, ClassLoader parent) Construct the class loaderDynamicClassLoader
(Key name, URL[] urls, ClassLoader parent) Construct the class loaderDynamicClassLoader
(Key name, URL url, ClassLoader parent) Construct the class loader -
Method Summary
Modifier and TypeMethodDescriptionvoid
Add a URL to the class loadervoid
Add an array of URLs to the class loadervoid
Clear The cache of loaded classesvoid
Clear the unfound class cachevoid
close()
Close the class loaderClass
<?> Find a class in the class loader or delegate to the parent.Class
<?> Find a class in the class loader or delegate to the parentGet all the class paths keys in the resolver cacheint
Size of the cacheGet the parent class loaderstatic URL[]
getJarURLs
(String targetPath) Static method that takes in a String path and returns an array of URLs of all the JARs/clases in the pathstatic URL[]
getJarURLs
(Path targetPath) Static method that takes in a path and returns an array of URLs of all the JARs in the pathGet the name of the class loader as aGet the cache of unfound classesGet the set of keys in the unfound class cacheint
How many unfound classes we have foundstatic URL[]
inflateClassPaths
(Array paths) Goes through an array of path locations and inflates them into an array of URLs of all the JARs and classes in the pathsboolean
Is the cache empty or notboolean
isClassInCache
(String className) Verifies if the passed class name is in the cacheMethods inherited from class java.net.URLClassLoader
definePackage, findResource, findResources, getPermissions, getResourceAsStream, 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, findClass, findLibrary, findLoadedClass, findResource, findSystemClass, getClassLoadingLock, getDefinedPackage, getDefinedPackages, getName, getPackage, getPackages, getParent, getPlatformClassLoader, getResource, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, getUnnamedModule, isRegisteredAsParallelCapable, loadClass, loadClass, registerAsParallelCapable, resolveClass, resources, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
-
Constructor Details
-
DynamicClassLoader
Construct the class loader- Parameters:
name
- The unique name of the class loaderurl
- A single URL to load fromparent
- The parent class loader to delegate to
-
DynamicClassLoader
Construct the class loader- Parameters:
name
- The unique name of the class loaderurls
- The URLs to load fromparent
- The parent class loader to delegate to
-
DynamicClassLoader
Construct the class loader- Parameters:
name
- The unique name of the class loaderparent
- The parent class loader to delegate to
-
-
Method Details
-
getNameAsKey
Get the name of the class loader as a- Returns:
- The name of the class loader
-
findClass
Find a class in the class loader or delegate to the parent. If not found, then throw an exception- Overrides:
findClass
in classURLClassLoader
- Parameters:
className
- The name of the class to find- Throws:
ClassNotFoundException
-
findClass
Find a class in the class loader or delegate to the parent- Parameters:
className
- The name of the class to findsafe
- Whether to throw an exception if the class is not found- Throws:
ClassNotFoundException
-
getDynamicParent
Get the parent class loader- Returns:
- The parent class loader
-
addURL
Add a URL to the class loader- Overrides:
addURL
in classURLClassLoader
- Parameters:
url
- The URL to add- See Also:
-
addURLs
Add an array of URLs to the class loader- Parameters:
urls
- The URLs to add- See Also:
-
clearCache
public void clearCache()Clear The cache of loaded classes -
isCacheEmpty
public boolean isCacheEmpty()Is the cache empty or not -
isClassInCache
Verifies if the passed class name is in the cache- Parameters:
className
- The name of the class to check- Returns:
- True if the class is in the cache, false otherwise
-
getCacheKeys
Get all the class paths keys in the resolver cache- Returns:
- The keys in the resolver cache
-
getCacheSize
public int getCacheSize()Size of the cache- Returns:
- The size of the cache
-
getUnfoundClasses
Get the cache of unfound classes- Returns:
- The cache of unfound classes
-
getUnfoundClassesKeys
Get the set of keys in the unfound class cache- Returns:
- The keys in the unfound class cache
-
getUnfoundClassesSize
public int getUnfoundClassesSize()How many unfound classes we have found- Returns:
- The size of the unfound classes
-
clearUnfoundClasses
public void clearUnfoundClasses()Clear the unfound class cache -
close
Close the class loader- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classURLClassLoader
- Throws:
IOException
-
getJarURLs
Static method that takes in a String path and returns an array of URLs of all the JARs/clases in the path- Parameters:
targetPath
- The path to search for JARs- Returns:
- An array of URLs of all the JARs in the path
- Throws:
IOException
-
getJarURLs
Static method that takes in a path and returns an array of URLs of all the JARs in the path- Parameters:
targetPath
- The path to search for JARs- Returns:
- An array of URLs of all the JARs in the path
- Throws:
IOException
-
inflateClassPaths
Goes through an array of path locations and inflates them into an array of URLs of all the JARs and classes in the paths- Parameters:
paths
- An array of paths' to inflate- Returns:
- The URLs of jars and classes
-