ShrinkWrap Aggregator and Build Parent 1.0.0-cr-1

org.jboss.shrinkwrap.impl.base.container
Class ContainerBase<T extends Archive<T>>

java.lang.Object
  extended by org.jboss.shrinkwrap.impl.base.AssignableBase<Archive<?>>
      extended by 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
protected ContainerBase(Class<T> actualType, Archive<?> archive)
           
 
Method Summary
 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(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(Asset asset, ArchivePath target)
          Adds the specified asset under the specified path into the target context
 T add(Asset asset, ArchivePath path, String name)
          Adds the specified asset under the specified target (directory) using the specified name.
 T add(Asset asset, String name)
          Adds the specified resource under the context denoted by the specified target
 T add(Asset asset, String target, 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 specified NamedAsset under the encapsulated name and target (directory)
 T addAsDirectories(ArchivePath... paths)
          Adds the specified directories.
 T addAsDirectories(String... paths)
          Adds the specified directories.
 T addAsDirectory(ArchivePath path)
          Adds the specified directory.
 T addAsDirectory(String path)
          Adds the specified directory.
 T addAsLibraries(Archive<?>... archives)
          Add multiple Archives to this Archive as libraries to the container, returning the container itself.
 T addAsLibraries(Archive<?>[]... archives)
          Add multiple Archives to this Archive as libraries to the container, returning the container itself.
 T addAsLibraries(Collection<? extends Archive<?>> archives)
          Add multiple Archives to this Archive as libraries to the container, returning the container itself.
 T addAsLibraries(File... resources)
          Add multiple File to this Archive as libraries to the container, returning the container itself.
 T addAsLibraries(String... resourceNames)
          Add multiple resources to this Archive as libraries to the container, returning the container itself.
 T addAsLibrary(Archive<?> archive)
          Add another Archive to this Archive as a library to the container, returning the container itself.
 T addAsLibrary(Asset resource, ArchivePath target)
          Adds the Asset as a library to the container, returning the container itself.
 T addAsLibrary(Asset resource, String target)
          Adds the Asset as a library to the container, returning the container itself.
 T addAsLibrary(File resource)
          Adds the File as a library to the container, returning the container itself.
 T addAsLibrary(File resource, ArchivePath target)
          Adds the File as a library to the container, returning the container itself.
 T addAsLibrary(File resource, String target)
          Adds the File 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, ArchivePath target)
          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(URL resource, ArchivePath target)
          Adds the URL as a library to the container, returning the container itself.
 T addAsLibrary(URL resource, String target)
          Adds the URL as a library to the container, returning the container itself.
 T addAsManifestResource(Asset resource, ArchivePath target)
          Adds the Asset as a Manifest resource to the container, returning the container itself.
 T addAsManifestResource(Asset resource, String target)
          Adds the Asset as a Manifest resource to the container, returning the container itself.
 T addAsManifestResource(File resource)
          Adds the File as a Manifest resource to the container, returning the container itself.
 T addAsManifestResource(File resource, ArchivePath target)
          Adds the File as a Manifest resource to the container, returning the container itself.
 T addAsManifestResource(File resource, String target)
          Adds the File 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, ArchivePath target)
          Adds the resource as a resource to a specific path inside 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(String resourceName)
          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(String resourceName, String target)
          Adds the resource as a Manifest resource to the container, returning the container itself.
 T addAsManifestResource(URL resource, ArchivePath target)
          Adds the URL as a Manifest resource to the container, returning the container itself.
 T addAsManifestResource(URL resource, String target)
          Adds the URL 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(Asset resource, ArchivePath target)
          Adds the Asset as a resource to the container, returning the container itself.
 T addAsResource(Asset resource, String target)
          Adds the Asset as a resource to the container, returning the container itself.
 T addAsResource(File resource)
          Adds the File as a resource to the container, returning the container itself.
 T addAsResource(File resource, ArchivePath target)
          Adds the File as a resource to the container, returning the container itself.
 T addAsResource(File resource, String target)
          Adds the File 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, ArchivePath target)
          Adds the resource as a resource to a specific path inside 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(String resourceName)
          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(String resourceName, String target)
          Adds the resource as a resource to the container, returning the container itself.
 T addAsResource(URL resource, ArchivePath target)
          Adds the URL as a resource to the container, returning the container itself.
 T addAsResource(URL resource, String target)
          Adds the URL 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/ServiceInterfaceName Asset representing this service.
 T addAsServiceProviderAndClasses(Class<?> serviceInterface, Class<?>... serviceImpls)
          Adds a META-INF/services/ServiceInterfaceName Asset and the classes related to the service to the archive.
 T addClass(Class<?> clazz)
          Adds the Class, and all member (inner) Classes to the Archive.
 T addClass(String fullyQualifiedClassName)
          Adds the Class, and all member (inner) Classes, with the specified fully-qualified name, loaded by the Thread Context ClassLoader, to the Archive.
 T addClass(String fullyQualifiedClassName, ClassLoader cl)
          Adds the Class, and all member (inner) @link{Class}es, with the specified fully-qualified name, loaded by the specified ClassLoader, to the Archive.
 T addClasses(Class<?>... classes)
          Adds the Classes, and all member (inner) Classes to the Archive.
 T addDefaultPackage()
          Adds all classes in the default Package to the Archive.
 T addManifest()
          Adds a default generated MANIFEST.MF manifest to the current archive.
 T addPackage(Package pack)
          Adds all classes in the specified Package to the Archive.
 T addPackage(String pack)
          Adds all classes in the specified Package to the Archive.
 T addPackages(boolean recursive, Filter<ArchivePath> filter, Package... packages)
          Adds all classes accepted by the filter in the specified Packages to the Archive.
 T addPackages(boolean recursive, Filter<ArchivePath> filter, String... packageNames)
          Adds all classes accepted by the filter in the specified Packages to the Archive.
 T addPackages(boolean recursive, Package... packages)
          Adds all classes in the specified Packages to the Archive.
 T addPackages(boolean recursive, String... packages)
          Adds all classes in the specified Packages to the Archive.
 boolean contains(ArchivePath path)
          Denotes whether this archive contains a resource at the specified path
 boolean contains(String path)
          Denotes whether this archive contains a resource at the specified path
