Interface ClassLoaderHook<T>

Type Parameters:
T - Plugin or Biz

@Extensible public 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 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 name
      classLoaderService - ClassLoaderService
      t - 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 name
      classLoaderService - ClassLoaderService
      t - 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

      URL preFindResource(String name, ClassLoaderService classLoaderService, T t)
      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 name
      classLoaderService - ClassLoaderService
      t - 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

      URL postFindResource(String name, ClassLoaderService classLoaderService, T t)
      This method will only be called if no resource was found from the normal loading process.
      Parameters:
      name - resource name
      classLoaderService - ClassLoaderService
      t - 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 an FileNotFoundException then the loading process is terminated
      Parameters:
      name - the name of the resource to find
      classLoaderService - ClassLoaderService
      t - 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 find
      classLoaderService - ClassLoaderService
      t - 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.