Package org.jboss.shrinkwrap.api
Class ShrinkWrap
java.lang.Object
org.jboss.shrinkwrap.api.ShrinkWrap
Main entry point into the ShrinkWrap system. Each
Archive
has an associated Configuration
provided at
construction by the Domain
under which the archive was created. ShrinkWrap
provides static access to
the default Domain
(and by extension the default Configuration
), as well as a shortcut mechanism to
create Archive
s under these defaults by way of create(Class, String)
. Additionally, this
class is the hook to create new Domain
s via createDomain()
,
createDomain(ConfigurationBuilder)
or createDomain(Configuration)
.- Version:
- $Revision: $
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static enum
Singleton wrapper to encapsulate a default domain -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
Internal constructor; not to be called as this class provides static utilities only -
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends Assignable>
TCreates a new archive of the specified type.static <T extends Assignable>
TCreates a new archive of the specified type.static Domain
Creates a newDomain
containing a defaultConfiguration
.static Domain
createDomain
(Configuration configuration) Creates a newDomain
containing configuration properties from the suppliedConfiguration
.static Domain
createDomain
(ConfigurationBuilder builder) Creates a newDomain
containing configuration properties from the suppliedConfigurationBuilder
.static <T extends Assignable>
TcreateFromZipFile
(Class<T> type, File archiveFile) Creates a new archive of the specified type as imported from the specifiedFile
.static Domain
Returns a single domain with default configuration for use in applications with no explicit configuration or isolation requirements.
-
Constructor Details
-
ShrinkWrap
private ShrinkWrap()Internal constructor; not to be called as this class provides static utilities only
-
-
Method Details
-
createDomain
Creates a newDomain
containing a defaultConfiguration
.ArchiveFactory
s created from this domain will have isolated configuration from archive factories created from other domains. Likewise, allArchiveFactory
s andArchive
s created from the returned domain will share the same configuration.- Returns:
- A new
Domain
with default configuration
-
createDomain
Creates a newDomain
containing configuration properties from the suppliedConfigurationBuilder
.ArchiveFactory
s created from this domain will have isolated configuration from archive factories created from other domains. Likewise, allArchiveFactory
s andArchive
s created from the returned domain will share the same configuration.- Parameters:
builder
- Builder with which we should create aConfiguration
for thisDomain
- Returns:
- A new
Domain
with default configuration - Throws:
IllegalArgumentException
- If the builder is not supplied
-
createDomain
Creates a newDomain
containing configuration properties from the suppliedConfiguration
.ArchiveFactory
s created from this domain will have isolated configuration from archive factories created from other domains. Likewise, allArchiveFactory
s andArchive
s created from the returned domain will share the same configuration.- Parameters:
configuration
-Configuration
for thisDomain
- Returns:
- A new
Domain
with default configuration - Throws:
IllegalArgumentException
- If the configuration is not supplied
-
getDefaultDomain
Returns a single domain with default configuration for use in applications with no explicit configuration or isolation requirements.- Returns:
- default
Domain
-
create
public static <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 the defaultConfiguration
. 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) Invoking this method is functionally equivalent to callingArchiveFactory.create(Class)
uponDomain.getArchiveFactory()
upon the domain returned bygetDefaultDomain()
.- Parameters:
type
- The type of the archive e.g.WebArchive
- Returns:
- An
Assignable
archive base - Throws:
IllegalArgumentException
- if type is not specifiedUnknownExtensionTypeException
- If no extension mapping is found for the specified type
-
create
public static <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 the defaultConfiguration
. Invoking this method is functionally equivalent to callingArchiveFactory.create(Class, String)
uponDomain.getArchiveFactory()
upon the domain returned bygetDefaultDomain()
.- Parameters:
type
- The type of the archive e.g.WebArchive
archiveName
- The name of the archive- Returns:
- An
Assignable
archive base - Throws:
IllegalArgumentException
- either argument is not specified
-
createFromZipFile
public static <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 theConfiguration
within thegetDefaultDomain()
- Parameters:
type
- The type of the archive e.g.WebArchive
archiveFile
- the archiveName to use- Returns:
- An
Assignable
view - Throws:
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
-