protected  T covarientReturn()
           
 Node delete(ArchivePath path)
          Removes the Node in the Archive at the specified ArchivePath.
 Node delete(String archivePath)
          Removes the Node in the Archive at the ArchivePath indicated by the specified String archivePath.
 boolean equals(Object obj)
           
 Node get(ArchivePath path)
          Obtains the Node located at the specified path
 Node get(String path)
          Obtains the Node located at the specified path
protected  Class<T> getActualClass()
           
 ArchiveFormat getArchiveFormat()
           
<X extends Archive<X>>
X
getAsType(Class<X> type, ArchivePath path)
          Get a nested Archive as a specific type.

The found Archives must have been added as a Archive, no import is performed.
<X extends Archive<X>>
X
getAsType(Class<X> type, ArchivePath path, ArchiveFormat archiveCompression)
          Get a nested Archive located in a ArchivePath as a specific type using the specify ArchiveFormat
<X extends Archive<X>>
Collection<X>
getAsType(Class<X> type, Filter<ArchivePath> filter)
          Get all nested Archive 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 nested Archive matching the filter as a specific type using the specify ArchiveFormat.
<X extends Archive<X>>
X
getAsType(Class<X> type, String path)
          Get a nested Archive as a specific type.

The found Archives must have been added as a Archive, no import is performed.
<X extends Archive<X>>
X
getAsType(Class<X> type, String path, ArchiveFormat archiveCompression)
          Get a nested Archive as a specific type using the specify ArchiveFormat
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 its respective Path.
 Map<ArchivePath,Node> getContent(Filter<ArchivePath> filter)
          Obtains all assets matching given filter in this archive, along with its respective Path.
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, 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 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 setManifest(Asset resource)
          Adds the Asset as MANIFEST.FM to the container, returning the container itself.
 T setManifest(File resource)
          Adds the File 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 the URL as MANIFEST.FM to the container, returning the container itself.
 String toString()
          Acts as a shorthand for Archive.toString(Formatter) where the Formatters.SIMPLE is leveraged.
 String toString(boolean verbose)
          If "true" is specified, acts as a shorthand for Archive.toString(Formatter) where the Formatters.VERBOSE is leveraged.
 String toString(Formatter formatter)
          Returns a view of this Archive as returned from the specified Formatter.
 void writeTo(OutputStream outputStream, Formatter formatter)
          Prints the content of this Archive to the specified OutputStream on the format defined by the specified Formatter.
 
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
 

Constructor Detail

ContainerBase

protected ContainerBase(Class<T> actualType,
                        Archive<?> archive)
