public final class ShrinkWrap
extends java.lang.Object
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)
.Modifier and Type | Class and Description |
---|---|
private static class |
ShrinkWrap.DefaultDomainWrapper
Singleton wrapper to encapsulate a default domain
|
Modifier | Constructor and Description |
---|---|
private |
ShrinkWrap()
Internal constructor; not to be called as this class provides static utilities only
|
Modifier and Type | Method and Description |
---|---|
static <T extends Assignable> |
create(java.lang.Class<T> type)
Creates a new archive of the specified type.
|
static <T extends Assignable> |
create(java.lang.Class<T> type,
java.lang.String archiveName)
Creates a new archive of the specified type.
|
static Domain |
createDomain()
Creates a new
Domain containing a default Configuration . |
static Domain |
createDomain(Configuration configuration)
Creates a new
Domain containing configuration properties from the supplied Configuration . |
static Domain |
createDomain(ConfigurationBuilder builder)
Creates a new
Domain containing configuration properties from the supplied ConfigurationBuilder . |
static <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 . |
static Domain |
getDefaultDomain()
Returns a single domain with default configuration for use in applications with no explicit configuration or
isolation requirements.
|
private ShrinkWrap()
public static Domain createDomain()
Domain
containing a default Configuration
. ArchiveFactory
s created from
this domain will have isolated configuration from archive factories created from other domains. Likewise, all
ArchiveFactory
s and Archive
s created from the returned domain will share the same configuration.Domain
with default configurationpublic static Domain createDomain(ConfigurationBuilder builder) throws java.lang.IllegalArgumentException
Domain
containing configuration properties from the supplied ConfigurationBuilder
.
ArchiveFactory
s created from this domain will have isolated configuration from archive factories created
from other domains. Likewise, all ArchiveFactory
s and Archive
s created from the returned domain
will share the same configuration.builder
- Builder with which we should create a Configuration
for this Domain
Domain
with default configurationjava.lang.IllegalArgumentException
- If the builder is not suppliedpublic static Domain createDomain(Configuration configuration) throws java.lang.IllegalArgumentException
Domain
containing configuration properties from the supplied Configuration
.
ArchiveFactory
s created from this domain will have isolated configuration from archive factories created
from other domains. Likewise, all ArchiveFactory
s and Archive
s created from the returned domain
will share the same configuration.configuration
- Configuration
for this Domain
Domain
with default configurationjava.lang.IllegalArgumentException
- If the configuration is not suppliedpublic static Domain getDefaultDomain()
Domain
public static <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)
Invoking this method is functionally equivalent to calling ArchiveFactory.create(Class)
upon
Domain.getArchiveFactory()
upon the domain returned by getDefaultDomain()
.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 static <T extends Assignable> T create(java.lang.Class<T> type, java.lang.String archiveName) throws java.lang.IllegalArgumentException
Configuration
.
Invoking this method is functionally equivalent to calling ArchiveFactory.create(Class, String)
upon
Domain.getArchiveFactory()
upon the domain returned by getDefaultDomain()
.type
- The type of the archive e.g. WebArchive
archiveName
- The name of the archiveAssignable
archive basejava.lang.IllegalArgumentException
- either argument is not specifiedpublic static <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
within the getDefaultDomain()
type
- The type of the archive e.g. WebArchive
archiveFile
- the archiveName 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