Class DefaultPackagerFactory
- java.lang.Object
-
- org.codehaus.cargo.util.log.LoggedObject
-
- org.codehaus.cargo.generic.spi.AbstractGenericHintFactory<T>
-
- org.codehaus.cargo.generic.spi.AbstractIntrospectionGenericHintFactory<Packager>
-
- org.codehaus.cargo.generic.packager.DefaultPackagerFactory
-
- All Implemented Interfaces:
PackagerFactory,Loggable
public class DefaultPackagerFactory extends AbstractIntrospectionGenericHintFactory<Packager> implements PackagerFactory
DefaultPackagerFactoryimplementation that has all the known container packagers registered against their containers. It also supports registering new packagers against any container.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.codehaus.cargo.generic.spi.AbstractGenericHintFactory
AbstractGenericHintFactory.GenericParameters
-
-
Constructor Summary
Constructors Constructor Description DefaultPackagerFactory()Register default deployers.DefaultPackagerFactory(ClassLoader classLoader)Register packager name mappings.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected PackagercreateInstance(Constructor<? extends Packager> constructor, String hint, AbstractGenericHintFactory.GenericParameters parameters)Create an implementation class instance.PackagercreatePackager(String containerId, PackagerType packagerType, String outputLocation)Create aPackagerinstance matching the specified container id.protected Constructor<? extends Packager>getConstructor(Class<? extends Packager> deployerClass, String hint, AbstractGenericHintFactory.GenericParameters parameters)Create a constructor.booleanisPackagerRegistered(String containerId, PackagerType packagerType)voidregisterPackager(String containerId, PackagerType packagerType, Class<? extends Packager> packagerClass)Registers aPackagerimplementation.voidregisterPackager(String containerId, PackagerType packagerType, String packagerClassName)Registers a packager using a class specified as a String.-
Methods inherited from class org.codehaus.cargo.generic.spi.AbstractIntrospectionGenericHintFactory
createImplementation, registerImplementation
-
Methods inherited from class org.codehaus.cargo.generic.spi.AbstractGenericHintFactory
getMapping, getMappings, hasMapping, registerImplementation
-
Methods inherited from class org.codehaus.cargo.util.log.LoggedObject
getLogger, setLogger
-
-
-
-
Constructor Detail
-
DefaultPackagerFactory
public DefaultPackagerFactory()
Register default deployers.
-
DefaultPackagerFactory
public DefaultPackagerFactory(ClassLoader classLoader)
Register packager name mappings.- Parameters:
classLoader- ClassLoader to discover implementations from. SeeAbstractFactoryRegistry.register(ClassLoader, PackagerFactory)for the details of what this value means.
-
-
Method Detail
-
registerPackager
public void registerPackager(String containerId, PackagerType packagerType, Class<? extends Packager> packagerClass)
Registers aPackagerimplementation.- Specified by:
registerPackagerin interfacePackagerFactory- Parameters:
containerId- the container attached to this packagerpackagerType- the packager's type (directory, zip, etc)packagerClass- the packager implementation class to register
-
registerPackager
public void registerPackager(String containerId, PackagerType packagerType, String packagerClassName)
Registers a packager using a class specified as a String.- Parameters:
containerId- Container id.packagerType- Packager type.packagerClassName- Packager implementation class to register as a String
-
isPackagerRegistered
public boolean isPackagerRegistered(String containerId, PackagerType packagerType)
- Specified by:
isPackagerRegisteredin interfacePackagerFactory- Parameters:
containerId- the container attached to this packager classpackagerType- the type to differentiate this packager from others for the specified container- Returns:
- true if the specified packager is already registered or false otherwise
-
createPackager
public Packager createPackager(String containerId, PackagerType packagerType, String outputLocation)
Create aPackagerinstance matching the specified container id.- Specified by:
createPackagerin interfacePackagerFactory- Parameters:
containerId- the container for which we need to create a packager instancepackagerType- the packager's type (directory, zip, etc)outputLocation- the location where the package will be generated. For example for a Directory Packager this will be the directory into which the package will be generated.- Returns:
- the packager instance
-
getConstructor
protected Constructor<? extends Packager> getConstructor(Class<? extends Packager> deployerClass, String hint, AbstractGenericHintFactory.GenericParameters parameters) throws NoSuchMethodException
Create a constructor.- Specified by:
getConstructorin classAbstractGenericHintFactory<Packager>- Parameters:
deployerClass- implementation class for which to create the constructorhint- the hint to differentiate this implementation class from othersparameters- additional parameters necessary to create the constructor object- Returns:
- the constructor to use for creating an instance
- Throws:
NoSuchMethodException- in case of error
-
createInstance
protected Packager createInstance(Constructor<? extends Packager> constructor, String hint, AbstractGenericHintFactory.GenericParameters parameters) throws Exception
Create an implementation class instance.- Specified by:
createInstancein classAbstractGenericHintFactory<Packager>- Parameters:
constructor- the constructor to use for creating the instancehint- the hint to differentiate this implementation class from othersparameters- additional parameters necessary to create the instance- Returns:
- the created instance
- Throws:
Exception- in case of error
-
-