Method Detail

getArchiveFormat

public ArchiveFormat getArchiveFormat()
Specified by:
getArchiveFormat in interface ArchiveFormatAssociable

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 interface Archive<T extends Archive<T>>
Parameters:
archive - to add
path - to use
exporter - Exporter type to use in fulfilling the Asset.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 interface Archive<T extends Archive<T>>
Parameters:
archive - to add
path - to use
exporter - Exporter type to use in fulfilling the Asset.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 interface Archive<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 interface Archive<T extends Archive<T>>
path - The context directory under which to add the asset
name - 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 interface Archive<T extends Archive<T>>
target - The context directory under which to add the asset
name - 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 specified NamedAsset under the encapsulated name and target (directory)

Specified by:
add in interface Archive<T extends Archive<T>>
Returns:
See Also:
org.jboss.shrinkwrap.api.Archive#add(NamedAsset))

addAsDirectories

public T addAsDirectories(ArchivePath... paths)
                                      throws IllegalArgumentException
Adds the specified directories.

Specified by:
addAsDirectories in interface Archive<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 interface Archive<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 interface Archive<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 interface Archive<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)

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 interface Archive<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 which ArchivePaths to include form the source Archive.

Specified by:
merge in interface Archive<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 interface Archive<T extends Archive<T>>
Parameters:
source - Archive to add contents from
path - 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 which ArchivePaths to include form the source Archive.

Specified by:
merge in interface Archive<T extends Archive<T>>
Parameters:
source - Archive to add contents from
path - Path to add contents to
filter - Filter to use for including Assets 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 which ArchivePaths to include form the source Archive.

Specified by:
merge in interface Archive<T extends Archive<T>>
Parameters:
source - Archive to add contents from
path - Path to add contents to
filter - Filter to use for including Assets 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 interface Archive<T extends Archive<T>>
Parameters:
source - Archive to add contents from
path - 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)

add

public T add(Asset asset,
             String name)
Adds the specified resource under the context denoted by the specified target

Specified by:
add in interface Archive<T extends Archive<T>>
Returns:
See Also:
Archive.add(org.jboss.shrinkwrap.api.asset.Asset, java.lang.String)

contains

public boolean contains(ArchivePath path)
Denotes whether this archive contains a resource at the specified path

Specified by:
contains in interface Archive<T extends Archive<T>>
Returns:
See Also:
Archive.contains(org.jboss.shrinkwrap.api.ArchivePath)

contains

public boolean contains(String path)
                 throws IllegalArgumentException
Denotes whether this archive contains a resource at the specified path

Specified by:
contains in interface Archive<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 the Node in the Archive at the specified ArchivePath. If the path is a directory, recursively removes all contents. If the path does not exist, return null.

Specified by:
delete in interface Archive<T extends Archive<T>>
Returns:
The Node removed
See Also:
Archive.delete(org.jboss.shrinkwrap.api.ArchivePath)

delete

public Node delete(String archivePath)
Removes the Node in the Archive at the ArchivePath indicated by the specified String archivePath. If the path is a directory, recursively removes all contents. If the path does not exist, return null.

Specified by:
delete in interface Archive<T extends Archive<T>>
Returns:
The Node removed
See Also:
Archive.delete(java.lang.String)

get

public Node get(ArchivePath path)
Obtains the Node located at the specified path

Specified by:
get in interface Archive<T extends Archive<T>>
Returns:
The Node, or null if nothing is found at the specified path
See Also:
Archive.get(org.jboss.shrinkwrap.api.ArchivePath)

get

public Node get(String path)
         throws IllegalArgumentException
Obtains the Node located at the specified path

Specified by:
get in interface Archive<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 nested Archive as a specific type.

The found Archives must have been added as a Archive, no import is performed.

Specified by:
getAsType in interface Archive<T extends Archive<T>>
Parameters:
type - The Type to return the Archive as
path - The location of the Archive
Returns:
The found Archive as given type or null if none found at given path
See Also:
Archive.getAsType(java.lang.Class, java.lang.String)

getAsType

public <X extends Archive<X>> X getAsType(Class<X> type,
                                          ArchivePath path)
Get a nested Archive as a specific type.

The found Archives must have been added as a Archive, no import is performed.

Specified by:
getAsType in interface Archive<T extends Archive<T>>
Parameters:
type - The Type to return the Archive as
path - 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 nested Archive 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 interface Archive<T extends Archive<T>>
Parameters:
type - The Type to return the Archive as
filter - Filter to match result
Returns:
A Collection of found Archives matching given filter or empty Collection 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 nested Archive as a specific type using the specify ArchiveFormat

