Class ShrinkWrapClassLoader
- java.lang.Object
-
- java.lang.ClassLoader
-
- java.security.SecureClassLoader
-
- java.net.URLClassLoader
-
- org.jboss.shrinkwrap.api.classloader.ShrinkWrapClassLoader
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable
public class ShrinkWrapClassLoader extends java.net.URLClassLoader implements java.io.CloseableExtension that will create a ClassLoader based on a Array of Archives. When done, callclose()to free resources.
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.StringEMPTYEmpty Stringprivate static java.util.logging.LoggerlogLoggerprivate java.util.List<java.io.InputStream>openedStreamsList of all streams opened, such that they may be closed inclose().
-
Constructor Summary
Constructors Constructor Description ShrinkWrapClassLoader(java.lang.ClassLoader parent, Archive<?>... archives)Constructs a new ShrinkWrapClassLoader for the givenArchives.ShrinkWrapClassLoader(Archive<?>... archives)Constructs a new ShrinkWrapClassLoader for the specifiedArchives using the default delegation parentClassLoader.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidaddArchive(Archive<?> archive)private voidaddArchives(Archive<?>[] archives)voidclose()-
Methods inherited from class java.net.URLClassLoader
addURL, definePackage, findClass, findResource, findResources, getPermissions, getResourceAsStream, getURLs, newInstance, newInstance
-
Methods inherited from class java.lang.ClassLoader
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findLibrary, findLoadedClass, findSystemClass, getClassLoadingLock, getPackage, getPackages, getParent, getResource, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, loadClass, registerAsParallelCapable, resolveClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
-
-
-
-
Field Detail
-
log
private static final java.util.logging.Logger log
Logger
-
EMPTY
private static final java.lang.String EMPTY
Empty String- See Also:
- Constant Field Values
-
openedStreams
private final java.util.List<java.io.InputStream> openedStreams
List of all streams opened, such that they may be closed inclose(). Guarded by "this".
-
-
Constructor Detail
-
ShrinkWrapClassLoader
public ShrinkWrapClassLoader(Archive<?>... archives)
Constructs a new ShrinkWrapClassLoader for the specifiedArchives using the default delegation parentClassLoader. TheArchives will be searched in the order specified for classes and resources after first searching in the parent class loader.- Parameters:
archives- theArchives from which to load classes and resources
-
ShrinkWrapClassLoader
public ShrinkWrapClassLoader(java.lang.ClassLoader parent, Archive<?>... archives)Constructs a new ShrinkWrapClassLoader for the givenArchives. TheArchives will be searched in the order specified for classes and resources after first searching in the specified parent class loader.- Parameters:
parent- the parent class loader for delegationarchives- theArchives from which to load classes and resources
-
-
Method Detail
-
addArchives
private void addArchives(Archive<?>[] archives)
-
addArchive
private void addArchive(Archive<?> archive)
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Overrides:
closein classjava.net.URLClassLoader- Throws:
java.io.IOException
-
-