org.jboss.shrinkwrap.api
Class ArchiveFactory

java.lang.Object
  extended by org.jboss.shrinkwrap.api.ArchiveFactory

public final class ArchiveFactory
extends Object

Responsible for creating Archives, which may be presented to the caller in a designated Assignable view.

Version:
$Revision: $
Author:
ALR, Ken Gullaksen

Method Summary
<T extends Assignable>
T
create(Class<T> type)
          Creates a new archive of the specified type.
<T extends Assignable>
T
create(Class<T> type, String archiveName)
          Creates a new archive of the specified type.
<T extends Assignable>
T
createFromZipFile(Class<T> type, File archiveFile)
          Creates a new archive of the specified type as imported from the specified File.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

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 the 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)

Parameters:
type - The type of the archive e.g. WebArchive
Returns:
An Assignable archive base
Throws:
IllegalArgumentException - if type is not specified
UnknownExtensionTypeException - 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 the Configuration specific to this ArchiveFactory.

Parameters:
type - The type of the archive e.g. WebArchive
archiveName - the archiveName to use
Returns:
An Assignable view
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 specified 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.

Parameters:
type - The type of the archive e.g. WebArchive
archiveFile - the archiveFile to use
Returns:
An Assignable view
Throws:
IllegalArgumentException - If either argument is not supplied, if the specified File does not exist, or is not a valid ZIP file
ArchiveImportException - If an error occurred during the import process


Copyright © 2011 JBoss, a division of Red Hat, Inc.. All Rights Reserved.