Specified by:
getAsType in interface Archive<T extends Archive<T>>
Parameters:
type - The Type to return the Archive as
path - The location of the Archive
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)
Get a nested Archive located in a ArchivePath as a specific type using the specify ArchiveFormat

Specified by:
getAsType in interface Archive<T extends Archive<T>>
Parameters:
type - The Type to return the Archive as
path - 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, org.jboss.shrinkwrap.api.ArchiveFormat)

getAsType

public <X extends Archive<X>> Collection<X> getAsType(Class<X> type,
                                                      Filter<ArchivePath> filter,
                                                      ArchiveFormat archiveCompression)
Get all nested Archive matching the filter as a specific type using the specify ArchiveFormat.

Specified by:
getAsType in interface Archive<T extends Archive<T>>
Parameters:
type - The Type to return the Archive as
filter - Filter to match result
Returns:
A Collection of found Archives matching given filter or empty Collection if non found.
See Also:
Archive.getAsType(java.lang.Class, org.jboss.shrinkwrap.api.Filter, org.jboss.shrinkwrap.api.ArchiveFormat)

getContent

public Map<ArchivePath,Node> getContent()
Obtains all assets in this archive, along with its respective Path. The returned Map will be an immutable view.

Specified by:
getContent in interface Archive<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 interface Archive<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)

Specified by:
getName in interface Archive<T extends Archive<T>>
See Also:
Archive.getName()

toString

public String toString()
Acts as a shorthand for Archive.toString(Formatter) where the Formatters.SIMPLE is leveraged.

Specified by:
toString in interface Archive<T extends Archive<T>>
Overrides:
toString in class Object
See Also:
org.jboss.declarchive.api.Archive#toString(boolean)

toString

public String toString(boolean verbose)
If "true" is specified, acts as a shorthand for Archive.toString(Formatter) where the Formatters.VERBOSE is leveraged. Otherwise the Formatters.SIMPLE will be used (equivalent to Archive.toString()).

Specified by:
toString in interface Archive<T extends Archive<T>>
Returns:
See Also:
org.jboss.declarchive.api.Archive#toString(boolean)

toString

public String toString(Formatter formatter)
                throws IllegalArgumentException
Returns a view of this Archive as returned from the specified Formatter. Common options may be to use the predefined formatters located in Formatters

Specified by:
toString in interface Archive<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 class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class 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)
Description copied from interface: ManifestContainer
Adds the resource as MANIFEST.FM to the container, returning the container itself.
The ClassLoader used to obtain the resource is up to the implementation.

Specified by:
setManifest in interface ManifestContainer<T extends Archive<T>>
Parameters:
resourceName - resource to add
Returns:
This virtual archive
See Also:
ManifestContainer.setManifest(Asset)

setManifest

public T setManifest(File resource)
                                 throws IllegalArgumentException
Description copied from interface: ManifestContainer
Adds the File as MANIFEST.FM to the container, returning the container itself.

Specified by:
setManifest in interface ManifestContainer<T extends Archive<T>>
Parameters:
resource - File resource to add
Returns:
This virtual archive
Throws:
IllegalArgumentException - if resource is null
See Also:
ManifestContainer.setManifest(Asset)

setManifest

public T setManifest(URL resource)
                                 throws IllegalArgumentException
Description copied from interface: ManifestContainer
Adds the URL as MANIFEST.FM to the container, returning the container itself.

Specified by:
setManifest in interface ManifestContainer<T extends Archive<T>>
Parameters:
resource - URL resource to add
Returns:
This virtual archive
Throws:
IllegalArgumentException - if resource is null
See Also:
ManifestContainer.setManifest(Asset)

setManifest

public T setManifest(Asset resource)
                                 throws IllegalArgumentException
Description copied from interface: ManifestContainer
Adds the Asset as MANIFEST.FM to the container, returning the container itself.

Specified by:
setManifest in interface ManifestContainer<T extends Archive<T>>
Parameters:
resource - File resource to add
Returns:
This virtual archive
Throws:
IllegalArgumentException - if resource is null
See Also:
ManifestContainer.addAsManifestResource(Asset, ArchivePath)

setManifest

public T setManifest(Package resourcePackage,
                     String resourceName)
                                 throws IllegalArgumentException
