public final class ArchiveFactory
extends java.lang.Object
Archive
s, which may be presented to the caller in a designated Assignable
view.Modifier and Type | Field and Description |
---|---|
private static java.lang.String |
ARCHIVE_IMPL
Implementation class name backing
Archive s to be created |
private Configuration |
configuration
Configuration for all archives created from this factory
|
Constructor and Description |
---|
ArchiveFactory(Configuration configuration)
Creates a new
ArchiveFactory which will use the supplied Configuration for each new
Archive it creates. |
Modifier and Type | Method and Description |
---|---|
<T extends Assignable> |
create(java.lang.Class<T> type)
Creates a new archive of the specified type.
|
<T extends Assignable> |
create(java.lang.Class<T> type,
java.lang.String archiveName)
Creates a new archive of the specified type.
|
<T extends Assignable> |
createFromZipFile(java.lang.Class<T> type,
java.io.File archiveFile)
Creates a new archive of the specified type as imported from the specified
File . |
private static final java.lang.String ARCHIVE_IMPL
Archive
s to be createdprivate final Configuration configuration
ArchiveFactory(Configuration configuration) throws java.lang.IllegalArgumentException
ArchiveFactory
which will use the supplied Configuration
for each new
Archive
it creates.configuration
- the Configuration
to usejava.lang.IllegalArgumentException
- if configuration is not suppliedpublic <T extends Assignable> T create(java.lang.Class<T> type) throws java.lang.IllegalArgumentException, UnknownExtensionTypeException
Configuration
specific
to this ArchiveFactory
. 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)type
- The type of the archive e.g. WebArchive
Assignable
archive basejava.lang.IllegalArgumentException
- if type is not specifiedUnknownExtensionTypeException
- If no extension mapping is found for the specified typepublic <T extends Assignable> T create(java.lang.Class<T> type, java.lang.String archiveName) throws java.lang.IllegalArgumentException
Configuration
specific
to this ArchiveFactory
.type
- The type of the archive e.g. WebArchive
archiveName
- the archiveName to useAssignable
viewjava.lang.IllegalArgumentException
- either argument is not suppliedpublic <T extends Assignable> T createFromZipFile(java.lang.Class<T> type, java.io.File archiveFile) throws java.lang.IllegalArgumentException, ArchiveImportException
File
. The file is expected to
be encoded as ZIP (ie. JAR/WAR/EAR). The name of the archive will be set to File.getName()
. The archive
will be be backed by the Configuration
specific to this ArchiveFactory
.type
- The type of the archive e.g. WebArchive
archiveFile
- the archiveFile to useAssignable
viewjava.lang.IllegalArgumentException
- If either argument is not supplied, if the specified File
does not exist, or is not a valid
ZIP fileArchiveImportException
- If an error occurred during the import process