Class EmbeddedImplClassLoader
This loader facilitates a scenario whereby an API can embed its implementation and dependencies all within the same archive as the API itself. The archive can be put directly on the class path, where it's API classes are loadable by the application class loader, but the embedded implementation and dependencies are not. When locating a concrete provider, the API can create an instance of an EmbeddedImplClassLoader to locate and load the implementation.
The archive typically consists of two disjoint logically groups: 1. the top-level classes and resources, 2. the embedded classes and resources
The top-level classes and resources are typically loaded and located, respectively, by the parent of an EmbeddedImplClassLoader loader. The embedded classes and resources, are located by the parent loader as pure resources with a provider specific name prefix, and classes are defined by the EmbeddedImplClassLoader. The list of prefixes is determined by reading the entries in the MANIFEST.TXT.
For example, the structure of the archive named x-content:
/org/elasticsearch/xcontent/XContent.class /IMPL-JARS/x-content/LISTING.TXT - contains list of jar file names, newline separated /IMPL-JARS/x-content/x-content-impl.jar/xxx /IMPL-JARS/x-content/dep-1.jar/abc /IMPL-JARS/x-content/dep-2.jar/xyz
-
Method Summary
Modifier and TypeMethodDescriptionClass<?>
protected URL
findResource
(String name) protected Enumeration<URL>
findResources
(String name) Methods inherited from class java.security.SecureClassLoader
defineClass, defineClass, getPermissions
Methods inherited from class java.lang.ClassLoader
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findClass, findLibrary, findLoadedClass, findResource, findSystemClass, getClassLoadingLock, getDefinedPackage, getDefinedPackages, getName, getPackage, getPackages, getParent, getPlatformClassLoader, getResource, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, getUnnamedModule, isRegisteredAsParallelCapable, loadClass, loadClass, registerAsParallelCapable, resolveClass, resources, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
-
Method Details
-
findClass
- Overrides:
findClass
in classClassLoader
- Throws:
ClassNotFoundException
-
findResource
- Overrides:
findResource
in classClassLoader
-
findResources
- Overrides:
findResources
in classClassLoader
- Throws:
IOException
-