Description copied from interface: ManifestContainer
Adds the resource inside the package as a MANIFEST.MF to the container, returning the container itself.

The ClassLoader used to obtain the resource is up to the implementation.

Specified by:
setManifest in interface ManifestContainer<T extends Archive<T>>
Parameters:
resourcePackage - The package of the resource
resourceName - The name of the resource inside resoucePackage
Returns:
This virtual archive
Throws:
IllegalArgumentException - if resourcePackage is null

addAsManifestResource

public final T addAsManifestResource(String resourceName)
Description copied from interface: ManifestContainer
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.

The ClassLoader used to obtain the resource is up to the implementation.

Specified by:
addAsManifestResource in interface ManifestContainer<T extends Archive<T>>
Parameters:
resourceName - resource to add
Returns:
This virtual archive

addAsManifestResource

public T addAsManifestResource(File resource)
                                           throws IllegalArgumentException
Description copied from interface: ManifestContainer
Adds the File as a Manifest resource to the container, returning the container itself.
The File will be placed into the Container Manifest path under File.getName().

Specified by:
addAsManifestResource in interface ManifestContainer<T extends Archive<T>>
Parameters:
resource - resource to add
Returns:
This virtual archive
Throws:
IllegalArgumentException - if File resource is null
See Also:
ManifestContainer.addAsManifestResource(Asset, ArchivePath)

addAsManifestResource

public T addAsManifestResource(String resourceName,
                               String target)
                                           throws IllegalArgumentException
Description copied from interface: ManifestContainer
Adds the resource as a Manifest resource to the container, returning the container itself.
The ClassLoader used to obtain the resource is up to the implementation.

Specified by:
addAsManifestResource in interface ManifestContainer<T extends Archive<T>>
Parameters:
resourceName - resource to add
target - The target path within the archive in which to add the resource, relative to the Archives manifest path.
Returns:
This virtual archive
Throws:
IllegalArgumentException - if resourceName is null
See Also:
ManifestContainer.addAsManifestResource(Asset, ArchivePath)

addAsManifestResource

public T addAsManifestResource(File resource,
                               String target)
                                           throws IllegalArgumentException
Description copied from interface: ManifestContainer
Adds the File as a Manifest resource to the container, returning the container itself.

Specified by:
addAsManifestResource in interface ManifestContainer<T extends Archive<T>>
Parameters:
resource - File resource to add
target - The target path within the archive in which to add the resource, relative to the Archives manifest path.
Returns:
This virtual archive
Throws:
IllegalArgumentException - if resource is null
See Also:
ManifestContainer.addAsManifestResource(Asset, ArchivePath)

addAsManifestResource

public T addAsManifestResource(URL resource,
                               String target)
                                           throws IllegalArgumentException
Description copied from interface: ManifestContainer
Adds the URL as a Manifest resource to the container, returning the container itself.

Specified by:
addAsManifestResource in interface ManifestContainer<T extends Archive<T>>
Parameters:
resource - URL resource to add
target - The target path within the archive in which to add the resource, relative to the Archives 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 the Asset as a Manifest resource to the container, returning the container itself.

Specified by:
addAsManifestResource in interface ManifestContainer<T extends Archive<T>>
Parameters:
resource - Asset resource to add
target - The target path within the archive in which to add the resource, relative to the Archives 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.
The ClassLoader used to obtain the resource is up to the implementation.

Specified by:
addAsManifestResource in interface ManifestContainer<T extends Archive<T>>
Parameters:
resourceName - resource to add
target - The target path within the archive in which to add the resource, relative to the Archives 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 the File as a Manifest resource to the container, returning the container itself.

Specified by:
addAsManifestResource in interface ManifestContainer<T extends Archive<T>>
Parameters:
resource - File resource to add
target - The target path within the archive in which to add the resource, relative to the Archives 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 the URL as a Manifest resource to the container, returning the container itself.

Specified by:
addAsManifestResource in interface ManifestContainer<T extends Archive<T>>
Parameters:
resource - URL resource to add
target - The target path within the archive in which to add the resource, relative to the Archives 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 the Asset as a Manifest resource to the container, returning the container itself.

Specified by:
addAsManifestResource in interface ManifestContainer<T extends Archive<T>>
Parameters:
resource - Asset resource to add
target - The target path within the archive in which to add the resource, relative to the Archives 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.

The ClassLoader used to obtain the resource is up to the implementation.

