Package org.jboss.shrinkwrap.api.asset
Class ClassLoaderAsset
- java.lang.Object
-
- org.jboss.shrinkwrap.api.asset.ClassLoaderAsset
-
- All Implemented Interfaces:
Asset
public class ClassLoaderAsset extends Object implements Asset
ClassloaderAsset Implementation of aAssetbacked by a resource located in the Classloader.- Author:
- Aslak Knutsen
-
-
Constructor Summary
Constructors Constructor Description ClassLoaderAsset(String resourceName)Load a named resource using the current threads context classloader.ClassLoaderAsset(String resourceName, ClassLoader classLoader)Load a named resource using the given classloader.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringgetSource()Returns the loaded resource.InputStreamopenStream()Opens up the given resource as a stream.
-
-
-
Constructor Detail
-
ClassLoaderAsset
public ClassLoaderAsset(String resourceName)
Load a named resource using the current threads context classloader.- Parameters:
resourceName- The name of the resource to load- Throws:
IllegalArgumentException- resourceName can not be nullIllegalArgumentException- resourceName must be found in given classloader
-
ClassLoaderAsset
public ClassLoaderAsset(String resourceName, ClassLoader classLoader)
Load a named resource using the given classloader.- Parameters:
resourceName- The name of the resource to loadclassLoader- The ClassLoader to use- Throws:
IllegalArgumentException- resourceName can not be nullIllegalArgumentException- classloader can not be nullIllegalArgumentException- resourceName must be found in given classloader
-
-
Method Detail
-
getSource
public String getSource()
Returns the loaded resource.
-
openStream
public InputStream openStream()
Opens up the given resource as a stream.- Specified by:
openStreamin interfaceAsset- Returns:
- A new open
InputStreamfor each call
-
-