Package org.jboss.shrinkwrap.api
Class ShrinkWrap
- java.lang.Object
-
- org.jboss.shrinkwrap.api.ShrinkWrap
-
public final class ShrinkWrap extends java.lang.ObjectMain entry point into the ShrinkWrap system. EachArchivehas an associatedConfigurationprovided at construction by theDomainunder which the archive was created.ShrinkWrapprovides static access to the defaultDomain(and by extension the defaultConfiguration), as well as a shortcut mechanism to createArchives under these defaults by way ofcreate(Class, String). Additionally, this class is the hook to create newDomains viacreateDomain(),createDomain(ConfigurationBuilder)orcreateDomain(Configuration).- Version:
- $Revision: $
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classShrinkWrap.DefaultDomainWrapperSingleton wrapper to encapsulate a default domain
-
Constructor Summary
Constructors Modifier Constructor Description privateShrinkWrap()Internal constructor; not to be called as this class provides static utilities only
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T extends Assignable>
Tcreate(java.lang.Class<T> type)Creates a new archive of the specified type.static <T extends Assignable>
Tcreate(java.lang.Class<T> type, java.lang.String archiveName)Creates a new archive of the specified type.static DomaincreateDomain()Creates a newDomaincontaining a defaultConfiguration.static DomaincreateDomain(Configuration configuration)Creates a newDomaincontaining configuration properties from the suppliedConfiguration.static DomaincreateDomain(ConfigurationBuilder builder)Creates a newDomaincontaining configuration properties from the suppliedConfigurationBuilder.static <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.static DomaingetDefaultDomain()Returns a single domain with default configuration for use in applications with no explicit configuration or isolation requirements.
-
-
-
Method Detail
-
createDomain
public static Domain createDomain()
Creates a newDomaincontaining a defaultConfiguration.ArchiveFactorys created from this domain will have isolated configuration from archive factories created from other domains. Likewise, allArchiveFactorys andArchives created from the returned domain will share the same configuration.- Returns:
- A new
Domainwith default configuration
-
createDomain
public static Domain createDomain(ConfigurationBuilder builder) throws java.lang.IllegalArgumentException
Creates a newDomaincontaining configuration properties from the suppliedConfigurationBuilder.ArchiveFactorys created from this domain will have isolated configuration from archive factories created from other domains. Likewise, allArchiveFactorys andArchives created from the returned domain will share the same configuration.- Parameters:
builder- Builder with which we should create aConfigurationfor thisDomain- Returns:
- A new
Domainwith default configuration - Throws:
java.lang.IllegalArgumentException- If the builder is not supplied
-
createDomain
public static Domain createDomain(Configuration configuration) throws java.lang.IllegalArgumentException
Creates a newDomaincontaining configuration properties from the suppliedConfiguration.ArchiveFactorys created from this domain will have isolated configuration from archive factories created from other domains. Likewise, allArchiveFactorys andArchives created from the returned domain will share the same configuration.- Parameters:
configuration-Configurationfor thisDomain- Returns:
- A new
Domainwith default configuration - Throws:
java.lang.IllegalArgumentException- If the configuration is not supplied
-
getDefaultDomain
public static Domain 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(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 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
Assignablearchive base - Throws:
java.lang.IllegalArgumentException- if type is not specifiedUnknownExtensionTypeException- If no extension mapping is found for the specified type
-
create
public static <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 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.WebArchivearchiveName- The name of the archive- Returns:
- An
Assignablearchive base - Throws:
java.lang.IllegalArgumentException- either argument is not specified
-
createFromZipFile
public static <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 theConfigurationwithin thegetDefaultDomain()- Parameters:
type- The type of the archive e.g.WebArchivearchiveFile- the archiveName to use- Returns:
- An
Assignableview - Throws:
java.lang.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
-
-