Specified by:
addAsManifestResources in interface ManifestContainer<T extends Archive<T>>
Parameters:
resourcePackage - The package of the resources
resourceNames - 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.

The ClassLoader used to obtain the resource is up to the implementation.

Specified by:
addAsManifestResource in interface ManifestContainer<T extends Archive<T>>
Parameters:
resourcePackage - The package of the resource
resourceName - 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.

The ClassLoader used to obtain the resource is up to the implementation.

Specified by:
addAsManifestResource in interface ManifestContainer<T extends Archive<T>>
Parameters:
resourcePackage - The package of the resource
resourceName - The name of the resource inside resoucePackage
target - 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.

The ClassLoader used to obtain the resource is up to the implementation.

Specified by:
addAsManifestResource in interface ManifestContainer<T extends Archive<T>>
Parameters:
resourcePackage - The package of the resource
resourceName - The name of the resource inside resoucePackage
target - 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 interface ManifestContainer<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/ServiceInterfaceName Asset representing this service. Warning: this method does not add the specified classes to the archive.

Specified by:
addAsServiceProvider in interface ManifestContainer<T extends Archive<T>>
Parameters:
serviceInterface - The Service Interface class
serviceImpls - The Service Interface Implementations
Returns:
This virtual archive
Throws:
IllegalArgumentException - if serviceInterface is null

addAsServiceProviderAndClasses

public T addAsServiceProviderAndClasses(Class<?> serviceInterface,
                                        Class<?>... serviceImpls)
                                                    throws IllegalArgumentException
Description copied from interface: ServiceProviderContainer
Adds a META-INF/services/ServiceInterfaceName Asset and the classes related to the service to the archive.

Specified by:
addAsServiceProviderAndClasses in interface ServiceProviderContainer<T extends Archive<T>>
Parameters:
serviceInterface - The Service Interface class
serviceImpls - 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.

The ClassLoader used to obtain the resource is up to the implementation.

Specified by:
addAsResource in interface ResourceContainer<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 the File as a resource to the container, returning the container itself.
The File will be placed into the Container Library path under File.getName().

Specified by:
addAsResource in interface ResourceContainer<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.

The ClassLoader used to obtain the resource is up to the implementation.

Specified by:
addAsResource in interface ResourceContainer<T extends Archive<T>>
Parameters:
resourceName - resource to add
target - The target path within the archive in which to add the resource, relative to the Archives 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 the File as a resource to the container, returning the container itself.

Specified by:
addAsResource in interface ResourceContainer<T extends Archive<T>>
Parameters:
resource - File resource to add
target - The target path within the archive in which to add the resource, relative to the Archives 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 the URL as a resource to the container, returning the container itself.

Specified by:
addAsResource in interface ResourceContainer<T extends Archive<T>>
Parameters:
resource - URL resource to add
target - The target path within the archive in which to add the resource, relative to the Archives 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 the Asset as a resource to the container, returning the container itself.

Specified by:
addAsResource in interface ResourceContainer<T extends Archive<T>>
Parameters:
resource - Asset resource to add
target - The target path within the archive in which to add the resource, relative to the Archives 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.

The ClassLoader used to obtain the resource is up to the implementation.

Specified by:
addAsResource in interface ResourceContainer<T extends Archive<T>>
Parameters:
resourceName - Name of the ClassLoader resource to add
target - 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.

The ClassLoader used to obtain the resource is up to the implementation.

Specified by:
addAsResource in interface ResourceContainer<T extends Archive<T>>
Parameters:
resourceName - resource to add
target - The target path within the archive in which to add the resource, relative to the Archives 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 the File as a resource to the container, returning the container itself.

Specified by:
addAsResource in interface ResourceContainer<T extends Archive<T>>
Parameters:
resource - File resource to add
target - The target path within the archive in which to add the resource, relative to the Archives 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 the URL as a resource to the container, returning the container itself.

Specified by:
addAsResource in interface ResourceContainer<T extends Archive<T>>
Parameters:
resource - URL resource to add
target - The target path within the archive in which to add the resource, relative to the Archives 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 the Asset as a resource to the container, returning the container itself.

Specified by:
addAsResource in interface ResourceContainer<T extends Archive<T>>
Parameters:
resource - Asset resource to add
target - The target path within the archive in which to add the resource, relative to the Archives 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.

The ClassLoader used to obtain the resource is up to the implementation.

