Interface ClassLoaderHook<T>
implementation of ClassLoaderHook is used to customize the strategy of loading class and resources.
- Since:
- 0.6.0
- Author:
- qilong.zql
-
Method Summary
Modifier and TypeMethodDescriptionClass<?>postFindClass(String name, ClassLoaderService classLoaderService, T t) This method will only be called if no class was found from the normal loading process.postFindResource(String name, ClassLoaderService classLoaderService, T t) This method will only be called if no resource was found from the normal loading process.postFindResources(String name, ClassLoaderService classLoaderService, T t) This method will only be called if no resources were found from the normal loading process.Class<?>preFindClass(String name, ClassLoaderService classLoaderService, T t) invoke this method before load class using biz classLoader or plugin classLoader.preFindResource(String name, ClassLoaderService classLoaderService, T t) invoke this method before load resource using biz classLoader or plugin classLoader.preFindResources(String name, ClassLoaderService classLoaderService, T t) If this method returns null then normal loading process is done.
-
Method Details
-
preFindClass
Class<?> preFindClass(String name, ClassLoaderService classLoaderService, T t) throws ClassNotFoundException invoke this method before load class using biz classLoader or plugin classLoader. If this method returns null then normal loading process is done. If this method returns a non-null value then the rest of the loading process is skipped and the returned value is used.- Parameters:
name- class nameclassLoaderService-ClassLoaderServicet- plugin or biz instance where this hook is invoked- Returns:
- the class found by this hook or null if normal loading process should continue
- Throws:
ClassNotFoundException- to terminate the hook and throw an exception
-
postFindClass
Class<?> postFindClass(String name, ClassLoaderService classLoaderService, T t) throws ClassNotFoundException This method will only be called if no class was found from the normal loading process.- Parameters:
name- class nameclassLoaderService-ClassLoaderServicet- plugin or biz instance where this hook is invoked- Returns:
- the class found by this hook or null if normal loading process should continue
- Throws:
ClassNotFoundException- to terminate the hook and throw an exception
-
preFindResource
invoke this method before load resource using biz classLoader or plugin classLoader. If this method returns null then normal loading process is done. If this method returns a non-null value then the rest of the loading process is skipped and the returned value is used.- Parameters:
name- resource nameclassLoaderService-ClassLoaderServicet- plugin or biz instance where this hook is invoked- Returns:
- the resource found by this hook or null if normal loading process should continue
-
postFindResource
This method will only be called if no resource was found from the normal loading process.- Parameters:
name- resource nameclassLoaderService-ClassLoaderServicet- plugin or biz instance where this hook is invoked- Returns:
- the resource found by this hook or null if normal loading process should continue
-
preFindResources
Enumeration<URL> preFindResources(String name, ClassLoaderService classLoaderService, T t) throws IOException If this method returns null then normal loading process is done. If this method returns a non-null value then the rest of the loading process is skipped and the returned value is used. If this method throws anFileNotFoundExceptionthen the loading process is terminated- Parameters:
name- the name of the resource to findclassLoaderService-ClassLoaderServicet- plugin or biz instance where this hook is invoked- Returns:
- the resources found by this hook or empty if normal loading process should continue
- Throws:
IOException- throw an exception when error occurs.
-
postFindResources
Enumeration<URL> postFindResources(String name, ClassLoaderService classLoaderService, T t) throws IOException This method will only be called if no resources were found from the normal loading process.- Parameters:
name- the name of the resource to findclassLoaderService-ClassLoaderServicet- plugin or biz instance where this hook is invoked- Returns:
- the resources found by this hook or empty if normal loading process should continue
- Throws:
IOException- throw an exception when error occurs.
-