Package org.jboss.shrinkwrap.api
Class ArchiveFactory
- java.lang.Object
-
- org.jboss.shrinkwrap.api.ArchiveFactory
-
public final class ArchiveFactory extends java.lang.Object
Responsible for creatingArchive
s, which may be presented to the caller in a designatedAssignable
view.- Version:
- $Revision: $
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.String
ARCHIVE_IMPL
Implementation class name backingArchive
s to be createdprivate Configuration
configuration
Configuration for all archives created from this factory
-
Constructor Summary
Constructors Constructor Description ArchiveFactory(Configuration configuration)
Creates a newArchiveFactory
which will use the suppliedConfiguration
for each newArchive
it creates.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T extends Assignable>
Tcreate(java.lang.Class<T> type)
Creates a new archive of the specified type.<T extends Assignable>
Tcreate(java.lang.Class<T> type, java.lang.String archiveName)
Creates a new archive of the specified type.<T extends Assignable>
TcreateFromZipFile(java.lang.Class<T> type, java.io.File archiveFile)
Creates a new archive of the specified type as imported from the specifiedFile
.
-
-
-
Field Detail
-
ARCHIVE_IMPL
private static final java.lang.String ARCHIVE_IMPL
Implementation class name backingArchive
s to be created- See Also:
- Constant Field Values
-
configuration
private final Configuration configuration
Configuration for all archives created from this factory
-
-
Constructor Detail
-
ArchiveFactory
ArchiveFactory(Configuration configuration) throws java.lang.IllegalArgumentException
Creates a newArchiveFactory
which will use the suppliedConfiguration
for each newArchive
it creates.- Parameters:
configuration
- theConfiguration
to use- Throws:
java.lang.IllegalArgumentException
- if configuration is not supplied
-
-
Method Detail
-
create
public <T extends Assignable> T create(java.lang.Class<T> type) throws java.lang.IllegalArgumentException, UnknownExtensionTypeException
Creates a new archive of the specified type. The archive will be be backed by theConfiguration
specific to thisArchiveFactory
. Generates a random name for the archive and adds proper extension based on the service descriptor properties file if extension property is present (e.g. shrinkwrap/impl-base/src/main/resources/META-INF/services/org.jboss.shrinkwrap.api.spec.JavaArchive)- Parameters:
type
- The type of the archive e.g.WebArchive
- Returns:
- An
Assignable
archive base - Throws:
java.lang.IllegalArgumentException
- if type is not specifiedUnknownExtensionTypeException
- If no extension mapping is found for the specified type
-
create
public <T extends Assignable> T create(java.lang.Class<T> type, java.lang.String archiveName) throws java.lang.IllegalArgumentException
Creates a new archive of the specified type. The archive will be be backed by theConfiguration
specific to thisArchiveFactory
.- Parameters:
type
- The type of the archive e.g.WebArchive
archiveName
- the archiveName to use- Returns:
- An
Assignable
view - Throws:
java.lang.IllegalArgumentException
- either argument is not supplied
-
createFromZipFile
public <T extends Assignable> T createFromZipFile(java.lang.Class<T> type, java.io.File archiveFile) throws java.lang.IllegalArgumentException, ArchiveImportException
Creates a new archive of the specified type as imported from the specifiedFile
. The file is expected to be encoded as ZIP (ie. JAR/WAR/EAR). The name of the archive will be set toFile.getName()
. The archive will be be backed by theConfiguration
specific to thisArchiveFactory
.- Parameters:
type
- The type of the archive e.g.WebArchive
archiveFile
- the archiveFile to use- Returns:
- An
Assignable
view - Throws:
java.lang.IllegalArgumentException
- If either argument is not supplied, if the specifiedFile
does not exist, or is not a valid ZIP fileArchiveImportException
- If an error occurred during the import process
-
-