Specified by:
addAsResources in interface ResourceContainer<T extends Archive<T>>
Parameters:
resourcePackage - The package of the resources
resourceNames - 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.

The ClassLoader used to obtain the resource is up to the implementation.

Specified by:
addAsResource in interface ResourceContainer<T extends Archive<T>>
Parameters:
resourcePackage - The package of the resource
resourceName - 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.

The ClassLoader used to obtain the resource is up to the implementation.

Specified by:
addAsResource in interface ResourceContainer<T extends Archive<T>>
Parameters:
resourcePackage - The package of the resource
resourceName - The name of the resource inside resoucePackage
target - 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.

The ClassLoader used to obtain the resource is up to the implementation.

Specified by:
addAsResource in interface ResourceContainer<T extends Archive<T>>
Parameters:
resourcePackage - The package of the resource
resourceName - The name of the resource inside resoucePackage
target - 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
Adds the Class, and all member (inner) Classes to the Archive.

Specified by:
addClass in interface ClassContainer<T extends Archive<T>>
Returns:
This archive
Throws:
IllegalArgumentException - If no class were specified

addClass

public T addClass(String fullyQualifiedClassName)
                              throws IllegalArgumentException
Adds the Class, and all member (inner) Classes, with the specified fully-qualified name, loaded by the Thread Context ClassLoader, to the Archive.

Specified by:
addClass in interface ClassContainer<T extends Archive<T>>
Parameters:
fullyQualifiedClassName - The name of the Class 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 the Class, and all member (inner) @link{Class}es, with the specified fully-qualified name, loaded by the specified ClassLoader, to the Archive.

Specified by:
addClass in interface ClassContainer<T extends Archive<T>>
Parameters:
fullyQualifiedClassName - The name of the Class to add
cl - The ClassLoader 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
Adds the Classes, and all member (inner) Classes to the Archive.

Specified by:
addClasses in interface ClassContainer<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
Adds all classes in the specified Package to the Archive.
SubPackages are excluded.

Specified by:
addPackage in interface ClassContainer<T extends Archive<T>>
Parameters:
pack - The Package 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
Adds all classes in the specified Packages to the Archive.

Specified by:
addPackages in interface ClassContainer<T extends Archive<T>>
Parameters:
recursive - Should the sub packages be added
packages - 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 specified Packages to the Archive.
The ArchivePath returned to the filter is the ArchivePath 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 interface ClassContainer<T extends Archive<T>>
Parameters:
recursive - Should the sub packages be added
filter - filter out specific classes
packages - 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
Adds all classes in the specified Package to the Archive.
SubPackages are excluded.

Specified by:
addPackage in interface ClassContainer<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
Adds all classes in the default Package to the Archive.
SubPackages are excluded.

Specified by:
addDefaultPackage in interface ClassContainer<T extends Archive<T>>
Returns:
This virtual archive

addPackages

public T addPackages(boolean recursive,
                     String... packages)
                                 throws IllegalArgumentException
Description copied from interface: ClassContainer
Adds all classes in the specified Packages to the Archive.

Specified by:
addPackages in interface ClassContainer<T extends Archive<T>>
Parameters:
recursive - Should the sub packages be added
packages - 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 specified Packages to the Archive.
The ArchivePath returned to the filter is the ArchivePath 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 interface ClassContainer<T extends Archive<T>>
Parameters:
recursive - Should the sub packages be added
filter - filter out specific classes
packageNames - All the packages to add represented by a String ("my/package")
Returns:
This virtual archive
Throws:
IllegalArgumentException - If no packages were 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 another Archive to this Archive as a library to the container, returning the container itself.
The Archive will be placed into the Container Library path under Archive.getName().

Specified by:
addAsLibrary in interface LibraryContainer<T extends Archive<T>>
Parameters:
archive - Archive resource to add
Returns:
This virtual archive
Throws:
IllegalArgumentException - if Archive 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.

The ClassLoader used to obtain the resource is up to the implementation.

Specified by:
addAsLibrary in interface LibraryContainer<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 the File as a library to the container, returning the container itself.
The File will be placed into the Container Library path under File.getName().

Specified by:
addAsLibrary in interface LibraryContainer<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.

The ClassLoader used to obtain the resource is up to the implementation.

Specified by:
addAsLibrary in interface LibraryContainer<T extends Archive<T>>
Parameters:
resourceName - resource to add
target - The target path within the archive in which to add the resource, relative to the Archives 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 the File as a library to the container, returning the container itself.

