Package org.apache.groovy.groovysh.jline
Class GroovyEngine.EngineClassLoader
java.lang.Object
java.lang.ClassLoader
java.security.SecureClassLoader
java.net.URLClassLoader
groovy.lang.GroovyClassLoader
org.apache.groovy.groovysh.jline.GroovyEngine.EngineClassLoader
- All Implemented Interfaces:
Closeable,AutoCloseable
- Enclosing class:
- GroovyEngine
Custom class loader for dynamically loaded Groovy classes.
Extends GroovyClassLoader with cache purging capabilities.
-
Nested Class Summary
Nested classes/interfaces inherited from class groovy.lang.GroovyClassLoader
GroovyClassLoader.ClassCollector, GroovyClassLoader.InnerLoader -
Field Summary
Fields inherited from class groovy.lang.GroovyClassLoader
classCache, sourceCache -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new EngineClassLoader.EngineClassLoader(ClassLoader parent) Constructs an EngineClassLoader with the given parent class loader andCompilerConfiguration.DEFAULT.EngineClassLoader(ClassLoader parent, CompilerConfiguration configuration) Constructs an EngineClassLoader with the given parent class loader and compiler configuration.EngineClassLoader(CompilerConfiguration configuration) Constructs an EngineClassLoader with the given compiler configuration and the current thread's context class loader as parent. -
Method Summary
Modifier and TypeMethodDescriptionPackage[]Returns all packages loaded by this class loader.voidPurges all dynamically generated script classes from the cache.voidpurgeClassCache(String regex) Purges cached classes matching the given regex pattern.Methods inherited from class groovy.lang.GroovyClassLoader
addClasspath, addURL, clearCache, close, createCollector, createCompilationUnit, defineClass, defineClass, genEncodingString, generateScriptName, getClassCacheEntry, getClassPath, getLoadedClasses, getPermissions, getResourceLoader, getTimeStamp, hasCompatibleConfiguration, isRecompilable, isShouldRecompile, isSourceNewer, loadClass, loadClass, loadClass, loadClass, parseClass, parseClass, parseClass, parseClass, parseClass, parseClass, recompile, removeClassCacheEntry, setClassCacheEntry, setResourceLoader, setShouldRecompileMethods inherited from class java.net.URLClassLoader
definePackage, findClass, findResource, findResources, getResourceAsStream, getURLs, newInstance, newInstanceMethods inherited from class java.security.SecureClassLoader
defineClass, defineClassMethods inherited from class java.lang.ClassLoader
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findClass, findLibrary, findLoadedClass, findResource, findSystemClass, getClassLoadingLock, getDefinedPackage, getDefinedPackages, getName, getPackage, getParent, getPlatformClassLoader, getResource, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, getUnnamedModule, isRegisteredAsParallelCapable, registerAsParallelCapable, resolveClass, resources, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
-
Constructor Details
-
EngineClassLoader
public EngineClassLoader()Constructs a new EngineClassLoader. -
EngineClassLoader
Constructs an EngineClassLoader with the given compiler configuration and the current thread's context class loader as parent.- Parameters:
configuration- compiler configuration, ornullfor the default- Since:
- 7.0.0
-
EngineClassLoader
Constructs an EngineClassLoader with the given parent class loader andCompilerConfiguration.DEFAULT. UseEngineClassLoader(ClassLoader, CompilerConfiguration)to supply an engine's configuration, so that the engine adopts this loader rather than wrapping it.- Parameters:
parent- the parent class loader- Since:
- 7.0.0
-
EngineClassLoader
Constructs an EngineClassLoader with the given parent class loader and compiler configuration.- Parameters:
parent- the parent class loaderconfiguration- compiler configuration, ornullfor the default- Since:
- 7.0.0
-
-
Method Details
-
getPackages
Returns all packages loaded by this class loader.- Overrides:
getPackagesin classClassLoader- Returns:
- array of packages
-
purgeClassCache
Purges cached classes matching the given regex pattern.- Parameters:
regex- the pattern to match class names
-
purgeClassCache
public void purgeClassCache()Purges all dynamically generated script classes from the cache.
-