Class ContainerBase<T extends Archive<T>>
- java.lang.Object
-
- org.jboss.shrinkwrap.impl.base.AssignableBase<Archive<?>>
-
- org.jboss.shrinkwrap.impl.base.container.ContainerBase<T>
-
- Type Parameters:
T
-
- All Implemented Interfaces:
Archive<T>
,Assignable
,ClassContainer<T>
,LibraryContainer<T>
,ManifestContainer<T>
,ResourceContainer<T>
,ServiceProviderContainer<T>
,ArchiveFormatAssociable
- Direct Known Subclasses:
EnterpriseContainerBase
,GenericArchiveImpl
,JavaArchiveImpl
,ResourceAdapterContainerBase
,WebContainerBase
public abstract class ContainerBase<T extends Archive<T>> extends AssignableBase<Archive<?>> implements Archive<T>, ManifestContainer<T>, ServiceProviderContainer<T>, ResourceContainer<T>, ClassContainer<T>, LibraryContainer<T>, ArchiveFormatAssociable
ContainerBase Abstract class that helps implement the Archive, ManifestContainer, ResourceContainer, ClassContainer and LibraryContainer.- Version:
- $Revision: $
- Author:
- Aslak Knutsen
-
-
Field Summary
-
Fields inherited from interface org.jboss.shrinkwrap.api.container.ManifestContainer
DEFAULT_MANIFEST_NAME
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
ContainerBase(Class<T> actualType, Archive<?> archive)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description T
add(Archive<?> archive, String path, Class<? extends StreamExporter> exporter)
Add an archive under a specific context and maintain the archive name as context path.T
add(Archive<?> archive, ArchivePath path, Class<? extends StreamExporter> exporter)
Add an archive under a specific context and maintain the archive name as context path.T
add(Asset asset, String name)
Adds the specified resource under the context denoted by the specified targetT
add(Asset asset, String target, String name)
Adds the specified asset under the specified target (directory) using the specified name.T
add(Asset asset, ArchivePath target)
Adds the specified asset under the specified path into the target contextT
add(Asset asset, ArchivePath path, String name)
Adds the specified asset under the specified target (directory) using the specified name.T
add(NamedAsset namedAsset)
Adds the asset encapsulated within the specifiedNamedAsset
under the encapsulated name and target (directory)T
addAsDirectories(String... paths)
Adds the specified directories.T
addAsDirectories(ArchivePath... paths)
Adds the specified directories.T
addAsDirectory(String path)
Adds the specified directory.T
addAsDirectory(ArchivePath path)
Adds the specified directory.T
addAsLibraries(File... resources)
T
addAsLibraries(String... resourceNames)
Add multiple resources to thisArchive
as libraries to the container, returning the container itself.T
addAsLibraries(Collection<? extends Archive<?>> archives)
T
addAsLibraries(Archive<?>... archives)
T
addAsLibraries(Archive<?>[]... archives)
T
addAsLibrary(File resource)
Adds theFile
as a library to the container, returning the container itself.T
addAsLibrary(File resource, String target)
Adds theFile
as a library to the container, returning the container itself.T
addAsLibrary(File resource, ArchivePath target)
Adds theFile
as a library to the container, returning the container itself.T
addAsLibrary(String resourceName)
Adds the resource as a library to the container, returning the container itself.T
addAsLibrary(String resourceName, String target)
Adds the resource as a library to the container, returning the container itself.T
addAsLibrary(String resourceName, ArchivePath target)
Adds the resource as a library to the container, returning the container itself.T
addAsLibrary(URL resource, String target)
Adds theURL
as a library to the container, returning the container itself.T
addAsLibrary(URL resource, ArchivePath target)
Adds theURL
as a library to the container, returning the container itself.T
addAsLibrary(Archive<?> archive)
T
addAsLibrary(Asset resource, String target)
Adds theAsset
as a library to the container, returning the container itself.T
addAsLibrary(Asset resource, ArchivePath target)
Adds theAsset
as a library to the container, returning the container itself.T
addAsManifestResource(File resource)
Adds theFile
as a Manifest resource to the container, returning the container itself.T
addAsManifestResource(File resource, String target)
Adds theFile
as a Manifest resource to the container, returning the container itself.T
addAsManifestResource(File resource, ArchivePath target)
Adds theFile
as a Manifest resource to the container, returning the container itself.T
addAsManifestResource(Package resourcePackage, String resourceName)
Adds the resource as a resource to the container, returning the container itself.T
addAsManifestResource(Package resourcePackage, String resourceName, String target)
Adds the resource as a resource to a specific path inside the container, returning the container itself.T
addAsManifestResource(Package resourcePackage, String resourceName, ArchivePath target)
Adds the resource as a resource to a specific path inside the container, returning the container itself.T
addAsManifestResource(String resourceName)
Adds the resource as a Manifest resource to the container, returning the container itself.T
addAsManifestResource(String resourceName, String target)
Adds the resource as a Manifest resource to the container, returning the container itself.T
addAsManifestResource(String resourceName, ArchivePath target)
Adds the resource as a Manifest resource to the container, returning the container itself.T
addAsManifestResource(URL resource, String target)
Adds theURL
as a Manifest resource to the container, returning the container itself.T
addAsManifestResource(URL resource, ArchivePath target)
Adds theURL
as a Manifest resource to the container, returning the container itself.T
addAsManifestResource(Asset resource, String target)
Adds theAsset
as a Manifest resource to the container, returning the container itself.T
addAsManifestResource(Asset resource, ArchivePath target)
Adds theAsset
as a Manifest resource to the container, returning the container itself.T
addAsManifestResources(Package resourcePackage, String... resourceNames)
Adds the resources inside the package as multiple resources to the container, returning the container itself.T
addAsResource(File resource)
Adds theFile
as a resource to the container, returning the container itself.T
addAsResource(File resource, String target)
Adds theFile
as a resource to the container, returning the container itself.T
addAsResource(File resource, ArchivePath target)
Adds theFile
as a resource to the container, returning the container itself.T
addAsResource(Package resourcePackage, String resourceName)
Adds the resource as a resource to the container, returning the container itself.T
addAsResource(Package resourcePackage, String resourceName, String target)
Adds the resource as a resource to a specific path inside the container, returning the container itself.T
addAsResource(Package resourcePackage, String resourceName, ArchivePath target)
Adds the resource as a resource to a specific path inside the container, returning the container itself.T
addAsResource(String resourceName)
Adds the resource as a resource to the container, returning the container itself.T
addAsResource(String resourceName, String target)
Adds the resource as a resource to the container, returning the container itself.T
addAsResource(String resourceName, ArchivePath target)
Adds the resource with the specified name to the container, returning the container itself.T
addAsResource(String resourceName, ArchivePath target, ClassLoader classLoader)
Adds the resource as a resource to the container, returning the container itself.T
addAsResource(URL resource, String target)
Adds theURL
as a resource to the container, returning the container itself.T
addAsResource(URL resource, ArchivePath target)
Adds theURL
as a resource to the container, returning the container itself.T
addAsResource(Asset resource, String target)
Adds theAsset
as a resource to the container, returning the container itself.T
addAsResource(Asset resource, ArchivePath target)
Adds theAsset
as a resource to the container, returning the container itself.T
addAsResources(Package resourcePackage, String... resourceNames)
Adds the resources inside the package as multiple resources to the container, returning the container itself.T
addAsServiceProvider(Class<?> serviceInterface, Class<?>... serviceImpls)
Adds a META-INF/services/ServiceInterfaceNameAsset
representing this service.T
addAsServiceProvider(String serviceInterface, String... serviceImpls)
Adds a META-INF/services/ServiceInterfaceNameAsset
representing this service.T
addAsServiceProviderAndClasses(Class<?> serviceInterface, Class<?>... serviceImpls)
Adds a META-INF/services/ServiceInterfaceNameAsset
and the classes related to the service to the archive.T
addClass(Class<?> clazz)
T
addClass(String fullyQualifiedClassName)
Adds theClass
, and all member (inner)Class
es, with the specified fully-qualified name, loaded by the Thread ContextClassLoader
, to theArchive
.T
addClass(String fullyQualifiedClassName, ClassLoader cl)
Adds theClass
, and all member (inner) @link{Class}es, with the specified fully-qualified name, loaded by the specifiedClassLoader
, to theArchive
.T
addClasses(Class<?>... classes)
T
addDefaultPackage()
T
addHandlers(ArchiveEventHandler... handlers)
Add an array of listeners for call back based.T
addManifest()
Adds a default generated MANIFEST.MF manifest to the current archive.T
addPackage(Package pack)
T
addPackage(String pack)
T
addPackages(boolean recursive, Package... packages)
T
addPackages(boolean recursive, String... packages)
T
addPackages(boolean recursive, Filter<ArchivePath> filter, Package... packages)
T
addPackages(boolean recursive, Filter<ArchivePath> filter, String... packageNames)
boolean
contains(String path)
Denotes whether this archive contains a resource at the specified pathboolean
contains(ArchivePath path)
Denotes whether this archive contains a resource at the specified pathprotected T
covarientReturn()
Node
delete(String archivePath)
Node
delete(ArchivePath path)
T
deleteClass(Class<?> clazz)
T
deleteClass(String fullyQualifiedClassName)
Deletes theClass
, and all member (inner)Class
es, with the specified fully-qualified name, loaded by the Thread ContextClassLoader
, from theArchive
.T
deleteClasses(Class<?>... classes)
T
deleteDefaultPackage()
T
deletePackage(Package pack)
T
deletePackage(String pack)
T
deletePackages(boolean recursive, Package... packages)
T
deletePackages(boolean recursive, String... packages)
T
deletePackages(boolean recursive, Filter<ArchivePath> filter, Package... packages)
T
deletePackages(boolean recursive, Filter<ArchivePath> filter, String... packages)
boolean
equals(Object obj)
T
filter(Filter<ArchivePath> filter)
Obtains all assets matching given filter in this archive as a new Archive.
This is an alias for shallowCopy(Filter).Node
get(String path)
Obtains theNode
located at the specified pathNode
get(ArchivePath path)
Obtains theNode
located at the specified pathprotected Class<T>
getActualClass()
ArchiveFormat
getArchiveFormat()
<X extends Archive<X>>
XgetAsType(Class<X> type, String path)
Get a nestedArchive
as a specific type.
The found Archives must have been added as a Archive, no import is performed.<X extends Archive<X>>
XgetAsType(Class<X> type, String path, ArchiveFormat archiveCompression)
Get a nestedArchive
as a specific type using the specifyArchiveFormat
<X extends Archive<X>>
XgetAsType(Class<X> type, ArchivePath path)
Get a nestedArchive
as a specific type.
The found Archives must have been added as a Archive, no import is performed.<X extends Archive<X>>
XgetAsType(Class<X> type, ArchivePath path, ArchiveFormat archiveCompression)
<X extends Archive<X>>
Collection<X>getAsType(Class<X> type, Filter<ArchivePath> filter)
Get all nestedArchive
matching the filter as a specific type.
The found Archives must have been added as a Archive, no import is performed.<X extends Archive<X>>
Collection<X>getAsType(Class<X> type, Filter<ArchivePath> filter, ArchiveFormat archiveCompression)
Get all nestedArchive
matching the filter as a specific type using the specifyArchiveFormat
.protected abstract ArchivePath
getClassesPath()
Should be implemented to set the path for Class related resources.Map<ArchivePath,Node>
getContent()
Obtains all assets in this archive, along with their respective paths.Map<ArchivePath,Node>
getContent(Filter<ArchivePath> filter)
Obtains all assets matching given filter in this archive, along with its respective Path.String
getId()
Obtains a globally-unique identifier for thisArchive
protected abstract ArchivePath
getLibraryPath()
Should be implemented to set the path for Library related resources.protected abstract ArchivePath
getManifestPath()
Should be implemented to set the path for Manifest related resources.String
getName()
Obtains the name of this archive (ie.protected abstract ArchivePath
getResourcePath()
Should be implemented to set the path for Resource related resources.int
hashCode()
T
merge(Archive<?> source)
Merge the contents from an existing archive without maintaining the archive name in the context path.T
merge(Archive<?> source, String path)
Merge the contents from an existing archive in a specific path without maintaining the archive name in the context path.T
merge(Archive<?> source, String path, Filter<ArchivePath> filter)
Merge the contents from an existing archive in a specific path without maintaining the archive name in the context path.T
merge(Archive<?> source, ArchivePath path)
Merge the contents from an existing archive in a specific path without maintaining the archive name in the context path.T
merge(Archive<?> source, ArchivePath path, Filter<ArchivePath> filter)
Merge the contents from an existing archive in a specific path without maintaining the archive name in the context path.T
merge(Archive<?> source, Filter<ArchivePath> filter)
Merge the contents from an existing archive without maintaining the archive name in the context path.T
move(String source, String target)
Moves the asset under the source path to the target path.T
move(ArchivePath source, ArchivePath target)
Moves the asset under the source path to the target path.T
setManifest(File resource)
Adds theFile
as MANIFEST.FM to the container, returning the container itself.T
setManifest(Package resourcePackage, String resourceName)
Adds the resource inside the package as a MANIFEST.MF to the container, returning the container itself.T
setManifest(String resourceName)
Adds the resource as MANIFEST.FM to the container, returning the container itself.T
setManifest(URL resource)
Adds theURL
as MANIFEST.FM to the container, returning the container itself.T
setManifest(Asset resource)
Adds theAsset
as MANIFEST.FM to the container, returning the container itself.Archive<T>
shallowCopy()
Creates a shallow copy of thisArchive
.Archive<T>
shallowCopy(Filter<ArchivePath> filter)
Creates a shallow copy of thisArchive
based on given filter.Assets from this archive are made available under the same paths.String
toString()
Acts as a shorthand forArchive.toString(Formatter)
where theFormatters.SIMPLE
is leveraged.String
toString(boolean verbose)
If "true" is specified, acts as a shorthand forArchive.toString(Formatter)
where theFormatters.VERBOSE
is leveraged.String
toString(Formatter formatter)
void
writeTo(OutputStream outputStream, Formatter formatter)
Prints the content of thisArchive
to the specifiedOutputStream
on the format defined by the specifiedFormatter
.-
Methods inherited from class org.jboss.shrinkwrap.impl.base.AssignableBase
as, getArchive
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.jboss.shrinkwrap.api.Assignable
as
-
-
-
-
Method Detail
-
getArchiveFormat
public ArchiveFormat getArchiveFormat()
- Specified by:
getArchiveFormat
in interfaceArchiveFormatAssociable
-
add
public T add(Archive<?> archive, String path, Class<? extends StreamExporter> exporter)
Add an archive under a specific context and maintain the archive name as context path.- Specified by:
add
in interfaceArchive<T extends Archive<T>>
- Parameters:
archive
- to addpath
- to useexporter
- Exporter type to use in fulfilling theAsset.openStream()
contract for the added (nested) archive.- Returns:
- See Also:
Archive.add(org.jboss.shrinkwrap.api.Archive, java.lang.String, java.lang.Class)
-
add
public T add(Archive<?> archive, ArchivePath path, Class<? extends StreamExporter> exporter)
Add an archive under a specific context and maintain the archive name as context path.- Specified by:
add
in interfaceArchive<T extends Archive<T>>
- Parameters:
archive
- to addpath
- to useexporter
- Exporter type to use in fulfilling theAsset.openStream()
contract for the added (nested) archive.- Returns:
- See Also:
Archive.add(org.jboss.shrinkwrap.api.Archive, org.jboss.shrinkwrap.api.ArchivePath, java.lang.Class)
-
add
public T add(Asset asset, ArchivePath target) throws IllegalArgumentException
Adds the specified asset under the specified path into the target context- Specified by:
add
in interfaceArchive<T extends Archive<T>>
target
- The context under which to add the assets- Returns:
- Throws:
IllegalArgumentException
- If no target or assets were specified- See Also:
Archive.add(org.jboss.shrinkwrap.api.asset.Asset, org.jboss.shrinkwrap.api.ArchivePath)
-
add
public T add(Asset asset, ArchivePath path, String name)
Adds the specified asset under the specified target (directory) using the specified name. The resultant path will be treating the specified path as a prefix namespace, then appending the name.- Specified by:
add
in interfaceArchive<T extends Archive<T>>
path
- The context directory under which to add the assetname
- The name to assign the assent under the target namespace- Returns:
- See Also:
Archive.add(org.jboss.shrinkwrap.api.asset.Asset, org.jboss.shrinkwrap.api.ArchivePath, java.lang.String)
-
add
public T add(Asset asset, String target, String name) throws IllegalArgumentException
Adds the specified asset under the specified target (directory) using the specified name. The resultant path will be treating the specified path as a prefix namespace, then appending the name.- Specified by:
add
in interfaceArchive<T extends Archive<T>>
target
- The context directory under which to add the assetname
- The name to assign the assent under the target namespace- Returns:
- Throws:
IllegalArgumentException
- If the target, name, or asset was not specified- See Also:
Archive.add(org.jboss.shrinkwrap.api.asset.Asset, java.lang.String, java.lang.String)
-
add
public T add(NamedAsset namedAsset)
Adds the asset encapsulated within the specifiedNamedAsset
under the encapsulated name and target (directory)
-
addAsDirectories
public T addAsDirectories(ArchivePath... paths) throws IllegalArgumentException
Adds the specified directories.- Specified by:
addAsDirectories
in interfaceArchive<T extends Archive<T>>
- Parameters:
paths
- The paths to add- Returns:
- This archive
- Throws:
IllegalArgumentException
- If no paths were specified- See Also:
Archive.addAsDirectories(org.jboss.shrinkwrap.api.ArchivePath[])
-
addAsDirectories
public T addAsDirectories(String... paths) throws IllegalArgumentException
Adds the specified directories.- Specified by:
addAsDirectories
in interfaceArchive<T extends Archive<T>>
- Parameters:
paths
- The paths to add- Returns:
- This archive
- Throws:
IllegalArgumentException
- If no paths were specified- See Also:
Archive.addAsDirectories(java.lang.String[])
-
addAsDirectory
public T addAsDirectory(ArchivePath path) throws IllegalArgumentException
Adds the specified directory.- Specified by:
addAsDirectory
in interfaceArchive<T extends Archive<T>>
- Parameters:
path
- The path to add- Returns:
- This archive
- Throws:
IllegalArgumentException
- If no path was specified- See Also:
Archive.addAsDirectory(org.jboss.shrinkwrap.api.ArchivePath)
-
addAsDirectory
public T addAsDirectory(String path) throws IllegalArgumentException
Adds the specified directory.- Specified by:
addAsDirectory
in interfaceArchive<T extends Archive<T>>
- Parameters:
path
- The path to add- Returns:
- This archive
- Throws:
IllegalArgumentException
- If no path was specified- See Also:
Archive.addAsDirectory(java.lang.String)
-
addHandlers
public T addHandlers(ArchiveEventHandler... handlers)
Add an array of listeners for call back based.- Specified by:
addHandlers
in interfaceArchive<T extends Archive<T>>
- Returns:
- This archive
- See Also:
org.jboss.shrinkwrap.api.Archive#addHandlers(org.jboss.shrinkwrap.api.Filter, org.jboss.shrinkwrap.api.ArchiveEventHandler)
-
merge
public T merge(Archive<?> source) throws IllegalArgumentException
Merge the contents from an existing archive without maintaining the archive name in the context path.- Specified by:
merge
in interfaceArchive<T extends Archive<T>>
- Parameters:
source
- Archive to add contents from- Returns:
- Throws:
IllegalArgumentException
- If the existing archive is not specified- See Also:
Archive.merge(org.jboss.shrinkwrap.api.Archive)
-
merge
public T merge(Archive<?> source, Filter<ArchivePath> filter) throws IllegalArgumentException
Merge the contents from an existing archive without maintaining the archive name in the context path. The filter control whichArchivePath
s to include form the sourceArchive
.- Specified by:
merge
in interfaceArchive<T extends Archive<T>>
- Parameters:
source
- Archive to add contents from- Returns:
- Throws:
IllegalArgumentException
- If the existing archive is not specified- See Also:
Archive.merge(org.jboss.shrinkwrap.api.Archive, org.jboss.shrinkwrap.api.Filter)
-
merge
public T merge(Archive<?> source, ArchivePath path) throws IllegalArgumentException
Merge the contents from an existing archive in a specific path without maintaining the archive name in the context path.- Specified by:
merge
in interfaceArchive<T extends Archive<T>>
- Parameters:
source
- Archive to add contents frompath
- Path to add contents to- Returns:
- Throws:
IllegalArgumentException
- If the path or existing archive is not specified- See Also:
Archive.merge(org.jboss.shrinkwrap.api.Archive, org.jboss.shrinkwrap.api.ArchivePath)
-
merge
public T merge(Archive<?> source, ArchivePath path, Filter<ArchivePath> filter) throws IllegalArgumentException
Merge the contents from an existing archive in a specific path without maintaining the archive name in the context path. The filter control whichArchivePath
s to include form the sourceArchive
.- Specified by:
merge
in interfaceArchive<T extends Archive<T>>
- Parameters:
source
- Archive to add contents frompath
- Path to add contents tofilter
- Filter to use for includingAsset
s in the merge.- Returns:
- Throws:
IllegalArgumentException
- If the path or existing archive is not specified- See Also:
Archive.merge(org.jboss.shrinkwrap.api.Archive, org.jboss.shrinkwrap.api.ArchivePath, org.jboss.shrinkwrap.api.Filter)
-
merge
public T merge(Archive<?> source, String path, Filter<ArchivePath> filter) throws IllegalArgumentException
Merge the contents from an existing archive in a specific path without maintaining the archive name in the context path. The filter control whichArchivePath
s to include form the sourceArchive
.- Specified by:
merge
in interfaceArchive<T extends Archive<T>>
- Parameters:
source
- Archive to add contents frompath
- Path to add contents tofilter
- Filter to use for includingAsset
s in the merge.- Returns:
- Throws:
IllegalArgumentException
- If the path or existing archive is not specified- See Also:
Archive.merge(org.jboss.shrinkwrap.api.Archive, java.lang.String, org.jboss.shrinkwrap.api.Filter)
-
merge
public T merge(Archive<?> source, String path) throws IllegalArgumentException
Merge the contents from an existing archive in a specific path without maintaining the archive name in the context path.- Specified by:
merge
in interfaceArchive<T extends Archive<T>>
- Parameters:
source
- Archive to add contents frompath
- Path to add contents to- Returns:
- Throws:
IllegalArgumentException
- If the path or existing archive is not specified- See Also:
Archive.merge(org.jboss.shrinkwrap.api.Archive, java.lang.String)
-
move
public T move(ArchivePath source, ArchivePath target) throws IllegalArgumentException, IllegalArchivePathException
Moves the asset under the source path to the target path.- Specified by:
move
in interfaceArchive<T extends Archive<T>>
- Parameters:
source
- The context under which to remove the assetstarget
- The context under which to add the moved assets- Returns:
- the resulting archive with the moved assets
- Throws:
IllegalArgumentException
- If any of the paths is not specifiedIllegalArchivePathException
- If the source path is invalid.- See Also:
Archive.move(org.jboss.shrinkwrap.api.ArchivePath, org.jboss.shrinkwrap.api.ArchivePath)
-
move
public T move(String source, String target) throws IllegalArgumentException, IllegalArchivePathException
Moves the asset under the source path to the target path.- Specified by:
move
in interfaceArchive<T extends Archive<T>>
- Parameters:
source
- The context under which to remove the assetstarget
- The context under which to add the moved assets- Returns:
- the resulting archive with the moved assets
- Throws:
IllegalArgumentException
- If any of the paths is not specifiedIllegalArchivePathException
- If the source path is invalid.- See Also:
Archive.move(java.lang.String, java.lang.String)
-
add
public T add(Asset asset, String name)
Adds the specified resource under the context denoted by the specified target
-
contains
public boolean contains(ArchivePath path)
Denotes whether this archive contains a resource at the specified path
-
contains
public boolean contains(String path) throws IllegalArgumentException
Denotes whether this archive contains a resource at the specified path- Specified by:
contains
in interfaceArchive<T extends Archive<T>>
- Returns:
- Throws:
IllegalArgumentException
- If the path is not specified- See Also:
Archive.contains(java.lang.String)
-
delete
public Node delete(ArchivePath path)
Removes theNode
in theArchive
at the specifiedArchivePath
. If the path is a directory, recursively removes all contents. If the path does not exist, return null.
-
delete
public Node delete(String archivePath)
Removes theNode
in theArchive
at theArchivePath
indicated by the specified String archivePath. If the path is a directory, recursively removes all contents. If the path does not exist, return null.
-
get
public Node get(ArchivePath path)
Obtains theNode
located at the specified path
-
get
public Node get(String path) throws IllegalArgumentException
Obtains theNode
located at the specified path- Specified by:
get
in interfaceArchive<T extends Archive<T>>
- Returns:
- The
Node
, or null if nothing is found at the Path - Throws:
IllegalArgumentException
- If the path is not specified- See Also:
Archive.get(java.lang.String)
-
getAsType
public <X extends Archive<X>> X getAsType(Class<X> type, String path)
Get a nestedArchive
as a specific type.
The found Archives must have been added as a Archive, no import is performed.
-
getAsType
public <X extends Archive<X>> X getAsType(Class<X> type, ArchivePath path)
Get a nestedArchive
as a specific type.
The found Archives must have been added as a Archive, no import is performed.- Specified by:
getAsType
in interfaceArchive<T extends Archive<T>>
- Parameters:
type
- The Type to return the Archive aspath
- The location of the Archive- Returns:
- The found Archive as given type or null if none found at given
ArchivePath
- See Also:
Archive.getAsType(java.lang.Class, org.jboss.shrinkwrap.api.ArchivePath)
-
getAsType
public <X extends Archive<X>> Collection<X> getAsType(Class<X> type, Filter<ArchivePath> filter)
Get all nestedArchive
matching the filter as a specific type.
The found Archives must have been added as a Archive, no import is performed.- Specified by:
getAsType
in interfaceArchive<T extends Archive<T>>
- Parameters:
type
- The Type to return the Archive asfilter
- Filter to match result- Returns:
- A
Collection
of found Archives matching given filter or emptyCollection
if non found. - See Also:
Archive.getAsType(java.lang.Class, org.jboss.shrinkwrap.api.Filter)
-
getAsType
public <X extends Archive<X>> X getAsType(Class<X> type, String path, ArchiveFormat archiveCompression)
Get a nestedArchive
as a specific type using the specifyArchiveFormat
- Specified by:
getAsType
in interfaceArchive<T extends Archive<T>>
- Parameters:
type
- The Type to return the Archive aspath
- The location of the ArchivearchiveCompression
- The archive format- Returns:
- The found Archive as given type or null if none found at the given path
- See Also:
Archive.getAsType(java.lang.Class, java.lang.String, org.jboss.shrinkwrap.api.ArchiveFormat)
-
getAsType
public <X extends Archive<X>> X getAsType(Class<X> type, ArchivePath path, ArchiveFormat archiveCompression)
- Specified by:
getAsType
in interfaceArchive<T extends Archive<T>>
- Parameters:
type
- The Type to return the Archive aspath
- The location of the ArchivearchiveCompression
- The archive format- Returns:
- The found Archive as given type or null if none found at given
ArchivePath
- See Also:
Archive.getAsType(java.lang.Class, org.jboss.shrinkwrap.api.ArchivePath, org.jboss.shrinkwrap.api.ArchiveFormat)
-
getAsType
public <X extends Archive<X>> Collection<X> getAsType(Class<X> type, Filter<ArchivePath> filter, ArchiveFormat archiveCompression)
Get all nestedArchive
matching the filter as a specific type using the specifyArchiveFormat
.- Specified by:
getAsType
in interfaceArchive<T extends Archive<T>>
- Parameters:
type
- The Type to return the Archive asfilter
- Filter to match resultarchiveCompression
- The archive format- Returns:
- A
Collection
of found Archives matching given filter or emptyCollection
if non found. - See Also:
Archive.getAsType(java.lang.Class, org.jboss.shrinkwrap.api.Filter, org.jboss.shrinkwrap.api.ArchiveFormat)
-
filter
public T filter(Filter<ArchivePath> filter)
Obtains all assets matching given filter in this archive as a new Archive.
This is an alias for shallowCopy(Filter).
-
getContent
public Map<ArchivePath,Node> getContent()
Obtains all assets in this archive, along with their respective paths. The returned Map will be an immutable view.- Specified by:
getContent
in interfaceArchive<T extends Archive<T>>
- Returns:
- See Also:
Archive.getContent()
-
getContent
public Map<ArchivePath,Node> getContent(Filter<ArchivePath> filter)
Obtains all assets matching given filter in this archive, along with its respective Path. The returned Map will be an immutable view.- Specified by:
getContent
in interfaceArchive<T extends Archive<T>>
- Returns:
- See Also:
Archive.getContent(org.jboss.shrinkwrap.api.Filter)
-
getName
public String getName()
Obtains the name of this archive (ie. myLibrary.jar)
-
shallowCopy
public Archive<T> shallowCopy()
Creates a shallow copy of thisArchive
. Assets from this archive are made available under the same paths. However, removing old assets or adding new assets on this archive affects does not affect the new archive.- Specified by:
shallowCopy
in interfaceArchive<T extends Archive<T>>
- Returns:
- a new archive with a copy of the pointers to the assets
- See Also:
Archive.shallowCopy()
-
shallowCopy
public Archive<T> shallowCopy(Filter<ArchivePath> filter)
Creates a shallow copy of thisArchive
based on given filter.Assets from this archive are made available under the same paths. However, removing old assets or adding new assets on this archive affects does not affect the new archive.- Specified by:
shallowCopy
in interfaceArchive<T extends Archive<T>>
- Returns:
- a new archive with a copy of the pointers to the assets
- See Also:
Archive.shallowCopy(Filter)
-
toString
public String toString()
Acts as a shorthand forArchive.toString(Formatter)
where theFormatters.SIMPLE
is leveraged.
-
toString
public String toString(boolean verbose)
If "true" is specified, acts as a shorthand forArchive.toString(Formatter)
where theFormatters.VERBOSE
is leveraged. Otherwise theFormatters.SIMPLE
will be used (equivalent toArchive.toString()
).
-
toString
public String toString(Formatter formatter) throws IllegalArgumentException
Returns a view of thisArchive
as returned from the specifiedFormatter
. Common options may be to use the predefined formatters located inFormatters
- Specified by:
toString
in interfaceArchive<T extends Archive<T>>
- Returns:
- Throws:
IllegalArgumentException
- If the formatter is not specified- See Also:
Archive.toString(org.jboss.shrinkwrap.api.formatter.Formatter)
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classObject
- See Also:
Object.hashCode()
-
equals
public boolean equals(Object obj)
- Overrides:
equals
in classObject
- See Also:
Object.equals(java.lang.Object)
-
getManifestPath
protected abstract ArchivePath getManifestPath()
Should be implemented to set the path for Manifest related resources.- Returns:
- Base Path for the ManifestContainer resources
-
setManifest
public final T setManifest(String resourceName)
Adds the resource as MANIFEST.FM to the container, returning the container itself.
TheClassLoader
used to obtain the resource is up to the implementation.- Specified by:
setManifest
in interfaceManifestContainer<T extends Archive<T>>
- Parameters:
resourceName
- resource to add- Returns:
- This virtual archive
- See Also:
ManifestContainer.setManifest(java.lang.String)
-
setManifest
public T setManifest(File resource) throws IllegalArgumentException
Adds theFile
as MANIFEST.FM to the container, returning the container itself.- Specified by:
setManifest
in interfaceManifestContainer<T extends Archive<T>>
- Parameters:
resource
-File
resource to add- Returns:
- This virtual archive
- Throws:
IllegalArgumentException
- if resource is null- See Also:
ManifestContainer.setManifest(java.io.File)
-
setManifest
public T setManifest(URL resource) throws IllegalArgumentException
Adds theURL
as MANIFEST.FM to the container, returning the container itself.- Specified by:
setManifest
in interfaceManifestContainer<T extends Archive<T>>
- Parameters:
resource
-URL
resource to add- Returns:
- This virtual archive
- Throws:
IllegalArgumentException
- if resource is null- See Also:
ManifestContainer.setManifest(java.net.URL)
-
setManifest
public T setManifest(Asset resource) throws IllegalArgumentException
Adds theAsset
as MANIFEST.FM to the container, returning the container itself.- Specified by:
setManifest
in interfaceManifestContainer<T extends Archive<T>>
- Parameters:
resource
-File
resource to add- Returns:
- This virtual archive
- Throws:
IllegalArgumentException
- if resource is null- See Also:
ManifestContainer.setManifest(org.jboss.shrinkwrap.api.asset.Asset)
-
setManifest
public T setManifest(Package resourcePackage, String resourceName) throws IllegalArgumentException
Adds the resource inside the package as a MANIFEST.MF to the container, returning the container itself.
TheClassLoader
used to obtain the resource is up to the implementation.- Specified by:
setManifest
in interfaceManifestContainer<T extends Archive<T>>
- Parameters:
resourcePackage
- The package of the resourceresourceName
- The name of the resource inside resoucePackage- Returns:
- This virtual archive
- Throws:
IllegalArgumentException
- if resourcePackage is null- See Also:
ManifestContainer.setManifest(java.lang.Package, java.lang.String)
-
addAsManifestResource
public final T addAsManifestResource(String resourceName)
Adds the resource as a Manifest resource to the container, returning the container itself.
The resource will be placed into the Container Manifest path under the same context from which it was retrieved.
TheClassLoader
used to obtain the resource is up to the implementation.- Specified by:
addAsManifestResource
in interfaceManifestContainer<T extends Archive<T>>
- Parameters:
resourceName
- resource to add- Returns:
- This virtual archive
- See Also:
ManifestContainer.addAsManifestResource(java.lang.String)
-
addAsManifestResource
public T addAsManifestResource(File resource) throws IllegalArgumentException
Adds theFile
as a Manifest resource to the container, returning the container itself.
TheFile
will be placed into the Container Manifest path underFile.getName()
.- Specified by:
addAsManifestResource
in interfaceManifestContainer<T extends Archive<T>>
- Parameters:
resource
- resource to add- Returns:
- This virtual archive
- Throws:
IllegalArgumentException
- ifFile
resource is null- See Also:
ManifestContainer.addAsManifestResource(java.io.File)
-
addAsManifestResource
public T addAsManifestResource(String resourceName, String target) throws IllegalArgumentException
Adds the resource as a Manifest resource to the container, returning the container itself.
TheClassLoader
used to obtain the resource is up to the implementation.- Specified by:
addAsManifestResource
in interfaceManifestContainer<T extends Archive<T>>
- Parameters:
resourceName
- resource to addtarget
- The target path within the archive in which to add the resource, relative to theArchive
s manifest path.- Returns:
- This virtual archive
- Throws:
IllegalArgumentException
- if resourceName is null- See Also:
ManifestContainer.addAsManifestResource(java.lang.String, java.lang.String)
-
addAsManifestResource
public T addAsManifestResource(File resource, String target) throws IllegalArgumentException
Adds theFile
as a Manifest resource to the container, returning the container itself.- Specified by:
addAsManifestResource
in interfaceManifestContainer<T extends Archive<T>>
- Parameters:
resource
-File
resource to addtarget
- The target path within the archive in which to add the resource, relative to theArchive
s manifest path.- Returns:
- This virtual archive
- Throws:
IllegalArgumentException
- if resource is null- See Also:
ManifestContainer.addAsManifestResource(java.io.File, java.lang.String)
-
addAsManifestResource
public T addAsManifestResource(URL resource, String target) throws IllegalArgumentException
Description copied from interface:ManifestContainer
Adds theURL
as a Manifest resource to the container, returning the container itself.- Specified by:
addAsManifestResource
in interfaceManifestContainer<T extends Archive<T>>
- Parameters:
resource
-URL
resource to addtarget
- The target path within the archive in which to add the resource, relative to theArchive
s manifest path.- Returns:
- This virtual archive
- Throws:
IllegalArgumentException
- if resource is null- See Also:
ManifestContainer.addAsManifestResource(Asset, ArchivePath)
-
addAsManifestResource
public T addAsManifestResource(Asset resource, String target) throws IllegalArgumentException
Description copied from interface:ManifestContainer
Adds theAsset
as a Manifest resource to the container, returning the container itself.- Specified by:
addAsManifestResource
in interfaceManifestContainer<T extends Archive<T>>
- Parameters:
resource
-Asset
resource to addtarget
- The target path within the archive in which to add the resource, relative to theArchive
s manifest path.- Returns:
- This virtual archive
- Throws:
IllegalArgumentException
- if resource is null- See Also:
ManifestContainer.addAsManifestResource(Asset, ArchivePath)
-
addAsManifestResource
public T addAsManifestResource(String resourceName, ArchivePath target) throws IllegalArgumentException
Description copied from interface:ManifestContainer
Adds the resource as a Manifest resource to the container, returning the container itself.
TheClassLoader
used to obtain the resource is up to the implementation.- Specified by:
addAsManifestResource
in interfaceManifestContainer<T extends Archive<T>>
- Parameters:
resourceName
- resource to addtarget
- The target path within the archive in which to add the resource, relative to theArchive
s manifest path.- Returns:
- This virtual archive
- Throws:
IllegalArgumentException
- if resourceName is null- See Also:
ManifestContainer.addAsManifestResource(Asset, ArchivePath)
-
addAsManifestResource
public T addAsManifestResource(File resource, ArchivePath target) throws IllegalArgumentException
Description copied from interface:ManifestContainer
Adds theFile
as a Manifest resource to the container, returning the container itself.- Specified by:
addAsManifestResource
in interfaceManifestContainer<T extends Archive<T>>
- Parameters:
resource
-File
resource to addtarget
- The target path within the archive in which to add the resource, relative to theArchive
s manifest path.- Returns:
- This virtual archive
- Throws:
IllegalArgumentException
- if resource is null- See Also:
ManifestContainer.addAsManifestResource(Asset, ArchivePath)
-
addAsManifestResource
public T addAsManifestResource(URL resource, ArchivePath target) throws IllegalArgumentException
Description copied from interface:ManifestContainer
Adds theURL
as a Manifest resource to the container, returning the container itself.- Specified by:
addAsManifestResource
in interfaceManifestContainer<T extends Archive<T>>
- Parameters:
resource
-URL
resource to addtarget
- The target path within the archive in which to add the resource, relative to theArchive
s manifest path.- Returns:
- This virtual archive
- Throws:
IllegalArgumentException
- if resource is null- See Also:
ManifestContainer.addAsManifestResource(Asset, ArchivePath)
-
addAsManifestResource
public T addAsManifestResource(Asset resource, ArchivePath target) throws IllegalArgumentException
Description copied from interface:ManifestContainer
Adds theAsset
as a Manifest resource to the container, returning the container itself.- Specified by:
addAsManifestResource
in interfaceManifestContainer<T extends Archive<T>>
- Parameters:
resource
-Asset
resource to addtarget
- The target path within the archive in which to add the resource, relative to theArchive
s manifest path.- Returns:
- This virtual archive
- Throws:
IllegalArgumentException
- if resource is null
-
addAsManifestResources
public T addAsManifestResources(Package resourcePackage, String... resourceNames) throws IllegalArgumentException
Description copied from interface:ManifestContainer
Adds the resources inside the package as multiple resources to the container, returning the container itself.
TheClassLoader
used to obtain the resource is up to the implementation.- Specified by:
addAsManifestResources
in interfaceManifestContainer<T extends Archive<T>>
- Parameters:
resourcePackage
- The package of the resourcesresourceNames
- The names of the resources inside resoucePackage- Returns:
- This virtual archive
- Throws:
IllegalArgumentException
- if resourcePackage is null
-
addAsManifestResource
public T addAsManifestResource(Package resourcePackage, String resourceName) throws IllegalArgumentException
Description copied from interface:ManifestContainer
Adds the resource as a resource to the container, returning the container itself.
TheClassLoader
used to obtain the resource is up to the implementation.- Specified by:
addAsManifestResource
in interfaceManifestContainer<T extends Archive<T>>
- Parameters:
resourcePackage
- The package of the resourceresourceName
- The name of the resource inside resoucePackage- Returns:
- This virtual archive
- Throws:
IllegalArgumentException
- if resourcePackage is null
-
addAsManifestResource
public T addAsManifestResource(Package resourcePackage, String resourceName, String target) throws IllegalArgumentException
Description copied from interface:ManifestContainer
Adds the resource as a resource to a specific path inside the container, returning the container itself.
TheClassLoader
used to obtain the resource is up to the implementation.- Specified by:
addAsManifestResource
in interfaceManifestContainer<T extends Archive<T>>
- Parameters:
resourcePackage
- The package of the resourceresourceName
- The name of the resource inside resoucePackagetarget
- The target location inside the container- Returns:
- This virtual archive
- Throws:
IllegalArgumentException
- if resourcePackage is null
-
addAsManifestResource
public T addAsManifestResource(Package resourcePackage, String resourceName, ArchivePath target) throws IllegalArgumentException
Description copied from interface:ManifestContainer
Adds the resource as a resource to a specific path inside the container, returning the container itself.
TheClassLoader
used to obtain the resource is up to the implementation.- Specified by:
addAsManifestResource
in interfaceManifestContainer<T extends Archive<T>>
- Parameters:
resourcePackage
- The package of the resourceresourceName
- The name of the resource inside resoucePackagetarget
- The target location inside the container- Returns:
- This virtual archive
- Throws:
IllegalArgumentException
- if resourcePackage is null
-
addManifest
public T addManifest() throws IllegalArgumentException
Adds a default generated MANIFEST.MF manifest to the current archive.- Specified by:
addManifest
in interfaceManifestContainer<T extends Archive<T>>
- Returns:
- This virtual archive
- Throws:
IllegalArgumentException
- if serviceInterface is null
-
addAsServiceProvider
public T addAsServiceProvider(Class<?> serviceInterface, Class<?>... serviceImpls) throws IllegalArgumentException
Description copied from interface:ManifestContainer
Adds a META-INF/services/ServiceInterfaceNameAsset
representing this service. Warning: this method does not add the specified classes to the archive.- Specified by:
addAsServiceProvider
in interfaceManifestContainer<T extends Archive<T>>
- Parameters:
serviceInterface
- The Service Interface classserviceImpls
- The Service Interface Implementations- Returns:
- This virtual archive
- Throws:
IllegalArgumentException
- if serviceInterface is null
-
addAsServiceProvider
public T addAsServiceProvider(String serviceInterface, String... serviceImpls) throws IllegalArgumentException
Description copied from interface:ManifestContainer
Adds a META-INF/services/ServiceInterfaceNameAsset
representing this service.- Specified by:
addAsServiceProvider
in interfaceManifestContainer<T extends Archive<T>>
- Parameters:
serviceInterface
- The Service Interface class nameserviceImpls
- The Service Interface Implementations class names- Returns:
- This virtual archive
- Throws:
IllegalArgumentException
- if serviceInterface is null- See Also:
ManifestContainer.addAsServiceProvider(Class, Class...)
-
addAsServiceProviderAndClasses
public T addAsServiceProviderAndClasses(Class<?> serviceInterface, Class<?>... serviceImpls) throws IllegalArgumentException
Description copied from interface:ServiceProviderContainer
Adds a META-INF/services/ServiceInterfaceNameAsset
and the classes related to the service to the archive.- Specified by:
addAsServiceProviderAndClasses
in interfaceServiceProviderContainer<T extends Archive<T>>
- Parameters:
serviceInterface
- The Service Interface classserviceImpls
- The Service Interface Implementations- Returns:
- This virtual archive
- Throws:
IllegalArgumentException
- if serviceInterface is null
-
getResourcePath
protected abstract ArchivePath getResourcePath()
Should be implemented to set the path for Resource related resources.- Returns:
- Base Path for the ResourceContainer resources
-
addAsResource
public final T addAsResource(String resourceName) throws IllegalArgumentException
Description copied from interface:ResourceContainer
Adds the resource as a resource to the container, returning the container itself.
The resource will be placed into the Container Resource path under the same context from which it was retrieved.
TheClassLoader
used to obtain the resource is up to the implementation.- Specified by:
addAsResource
in interfaceResourceContainer<T extends Archive<T>>
- Parameters:
resourceName
- resource to add- Returns:
- This virtual archive
- Throws:
IllegalArgumentException
- If the resourceName is null- See Also:
ResourceContainer.addAsResource(Asset, ArchivePath)
-
addAsResource
public final T addAsResource(File resource) throws IllegalArgumentException
Description copied from interface:ResourceContainer
Adds theFile
as a resource to the container, returning the container itself.
TheFile
will be placed into the Container Library path underFile.getName()
.- Specified by:
addAsResource
in interfaceResourceContainer<T extends Archive<T>>
- Parameters:
resource
-File
resource to add- Returns:
- This virtual archive
- Throws:
IllegalArgumentException
- If the resource is null- See Also:
ResourceContainer.addAsResource(Asset, ArchivePath)
-
addAsResource
public final T addAsResource(String resourceName, String target) throws IllegalArgumentException
Description copied from interface:ResourceContainer
Adds the resource as a resource to the container, returning the container itself.
TheClassLoader
used to obtain the resource is up to the implementation.- Specified by:
addAsResource
in interfaceResourceContainer<T extends Archive<T>>
- Parameters:
resourceName
- resource to addtarget
- The target path within the archive in which to add the resource, relative to theArchive
s resource path.- Returns:
- This virtual archive
- Throws:
IllegalArgumentException
- if resourceName is null- See Also:
ResourceContainer.addAsResource(Asset, ArchivePath)
-
addAsResource
public T addAsResource(File resource, String target) throws IllegalArgumentException
Description copied from interface:ResourceContainer
Adds theFile
as a resource to the container, returning the container itself.- Specified by:
addAsResource
in interfaceResourceContainer<T extends Archive<T>>
- Parameters:
resource
-File
resource to addtarget
- The target path within the archive in which to add the resource, relative to theArchive
s resource path.- Returns:
- This virtual archive
- Throws:
IllegalArgumentException
- if resource is null- See Also:
ResourceContainer.addAsResource(Asset, ArchivePath)
-
addAsResource
public T addAsResource(URL resource, String target) throws IllegalArgumentException
Description copied from interface:ResourceContainer
Adds theURL
as a resource to the container, returning the container itself.- Specified by:
addAsResource
in interfaceResourceContainer<T extends Archive<T>>
- Parameters:
resource
-URL
resource to addtarget
- The target path within the archive in which to add the resource, relative to theArchive
s resource path.- Returns:
- This virtual archive
- Throws:
IllegalArgumentException
- if resource is null- See Also:
ResourceContainer.addAsResource(Asset, ArchivePath)
-
addAsResource
public T addAsResource(Asset resource, String target) throws IllegalArgumentException
Description copied from interface:ResourceContainer
Adds theAsset
as a resource to the container, returning the container itself.- Specified by:
addAsResource
in interfaceResourceContainer<T extends Archive<T>>
- Parameters:
resource
-Asset
resource to addtarget
- The target path within the archive in which to add the resource, relative to theArchive
s resource path.- Returns:
- This virtual archive
- Throws:
IllegalArgumentException
- if resource is null- See Also:
ResourceContainer.addAsResource(Asset, ArchivePath)
-
addAsResource
public T addAsResource(String resourceName, ArchivePath target) throws IllegalArgumentException
Description copied from interface:ResourceContainer
Adds the resource with the specified name to the container, returning the container itself.
TheClassLoader
used to obtain the resource is up to the implementation.- Specified by:
addAsResource
in interfaceResourceContainer<T extends Archive<T>>
- Parameters:
resourceName
- Name of theClassLoader
resource to addtarget
- The target within the archive into which we'll place the resource- Returns:
- This virtual archive
- Throws:
IllegalArgumentException
- If the target is null
-
addAsResource
public T addAsResource(String resourceName, ArchivePath target, ClassLoader classLoader) throws IllegalArgumentException
Description copied from interface:ResourceContainer
Adds the resource as a resource to the container, returning the container itself.
TheClassLoader
used to obtain the resource is up to the implementation.- Specified by:
addAsResource
in interfaceResourceContainer<T extends Archive<T>>
- Parameters:
resourceName
- resource to addtarget
- The target path within the archive in which to add the resource, relative to theArchive
s resource path.- Returns:
- This virtual archive
- Throws:
IllegalArgumentException
- if resourceName is null- See Also:
ResourceContainer.addAsResource(Asset, ArchivePath)
-
addAsResource
public T addAsResource(File resource, ArchivePath target) throws IllegalArgumentException
Description copied from interface:ResourceContainer
Adds theFile
as a resource to the container, returning the container itself.- Specified by:
addAsResource
in interfaceResourceContainer<T extends Archive<T>>
- Parameters:
resource
-File
resource to addtarget
- The target path within the archive in which to add the resource, relative to theArchive
s resource path.- Returns:
- This virtual archive
- Throws:
IllegalArgumentException
- if resource is null- See Also:
ResourceContainer.addAsResource(Asset, ArchivePath)
-
addAsResource
public T addAsResource(URL resource, ArchivePath target) throws IllegalArgumentException
Description copied from interface:ResourceContainer
Adds theURL
as a resource to the container, returning the container itself.- Specified by:
addAsResource
in interfaceResourceContainer<T extends Archive<T>>
- Parameters:
resource
-URL
resource to addtarget
- The target path within the archive in which to add the resource, relative to theArchive
s resource path.- Returns:
- This virtual archive
- Throws:
IllegalArgumentException
- if resource is null- See Also:
ResourceContainer.addAsResource(Asset, ArchivePath)
-
addAsResource
public T addAsResource(Asset resource, ArchivePath target) throws IllegalArgumentException
Description copied from interface:ResourceContainer
Adds theAsset
as a resource to the container, returning the container itself.- Specified by:
addAsResource
in interfaceResourceContainer<T extends Archive<T>>
- Parameters:
resource
-Asset
resource to addtarget
- The target path within the archive in which to add the resource, relative to theArchive
s resource path.- Returns:
- This virtual archive
- Throws:
IllegalArgumentException
- if resource is null
-
addAsResources
public T addAsResources(Package resourcePackage, String... resourceNames) throws IllegalArgumentException
Description copied from interface:ResourceContainer
Adds the resources inside the package as multiple resources to the container, returning the container itself.
TheClassLoader
used to obtain the resource is up to the implementation.- Specified by:
addAsResources
in interfaceResourceContainer<T extends Archive<T>>
- Parameters:
resourcePackage
- The package of the resourcesresourceNames
- The names of the resources inside resoucePackage- Returns:
- This virtual archive
- Throws:
IllegalArgumentException
- if resourcePackage is null
-
addAsResource
public T addAsResource(Package resourcePackage, String resourceName) throws IllegalArgumentException
Description copied from interface:ResourceContainer
Adds the resource as a resource to the container, returning the container itself.
TheClassLoader
used to obtain the resource is up to the implementation.- Specified by:
addAsResource
in interfaceResourceContainer<T extends Archive<T>>
- Parameters:
resourcePackage
- The package of the resourceresourceName
- The name of the resource inside resoucePackage- Returns:
- This virtual archive
- Throws:
IllegalArgumentException
- if resourcePackage is null
-
addAsResource
public T addAsResource(Package resourcePackage, String resourceName, String target) throws IllegalArgumentException
Description copied from interface:ResourceContainer
Adds the resource as a resource to a specific path inside the container, returning the container itself.
TheClassLoader
used to obtain the resource is up to the implementation.- Specified by:
addAsResource
in interfaceResourceContainer<T extends Archive<T>>
- Parameters:
resourcePackage
- The package of the resourceresourceName
- The name of the resource inside resoucePackagetarget
- The target location inside the container- Returns:
- This virtual archive
- Throws:
IllegalArgumentException
- if resourcePackage is null
-
addAsResource
public T addAsResource(Package resourcePackage, String resourceName, ArchivePath target) throws IllegalArgumentException
Description copied from interface:ResourceContainer
Adds the resource as a resource to a specific path inside the container, returning the container itself.
TheClassLoader
used to obtain the resource is up to the implementation.- Specified by:
addAsResource
in interfaceResourceContainer<T extends Archive<T>>
- Parameters:
resourcePackage
- The package of the resourceresourceName
- The name of the resource inside resoucePackagetarget
- The target location inside the container- Returns:
- This virtual archive
- Throws:
IllegalArgumentException
- if resourcePackage is null
-
getClassesPath
protected abstract ArchivePath getClassesPath()
Should be implemented to set the path for Class related resources.- Returns:
- Base Path for the ClassContainer resources
-
addClass
public T addClass(Class<?> clazz) throws IllegalArgumentException
Description copied from interface:ClassContainer
- Specified by:
addClass
in interfaceClassContainer<T extends Archive<T>>
- Returns:
- This archive
- Throws:
IllegalArgumentException
- If no class were specified
-
addClass
public T addClass(String fullyQualifiedClassName) throws IllegalArgumentException
Adds theClass
, and all member (inner)Class
es, with the specified fully-qualified name, loaded by the Thread ContextClassLoader
, to theArchive
.- Specified by:
addClass
in interfaceClassContainer<T extends Archive<T>>
- Parameters:
fullyQualifiedClassName
- The name of theClass
to add- Returns:
- This archive
- Throws:
IllegalArgumentException
- If no class name was specified- See Also:
ClassContainer.addClass(java.lang.String)
-
addClass
public T addClass(String fullyQualifiedClassName, ClassLoader cl) throws IllegalArgumentException
Adds theClass
, and all member (inner) @link{Class}es, with the specified fully-qualified name, loaded by the specifiedClassLoader
, to theArchive
.- Specified by:
addClass
in interfaceClassContainer<T extends Archive<T>>
- Parameters:
fullyQualifiedClassName
- The name of theClass
to addcl
- TheClassLoader
used to load the Class- Returns:
- This archive
- Throws:
IllegalArgumentException
- If no class name was specified- See Also:
ClassContainer.addClass(java.lang.String, java.lang.ClassLoader)
-
addClasses
public T addClasses(Class<?>... classes) throws IllegalArgumentException
Description copied from interface:ClassContainer
- Specified by:
addClasses
in interfaceClassContainer<T extends Archive<T>>
- Parameters:
classes
- The classes to add to the Archive- Returns:
- This archive
- Throws:
IllegalArgumentException
- If no classes were specified
-
addPackage
public T addPackage(Package pack) throws IllegalArgumentException
Description copied from interface:ClassContainer
- Specified by:
addPackage
in interfaceClassContainer<T extends Archive<T>>
- Parameters:
pack
- ThePackage
to add- Returns:
- This virtual archive
- Throws:
IllegalArgumentException
- If no package were specified- See Also:
ClassContainer.addPackages(boolean, Package...)
-
addPackages
public T addPackages(boolean recursive, Package... packages) throws IllegalArgumentException
Description copied from interface:ClassContainer
- Specified by:
addPackages
in interfaceClassContainer<T extends Archive<T>>
- Parameters:
recursive
- Should the sub packages be addedpackages
- All the packages to add- Returns:
- This virtual archive
- Throws:
IllegalArgumentException
- If no packages were specified- See Also:
ClassContainer.addPackages(boolean, Filter, Package...)
-
addPackages
public T addPackages(boolean recursive, Filter<ArchivePath> filter, Package... packages) throws IllegalArgumentException
Description copied from interface:ClassContainer
Adds all classes accepted by the filter in the specifiedPackage
s to theArchive
.
TheArchivePath
returned to the filter is theArchivePath
of the class, not the final location.
package.MyClass = /package/MyClass.class
not: package.MyClass = /WEB-INF/classes/package/MyClass.class- Specified by:
addPackages
in interfaceClassContainer<T extends Archive<T>>
- Parameters:
recursive
- Should the sub packages be addedfilter
- filter out specific classespackages
- All the packages to add- Returns:
- This virtual archive
- Throws:
IllegalArgumentException
- If no packages were specified
-
addPackage
public T addPackage(String pack) throws IllegalArgumentException
Description copied from interface:ClassContainer
- Specified by:
addPackage
in interfaceClassContainer<T extends Archive<T>>
- Parameters:
pack
- Package to add represented by a String ("my/package")- Returns:
- This virtual archive
- Throws:
IllegalArgumentException
- If no package were specified- See Also:
ClassContainer.addPackages(boolean, Package...)
-
addDefaultPackage
public T addDefaultPackage()
Description copied from interface:ClassContainer
- Specified by:
addDefaultPackage
in interfaceClassContainer<T extends Archive<T>>
- Returns:
- This virtual archive
-
addPackages
public T addPackages(boolean recursive, String... packages) throws IllegalArgumentException
Description copied from interface:ClassContainer
- Specified by:
addPackages
in interfaceClassContainer<T extends Archive<T>>
- Parameters:
recursive
- Should the sub packages be addedpackages
- All the packages to add represented by a String ("my/package")- Returns:
- This virtual archive
- Throws:
IllegalArgumentException
- If no packages were specified- See Also:
ClassContainer.addPackages(boolean, Filter, Package...)
-
addPackages
public T addPackages(boolean recursive, Filter<ArchivePath> filter, String... packageNames) throws IllegalArgumentException
Description copied from interface:ClassContainer
Adds all classes accepted by the filter in the specifiedPackage
s to theArchive
.
TheArchivePath
returned to the filter is theArchivePath
of the class, not the final location.
package.MyClass = /package/MyClass.class
not: package.MyClass = /WEB-INF/classes/package/MyClass.class- Specified by:
addPackages
in interfaceClassContainer<T extends Archive<T>>
- Parameters:
recursive
- Should the sub packages be addedfilter
- filter out specific classespackageNames
- All the packages to add represented by a String ("my/package")- Returns:
- This virtual archive
- Throws:
IllegalArgumentException
- If no packages were specified
-
deleteClass
public T deleteClass(Class<?> clazz) throws IllegalArgumentException
Description copied from interface:ClassContainer
- Specified by:
deleteClass
in interfaceClassContainer<T extends Archive<T>>
- Returns:
- This archive
- Throws:
IllegalArgumentException
- If no class was specified
-
deleteClass
public T deleteClass(String fullyQualifiedClassName) throws IllegalArgumentException
Description copied from interface:ClassContainer
Deletes theClass
, and all member (inner)Class
es, with the specified fully-qualified name, loaded by the Thread ContextClassLoader
, from theArchive
.- Specified by:
deleteClass
in interfaceClassContainer<T extends Archive<T>>
- Parameters:
fullyQualifiedClassName
- The name of theClass
to be deleted- Returns:
- This archive
- Throws:
IllegalArgumentException
- If no class name was specified
-
deleteClasses
public T deleteClasses(Class<?>... classes) throws IllegalArgumentException
Description copied from interface:ClassContainer
- Specified by:
deleteClasses
in interfaceClassContainer<T extends Archive<T>>
- Parameters:
classes
- The classes to be removed from theArchive
- Returns:
- This archive
- Throws:
IllegalArgumentException
- If no classes were specified
-
deletePackage
public T deletePackage(Package pack) throws IllegalArgumentException
Description copied from interface:ClassContainer
- Specified by:
deletePackage
in interfaceClassContainer<T extends Archive<T>>
- Parameters:
pack
- ThePackage
to be deleted- Returns:
- This archive
- Throws:
IllegalArgumentException
- If no package was specified- See Also:
ClassContainer.deletePackages(boolean, Package...)
-
deletePackage
public T deletePackage(String pack) throws IllegalArgumentException
Description copied from interface:ClassContainer
- Specified by:
deletePackage
in interfaceClassContainer<T extends Archive<T>>
- Parameters:
pack
- Package to be delete represented by a String ("my/package")- Returns:
- This archive
- Throws:
IllegalArgumentException
- If no package was specified- See Also:
ClassContainer.deletePackages(boolean, Package...)
-
deleteDefaultPackage
public T deleteDefaultPackage()
Description copied from interface:ClassContainer
- Specified by:
deleteDefaultPackage
in interfaceClassContainer<T extends Archive<T>>
- Returns:
- This archive
-
deletePackages
public T deletePackages(boolean recursive, Package... packages) throws IllegalArgumentException
Description copied from interface:ClassContainer
- Specified by:
deletePackages
in interfaceClassContainer<T extends Archive<T>>
- Parameters:
recursive
- Should the sub packages be deleted?packages
- All the packages to be deleted- Returns:
- This archive
- Throws:
IllegalArgumentException
- If no packages were specified- See Also:
ClassContainer.deletePackages(boolean, Filter, Package...)
-
deletePackages
public T deletePackages(boolean recursive, String... packages) throws IllegalArgumentException
Description copied from interface:ClassContainer
- Specified by:
deletePackages
in interfaceClassContainer<T extends Archive<T>>
- Parameters:
recursive
- Should the sub packages be deleted?packages
- All the packages to be deleted represented by a String ("my/package")- Returns:
- This archive
- Throws:
IllegalArgumentException
- If no packages were specified- See Also:
ClassContainer.deletePackages(boolean, Filter, Package...)
-
deletePackages
public T deletePackages(boolean recursive, Filter<ArchivePath> filter, Package... packages) throws IllegalArgumentException
Description copied from interface:ClassContainer
Deletes all classes accepted by the filter in the specifiedPackage
s from theArchive
.
TheArchivePath
returned to the filter is theArchivePath
of the class, not the final location.
package.MyClass = /package/MyClass.class
not: package.MyClass = /WEB-INF/classes/package/MyClass.class- Specified by:
deletePackages
in interfaceClassContainer<T extends Archive<T>>
- Parameters:
recursive
- Should the sub packages be deleted?filter
- filter out specific classespackages
- All the packages to be deleted- Returns:
- This archive
- Throws:
IllegalArgumentException
- If no packages were specified or if no filter was specified
-
deletePackages
public T deletePackages(boolean recursive, Filter<ArchivePath> filter, String... packages) throws IllegalArgumentException
Description copied from interface:ClassContainer
Delete all classes accepted by the filter in the specifiedPackage
s from theArchive
.
TheArchivePath
returned to the filter is theArchivePath
of the class, not the final location.
package.MyClass = /package/MyClass.class
not: package.MyClass = /WEB-INF/classes/package/MyClass.class- Specified by:
deletePackages
in interfaceClassContainer<T extends Archive<T>>
- Parameters:
recursive
- Should the sub packages be deleted?filter
- filter out specific classespackages
- All the packages to be deleted represented by a String ("my/package")- Returns:
- This archive
- Throws:
IllegalArgumentException
- If no packages were specified or if no filter was specified
-
getLibraryPath
protected abstract ArchivePath getLibraryPath()
Should be implemented to set the path for Library related resources.- Returns:
- Base Path for the LibraryContainer resources
-
addAsLibrary
public T addAsLibrary(Archive<?> archive) throws IllegalArgumentException
Add anotherArchive
to thisArchive
as a library to the container, returning the container itself.
TheArchive
will be placed into the Container Library path underArchive.getName()
.- Specified by:
addAsLibrary
in interfaceLibraryContainer<T extends Archive<T>>
- Parameters:
archive
-Archive
resource to add- Returns:
- This virtual archive
- Throws:
IllegalArgumentException
- ifArchive
is null- See Also:
LibraryContainer.addAsLibrary(org.jboss.shrinkwrap.api.Archive)
-
addAsLibrary
public T addAsLibrary(String resourceName) throws IllegalArgumentException
Adds the resource as a library to the container, returning the container itself.
The resource will be placed into the Container Library path under the same context from which it was retrieved.
TheClassLoader
used to obtain the resource is up to the implementation.- Specified by:
addAsLibrary
in interfaceLibraryContainer<T extends Archive<T>>
- Parameters:
resourceName
- resource to add- Returns:
- This virtual archive
- Throws:
IllegalArgumentException
- if resourceName is null- See Also:
LibraryContainer.addAsLibrary(java.lang.String)
-
addAsLibrary
public T addAsLibrary(File resource) throws IllegalArgumentException
Adds theFile
as a library to the container, returning the container itself.
TheFile
will be placed into the Container Library path underFile.getName()
.- Specified by:
addAsLibrary
in interfaceLibraryContainer<T extends Archive<T>>
- Parameters:
resource
-File
resource to add- Returns:
- This virtual archive
- Throws:
IllegalArgumentException
- if resourceName is null- See Also:
LibraryContainer.addAsLibrary(java.io.File)
-
addAsLibrary
public T addAsLibrary(String resourceName, String target) throws IllegalArgumentException
Adds the resource as a library to the container, returning the container itself.
TheClassLoader
used to obtain the resource is up to the implementation.- Specified by:
addAsLibrary
in interfaceLibraryContainer<T extends Archive<T>>
- Parameters:
resourceName
- resource to addtarget
- The target path within the archive in which to add the resource, relative to theArchive
s library path.- Returns:
- This virtual archive
- Throws:
IllegalArgumentException
- if resourceName is null- See Also:
LibraryContainer.addAsLibrary(java.lang.String, java.lang.String)
-
addAsLibrary
public T addAsLibrary(File resource, String target) throws IllegalArgumentException
Adds theFile
as a library to the container, returning the container itself.- Specified by:
addAsLibrary
in interfaceLibraryContainer<T extends Archive<T>>
- Parameters:
resource
-File
resource to addtarget
- The target path within the archive in which to add the resource, relative to theArchive
s library path.- Returns:
- This virtual archive
- Throws:
IllegalArgumentException
- if resource is null- See Also:
LibraryContainer.addAsLibrary(java.io.File, java.lang.String)
-
addAsLibrary
public T addAsLibrary(URL resource, String target) throws IllegalArgumentException
Description copied from interface:LibraryContainer
Adds theURL
as a library to the container, returning the container itself.- Specified by:
addAsLibrary
in interfaceLibraryContainer<T extends Archive<T>>
- Parameters:
resource
-URL
resource to addtarget
- The target path within the archive in which to add the resource, relative to theArchive
s library path.- Returns:
- This virtual archive
- Throws:
IllegalArgumentException
- if resource is null- See Also:
LibraryContainer.addAsLibrary(Asset, ArchivePath)
-
addAsLibrary
public T addAsLibrary(Asset resource, String target) throws IllegalArgumentException
Description copied from interface:LibraryContainer
Adds theAsset
as a library to the container, returning the container itself.- Specified by:
addAsLibrary
in interfaceLibraryContainer<T extends Archive<T>>
- Parameters:
resource
-Asset
resource to addtarget
- The target path within the archive in which to add the resource, relative to theArchive
s library path.- Returns:
- This virtual archive
- Throws:
IllegalArgumentException
- if resource is null- See Also:
LibraryContainer.addAsLibrary(Asset, ArchivePath)
-
addAsLibrary
public T addAsLibrary(String resourceName, ArchivePath target) throws IllegalArgumentException
Description copied from interface:LibraryContainer
Adds the resource as a library to the container, returning the container itself.
TheClassLoader
used to obtain the resource is up to the implementation.- Specified by:
addAsLibrary
in interfaceLibraryContainer<T extends Archive<T>>
- Parameters:
resourceName
- resource to addtarget
- The target path within the archive in which to add the resource, relative to theArchive
s library path.- Returns:
- This virtual archive
- Throws:
IllegalArgumentException
- if resourceName is null- See Also:
LibraryContainer.addAsLibrary(Asset, ArchivePath)
-
addAsLibrary
public T addAsLibrary(File resource, ArchivePath target) throws IllegalArgumentException
Description copied from interface:LibraryContainer
Adds theFile
as a library to the container, returning the container itself.- Specified by:
addAsLibrary
in interfaceLibraryContainer<T extends Archive<T>>
- Parameters:
resource
-File
resource to addtarget
- The target path within the archive in which to add the resource, relative to theArchive
s library path.- Returns:
- This virtual archive
- Throws:
IllegalArgumentException
- if resource is null- See Also:
LibraryContainer.addAsLibrary(Asset, ArchivePath)
-
addAsLibrary
public T addAsLibrary(URL resource, ArchivePath target) throws IllegalArgumentException
Description copied from interface:LibraryContainer
Adds theURL
as a library to the container, returning the container itself.- Specified by:
addAsLibrary
in interfaceLibraryContainer<T extends Archive<T>>
- Parameters:
resource
-URL
resource to addtarget
- The target path within the archive in which to add the resource, relative to theArchive
s library path.- Returns:
- This virtual archive
- Throws:
IllegalArgumentException
- if resource is null- See Also:
LibraryContainer.addAsLibrary(Asset, ArchivePath)
-
addAsLibrary
public T addAsLibrary(Asset resource, ArchivePath target) throws IllegalArgumentException
Description copied from interface:LibraryContainer
Adds theAsset
as a library to the container, returning the container itself.- Specified by:
addAsLibrary
in interfaceLibraryContainer<T extends Archive<T>>
- Parameters:
resource
-Asset
resource to addtarget
- The target path within the archive in which to add the resource, relative to theArchive
s library path.- Returns:
- This virtual archive
- Throws:
IllegalArgumentException
- if resource is null
-
addAsLibraries
public T addAsLibraries(String... resourceNames) throws IllegalArgumentException
Description copied from interface:LibraryContainer
Add multiple resources to thisArchive
as libraries to the container, returning the container itself.
The resources will be placed into the Container Library path under the same context from which they were retrieved.
TheClassLoader
used to obtain the resource is up to the implementation.- Specified by:
addAsLibraries
in interfaceLibraryContainer<T extends Archive<T>>
- Parameters:
resourceNames
- resources to add- Returns:
- This virtual archive
- Throws:
IllegalArgumentException
- if resourceNames are null or empty- See Also:
LibraryContainer.addAsLibrary(String)
-
addAsLibraries
public T addAsLibraries(File... resources) throws IllegalArgumentException
Description copied from interface:LibraryContainer
Add multipleFile
to thisArchive
as libraries to the container, returning the container itself.
TheFile
s will be placed into the Container Library path underFile.getName()
.- Specified by:
addAsLibraries
in interfaceLibraryContainer<T extends Archive<T>>
- Parameters:
resources
-File
resources to add- Returns:
- This virtual archive
- Throws:
IllegalArgumentException
- ifFile
resources are null or empty- See Also:
LibraryContainer.addAsLibrary(File)
-
addAsLibraries
public T addAsLibraries(Archive<?>... archives) throws IllegalArgumentException
Description copied from interface:LibraryContainer
Add multipleArchive
s to thisArchive
as libraries to the container, returning the container itself.
TheArchive
s will be placed into the Container Library path underArchive.getName()
.- Specified by:
addAsLibraries
in interfaceLibraryContainer<T extends Archive<T>>
- Parameters:
archives
-Archive
resources to add- Returns:
- This virtual archive
- Throws:
IllegalArgumentException
- ifArchive
resources are null- See Also:
LibraryContainer.addAsLibrary(Archive)
-
addAsLibraries
public T addAsLibraries(Collection<? extends Archive<?>> archives) throws IllegalArgumentException
Add multipleArchive
s to thisArchive
as libraries to the container, returning the container itself.
TheArchive
s will be placed into the Container Library path underArchive.getName()
.- Specified by:
addAsLibraries
in interfaceLibraryContainer<T extends Archive<T>>
- Parameters:
archives
-Archive
resources to add- Returns:
- This virtual archive
- Throws:
IllegalArgumentException
- ifCollection
of archives is null- See Also:
LibraryContainer.addAsLibraries(java.util.Collection)
-
addAsLibraries
public T addAsLibraries(Archive<?>[]... archives) throws IllegalArgumentException
Add multipleArchive
s to thisArchive
as libraries to the container, returning the container itself.
TheArchive
s will be placed into the Container Library path underArchive.getName()
.- Specified by:
addAsLibraries
in interfaceLibraryContainer<T extends Archive<T>>
- Parameters:
archives
-Archive
resources to add- Returns:
- This virtual archive
- Throws:
IllegalArgumentException
- ifCollection
of archives is null- See Also:
LibraryContainer.addAsLibraries(java.util.Collection)
-
writeTo
public void writeTo(OutputStream outputStream, Formatter formatter) throws IllegalArgumentException
Prints the content of thisArchive
to the specifiedOutputStream
on the format defined by the specifiedFormatter
. The caller is responsible for opening, flushing and eventually closing the stream.
-
covarientReturn
protected T covarientReturn()
-
-