Specified by:
addAsLibrary in interface LibraryContainer<T extends Archive<T>>
Parameters:
resource - File resource to add
target - The target path within the archive in which to add the resource, relative to the Archives 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 the URL as a library to the container, returning the container itself.

Specified by:
addAsLibrary in interface LibraryContainer<T extends Archive<T>>
Parameters:
resource - URL resource to add
target - The target path within the archive in which to add the resource, relative to the Archives 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 the Asset as a library to the container, returning the container itself.

Specified by:
addAsLibrary in interface LibraryContainer<T extends Archive<T>>
Parameters:
resource - Asset resource to add
target - The target path within the archive in which to add the resource, relative to the Archives 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.

The ClassLoader used to obtain the resource is up to the implementation.

Specified by:
addAsLibrary in interface LibraryContainer<T extends Archive<T>>
Parameters:
resourceName - resource to add
target - The target path within the archive in which to add the resource, relative to the Archives 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 the File as a library to the container, returning the container itself.

Specified by:
addAsLibrary in interface LibraryContainer<T extends Archive<T>>
Parameters:
resource - File resource to add
target - The target path within the archive in which to add the resource, relative to the Archives 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 the URL as a library to the container, returning the container itself.

Specified by:
addAsLibrary in interface LibraryContainer<T extends Archive<T>>
Parameters:
resource - URL resource to add
target - The target path within the archive in which to add the resource, relative to the Archives 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 the Asset as a library to the container, returning the container itself.

Specified by:
addAsLibrary in interface LibraryContainer<T extends Archive<T>>
Parameters:
resource - Asset resource to add
target - The target path within the archive in which to add the resource, relative to the Archives 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 this Archive 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.

The ClassLoader used to obtain the resource is up to the implementation.

Specified by:
addAsLibraries in interface LibraryContainer<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 multiple File to this Archive as libraries to the container, returning the container itself.
The Files will be placed into the Container Library path under File.getName().

Specified by:
addAsLibraries in interface LibraryContainer<T extends Archive<T>>
Parameters:
resources - File resources to add
Returns:
This virtual archive
Throws:
IllegalArgumentException - if File resources are null or empty
See Also:
LibraryContainer.addAsLibrary(File)

addAsLibraries

public T addAsLibraries(Archive<?>... archives)
                                    throws IllegalArgumentException
Description copied from interface: LibraryContainer
Add multiple Archives to this Archive as libraries to the container, returning the container itself.
The Archives will be placed into the Container Library path under Archive.getName().

Specified by:
addAsLibraries in interface LibraryContainer<T extends Archive<T>>
Parameters:
archives - Archive resources to add
Returns:
This virtual archive
Throws:
IllegalArgumentException - if Archive resources are null
See Also:
LibraryContainer.addAsLibrary(Archive)

addAsLibraries

public T addAsLibraries(Collection<? extends Archive<?>> archives)
                                    throws IllegalArgumentException
Add multiple Archives to this Archive as libraries to the container, returning the container itself.
The Archives will be placed into the Container Library path under Archive.getName().

Specified by:
addAsLibraries in interface LibraryContainer<T extends Archive<T>>
Parameters:
archives - Archive resources to add
Returns:
This virtual archive
Throws:
IllegalArgumentException - if Collection of archives is null
See Also:
LibraryContainer.addAsLibraries(java.util.Collection)

addAsLibraries

public T addAsLibraries(Archive<?>[]... archives)
                                    throws IllegalArgumentException
Add multiple Archives to this Archive as libraries to the container, returning the container itself.
The Archives will be placed into the Container Library path under Archive.getName().

Specified by:
addAsLibraries in interface LibraryContainer<T extends Archive<T>>
Parameters:
archives - Archive resources to add
Returns:
This virtual archive
Throws:
IllegalArgumentException - if Collection 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 this Archive to the specified OutputStream on the format defined by the specified Formatter. The caller is responsible for opening, flushing and eventually closing the stream.

Specified by:
writeTo in interface Archive<T extends Archive<T>>
Parameters:
outputStream - the stream to print the archive contents to
formatter - the output format
Throws:
IllegalArgumentException - if an exceptions occur when writing the archive contents.

covarientReturn

protected T covarientReturn()

getActualClass

protected Class<T> getActualClass()

ShrinkWrap Aggregator and Build Parent 1.0.0-cr-1

Copyright © 2011 JBoss, a division of Red Hat, Inc.. All Rights Reserved.