Class AbstractClassLoader
java.lang.Object
java.lang.ClassLoader
org.frankframework.configuration.classloaders.AbstractClassLoader
- All Implemented Interfaces:
IConfigurationClassLoader
,org.springframework.core.SmartClassLoader
- Direct Known Subclasses:
AbstractBytesClassLoader
,DirectoryClassLoader
,DummyClassLoader
,WebAppClassLoader
public abstract class AbstractClassLoader
extends ClassLoader
implements IConfigurationClassLoader, org.springframework.core.SmartClassLoader
Abstract base class for for IBIS Configuration ClassLoaders.
Appends a BasePath to every resource when set. This allows the use of sub config's in src/main/resources
When a file with prepended BasePath cannot be found it will traverse through it's classpath to find it.
- Author:
- Niels Meijer
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.frankframework.configuration.classloaders.IConfigurationClassLoader
IConfigurationClassLoader.ReportLevel
-
Field Summary
Fields inherited from interface org.frankframework.configuration.classloaders.IConfigurationClassLoader
CLASSPATH_RESOURCE_SCHEME
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
configure
(IbisContext ibisContext, String configurationName) Configure theIConfigurationClassLoader
's implementationvoid
destroy()
Called upon destroying (and thus removing) the IConfigurationClassLoaderprotected boolean
protected String
The root directory where all resources are located.The configurationFile should only ever be found in the current classloader and never in it's parentRetrieve the name of the configuration that uses thisIConfigurationClassLoader
protected IbisContext
Only for internal use within ClassLoaders Retrieve the IbisContext from the ClassLoader which is set when theconfigure
method is calledabstract URL
getLocalResource
(String name) final URL
getResource
(String name) Override this method and make it final so nobody can overwrite it.getResource
(String name, boolean useParent) In case of thegetResources(String)
we only want the local paths and not the parent pathfinal Enumeration<URL>
getResources
(String name) protected Class<?>
Class<?>
publicDefineClass
(String name, byte[] b, ProtectionDomain protectionDomain) Fixes--add-opens=java.base/java.lang=ALL-UNNAMED
problem when loading classes dynamically when CGLIB is enabled.void
reload()
Unload the current IConfigurationClassLoader and load again upon successful unload.void
setAllowCustomClasses
(boolean allow) void
setBasePath
(String basePath) Sets the path prefix used whengetLocalResource()
is called.void
setConfigurationFile
(String configurationFile) void
setReportLevel
(String level) Defines the log level for errors caused by theconfigure
methodtoString()
Methods inherited from class java.lang.ClassLoader
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findClass, findClass, findLibrary, findLoadedClass, findResource, findResource, findResources, findSystemClass, getClassLoadingLock, getDefinedPackage, getDefinedPackages, getName, getPackage, getPackages, getParent, getPlatformClassLoader, getResourceAsStream, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, getUnnamedModule, isRegisteredAsParallelCapable, loadClass, registerAsParallelCapable, resolveClass, resources, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.springframework.core.SmartClassLoader
getOriginalClassLoader, isClassReloadable
-
Field Details
-
log
protected org.apache.logging.log4j.Logger log
-
-
Constructor Details
-
AbstractClassLoader
protected AbstractClassLoader() -
AbstractClassLoader
-
-
Method Details
-
configure
public void configure(IbisContext ibisContext, String configurationName) throws ClassLoaderException Description copied from interface:IConfigurationClassLoader
Configure theIConfigurationClassLoader
's implementation- Specified by:
configure
in interfaceIConfigurationClassLoader
- Throws:
ClassLoaderException
- when theIConfigurationClassLoader
's implementation cannot retrieve or load the configuration files
-
setBasePath
Sets the path prefix used whengetLocalResource()
is called.- Parameters:
basePath
- path to use, defaults to the configuration name
-
getBasePath
The root directory where all resources are located. This may purely be used within the ClassLoader and resources should not be aware of this 'root' directory.- Returns:
- the path prefix that is used for retrieving files through this ClassLoader
-
getConfigurationName
Description copied from interface:IConfigurationClassLoader
Retrieve the name of the configuration that uses thisIConfigurationClassLoader
- Specified by:
getConfigurationName
in interfaceIConfigurationClassLoader
-
getConfigurationFile
The configurationFile should only ever be found in the current classloader and never in it's parent -
setConfigurationFile
-
getIbisContext
Only for internal use within ClassLoaders Retrieve the IbisContext from the ClassLoader which is set when theconfigure
method is called -
setReportLevel
Description copied from interface:IConfigurationClassLoader
Defines the log level for errors caused by theconfigure
method- Specified by:
setReportLevel
in interfaceIConfigurationClassLoader
- Parameters:
level
- ReportLevel in string format to be parsed by the ClassLoaderManager digester
-
getReportLevel
- Specified by:
getReportLevel
in interfaceIConfigurationClassLoader
- Returns:
- the
IConfigurationClassLoader.ReportLevel
set for thisIConfigurationClassLoader
-
setAllowCustomClasses
public void setAllowCustomClasses(boolean allow) -
getAllowCustomClasses
protected boolean getAllowCustomClasses() -
getResource
Override this method and make it final so nobody can overwrite it. Implementations of this class should usegetLocalResource(String)
- Specified by:
getResource
in interfaceIConfigurationClassLoader
- Overrides:
getResource
in classClassLoader
-
getLocalResource
- Parameters:
name
- of the file to search for in the current local classpath- Returns:
- the URL of the file if found in the ClassLoader or
null
when the file cannot be found
-
getResource
In case of thegetResources(String)
we only want the local paths and not the parent path- Parameters:
name
- of the file to retrieveuseParent
- only use local classpath or also traverse down the classpath- Returns:
- the URL of the file if found in the ClassLoader or
null
-
getResources
- Overrides:
getResources
in classClassLoader
- Throws:
IOException
-
loadClass
- Overrides:
loadClass
in classClassLoader
- Throws:
ClassNotFoundException
-
publicDefineClass
public Class<?> publicDefineClass(String name, byte[] b, @Nullable ProtectionDomain protectionDomain) Fixes
--add-opens=java.base/java.lang=ALL-UNNAMED
problem when loading classes dynamically when CGLIB is enabled. See spring github for more background information.- Specified by:
publicDefineClass
in interfaceorg.springframework.core.SmartClassLoader
-
reload
Description copied from interface:IConfigurationClassLoader
Unload the current IConfigurationClassLoader and load again upon successful unload.- Specified by:
reload
in interfaceIConfigurationClassLoader
- Throws:
ClassLoaderException
-
destroy
public void destroy()Description copied from interface:IConfigurationClassLoader
Called upon destroying (and thus removing) the IConfigurationClassLoader- Specified by:
destroy
in interfaceIConfigurationClassLoader
-
toString
-