类 AbstractClassLoader
- java.lang.Object
-
- java.lang.ClassLoader
-
- java.security.SecureClassLoader
-
- java.net.URLClassLoader
-
- io.esastack.cabin.container.service.loader.AbstractClassLoader
-
- 所有已实现的接口:
Closeable,AutoCloseable
public abstract class AbstractClassLoader extends URLClassLoader
-
-
字段概要
字段 修饰符和类型 字段 说明 protected ClassLoaderServiceclassLoaderServiceprotected StringmoduleNameprotected SharedClassServicesharedClassServiceprotected SharedResourceServicesharedResourceService
-
构造器概要
构造器 构造器 说明 AbstractClassLoader(String moduleName, URL[] urls)
-
方法概要
所有方法 实例方法 抽象方法 具体方法 修饰符和类型 方法 说明 protected voiddebugClassLoadMessage(Class<?> clazz, String method, String className)protected URLgetBizResource(String name)protected Enumeration<URL>getBizResources(String name)protected URLgetExportResource(String name)protected Enumeration<URL>getExportResources(String name)protected URLgetJavaAgentResource(String name)One useful example is that when javassist is used with jdk11, the ClassLoader::getResource is used to determine whether a class exists while compiling new classes.protected Enumeration<URL>getJavaAgentResources(String name)Why we need to load Agent Resources: 1.protected URLgetJdkResource(String name)protected Enumeration<URL>getJdkResources(String name)protected URLgetLocalResource(String name)protected Enumeration<URL>getLocalResources(String name)StringgetModuleName()URLgetResource(String name)protected abstract URLgetResource0(String name)Pay attention to the priority of finding resource: jdk, exported, bizEnumeration<URL>getResources(String name)protected abstract Enumeration<URL>getResources0(String name)Pay attention to the priority of finding resource: jdk, exported, bizprotected Class<?>loadAgentClass(String name)* Why we need to load Agent Classes: The classes in agent jars may be used to enhance the Biz classes and Lib classes, using javassist or asm; So the agent classes and methods may appear in the enhanced class byte code, while these classes being executing, the agent classes would be loaded by the Classloader of the caller class.protected Class<?>loadBizClass(String name)protected Class<?>loadCabinClass(String name)protected Class<?>loadClass(String name, boolean resolve)protected abstract Class<?>loadClass0(String name, boolean resolve)Class<?>loadClassFromClasspath(String name)protected Class<?>loadFromRecords(String name)protected Class<?>loadImportClassFromBiz(String name)protected Class<?>loadJdkClass(String name)protected Class<?>loadLocalClass(String name)protected Class<?>loadSharedClass(String name)protected booleanshouldImportClassFromBiz(String name)-
从类继承的方法 java.net.URLClassLoader
addURL, close, definePackage, findClass, findResource, findResources, getPermissions, getResourceAsStream, getURLs, newInstance, newInstance
-
从类继承的方法 java.security.SecureClassLoader
defineClass, defineClass
-
从类继承的方法 java.lang.ClassLoader
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findClass, findLibrary, findLoadedClass, findResource, findSystemClass, getClassLoadingLock, getDefinedPackage, getDefinedPackages, getName, getPackage, getPackages, getParent, getPlatformClassLoader, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, getUnnamedModule, isRegisteredAsParallelCapable, loadClass, registerAsParallelCapable, resolveClass, resources, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
-
-
-
-
字段详细资料
-
moduleName
protected final String moduleName
-
classLoaderService
protected final ClassLoaderService classLoaderService
-
sharedClassService
protected final SharedClassService sharedClassService
-
sharedResourceService
protected final SharedResourceService sharedResourceService
-
-
方法详细资料
-
getModuleName
public String getModuleName()
-
loadClass
protected Class<?> loadClass(String name, boolean resolve) throws CabinLoaderException
- 覆盖:
loadClass在类中ClassLoader- 抛出:
CabinLoaderException
-
getResources
public Enumeration<URL> getResources(String name) throws IOException
- 覆盖:
getResources在类中ClassLoader- 抛出:
IOException
-
getResource
public URL getResource(String name)
- 覆盖:
getResource在类中ClassLoader
-
loadClass0
protected abstract Class<?> loadClass0(String name, boolean resolve) throws CabinLoaderException
-
getResources0
protected abstract Enumeration<URL> getResources0(String name) throws IOException
Pay attention to the priority of finding resource: jdk, exported, biz- 抛出:
IOException
-
getResource0
protected abstract URL getResource0(String name)
Pay attention to the priority of finding resource: jdk, exported, biz
-
loadClassFromClasspath
public Class<?> loadClassFromClasspath(String name) throws CabinLoaderException
-
loadImportClassFromBiz
protected Class<?> loadImportClassFromBiz(String name) throws CabinLoaderException
-
loadFromRecords
protected Class<?> loadFromRecords(String name) throws CabinLoaderException
-
loadJdkClass
protected Class<?> loadJdkClass(String name) throws CabinLoaderException
-
loadCabinClass
protected Class<?> loadCabinClass(String name) throws CabinLoaderException
-
loadSharedClass
protected Class<?> loadSharedClass(String name) throws CabinLoaderException
-
loadBizClass
protected Class<?> loadBizClass(String name) throws CabinLoaderException
-
loadLocalClass
protected Class<?> loadLocalClass(String name) throws CabinLoaderException
-
loadAgentClass
protected Class<?> loadAgentClass(String name) throws CabinLoaderException
* Why we need to load Agent Classes: The classes in agent jars may be used to enhance the Biz classes and Lib classes, using javassist or asm; So the agent classes and methods may appear in the enhanced class byte code, while these classes being executing, the agent classes would be loaded by the Classloader of the caller class. Here, only classes in agent local classpath should be loaded.- 参数:
name- classname to be loaded- 返回:
- Class object
- 抛出:
CabinLoaderException- if multiple classed loaed from different agents
-
getJdkResources
protected Enumeration<URL> getJdkResources(String name) throws IOException
- 抛出:
IOException
-
getLocalResources
protected Enumeration<URL> getLocalResources(String name) throws IOException
- 抛出:
IOException
-
getExportResources
protected Enumeration<URL> getExportResources(String name) throws IOException
- 抛出:
IOException
-
getBizResources
protected Enumeration<URL> getBizResources(String name) throws IOException
- 抛出:
IOException
-
getJavaAgentResources
protected Enumeration<URL> getJavaAgentResources(String name) throws IOException
Why we need to load Agent Resources: 1. Agent may implement some SPI of biz and lib module, to load these implementations, the resource files must can be found by biz and lib module classloader; 2. Just for found some resource bringing by agent file.- 抛出:
IOException
-
getJavaAgentResource
protected URL getJavaAgentResource(String name)
One useful example is that when javassist is used with jdk11, the ClassLoader::getResource is used to determine whether a class exists while compiling new classes.
-
shouldImportClassFromBiz
protected boolean shouldImportClassFromBiz(String name)
-
-