Class ArchiveFactory
java.lang.Object
org.jboss.shrinkwrap.api.ArchiveFactory
Responsible for creating
Archives, which may be presented to the caller in a designated Assignable
view.- Version:
- $Revision: $
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final StringImplementation class name backingArchives to be createdprivate final ConfigurationConfiguration for all archives created from this factory -
Constructor Summary
ConstructorsConstructorDescriptionArchiveFactory(Configuration configuration) Creates a newArchiveFactorywhich will use the suppliedConfigurationfor each newArchiveit creates. -
Method Summary
Modifier and TypeMethodDescription<T extends Assignable>
TCreates a new archive of the specified type.<T extends Assignable>
TCreates a new archive of the specified type.<T extends Assignable>
TcreateFromZipFile(Class<T> type, File archiveFile) Creates a new archive of the specified type as imported from the specifiedFile.
-
Field Details
-
ARCHIVE_IMPL
-
configuration
Configuration for all archives created from this factory
-
-
Constructor Details
-
ArchiveFactory
ArchiveFactory(Configuration configuration) throws IllegalArgumentException Creates a newArchiveFactorywhich will use the suppliedConfigurationfor each newArchiveit creates.- Parameters:
configuration- theConfigurationto use- Throws:
IllegalArgumentException- if configuration is not supplied
-
-
Method Details
-
create
public <T extends Assignable> T create(Class<T> type) throws IllegalArgumentException, UnknownExtensionTypeException Creates a new archive of the specified type. The archive will be be backed by theConfigurationspecific 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
Assignablearchive base - Throws:
IllegalArgumentException- if type is not specifiedUnknownExtensionTypeException- If no extension mapping is found for the specified type
-
create
public <T extends Assignable> T create(Class<T> type, String archiveName) throws IllegalArgumentException Creates a new archive of the specified type. The archive will be be backed by theConfigurationspecific to thisArchiveFactory.- Parameters:
type- The type of the archive e.g.WebArchivearchiveName- the archiveName to use- Returns:
- An
Assignableview - Throws:
IllegalArgumentException- either argument is not supplied
-
createFromZipFile
public <T extends Assignable> T createFromZipFile(Class<T> type, File archiveFile) throws 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 theConfigurationspecific to thisArchiveFactory.- Parameters:
type- The type of the archive e.g.WebArchivearchiveFile- the archiveFile to use- Returns:
- An
Assignableview - Throws:
IllegalArgumentException- If either argument is not supplied, if the specifiedFiledoes not exist, or is not a valid ZIP fileArchiveImportException- If an error occurred during the import process
-