org.codehaus.cargo.generic.packager
Class DefaultPackagerFactory

java.lang.Object
  extended by org.codehaus.cargo.util.log.LoggedObject
      extended by org.codehaus.cargo.generic.spi.AbstractGenericHintFactory
          extended by org.codehaus.cargo.generic.spi.AbstractIntrospectionGenericHintFactory
              extended by org.codehaus.cargo.generic.packager.DefaultPackagerFactory
All Implemented Interfaces:
PackagerFactory, Loggable

public class DefaultPackagerFactory
extends AbstractIntrospectionGenericHintFactory
implements PackagerFactory

Default PackagerFactory implementation that has all the known container packagers registered against their containers. It also supports registering new packagers against any container.

Version:
$Id: DefaultPackagerFactory.java 1919 2009-03-05 02:23:52Z adriancole $

Nested Class Summary
 
Nested classes/interfaces inherited from class org.codehaus.cargo.generic.spi.AbstractGenericHintFactory
AbstractGenericHintFactory.GenericParameters
 
Constructor Summary
DefaultPackagerFactory()
          Register default deployers.
DefaultPackagerFactory(ClassLoader classLoader)
          Register packager name mappings.
 
Method Summary
protected  Object createInstance(Constructor constructor, String hint, AbstractGenericHintFactory.GenericParameters parameters)
          Create an implementation class instance.
 Packager createPackager(String containerId, PackagerType packagerType, String outputLocation)
          Create a Packager instance matching the specified container id.
protected  Constructor getConstructor(Class deployerClass, String hint, AbstractGenericHintFactory.GenericParameters parameters)
          Create a constructor.
 boolean isPackagerRegistered(String containerId, PackagerType packagerType)
          
 void registerPackager(String containerId, PackagerType packagerType, Class packagerClass)
          Registers a Packager implementation.
 void registerPackager(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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultPackagerFactory

public DefaultPackagerFactory()
Register default deployers.


DefaultPackagerFactory

public DefaultPackagerFactory(ClassLoader classLoader)
Register packager name mappings.

Parameters:
classLoader - ClassLoader to discover implementations from. See AbstractFactoryRegistry.register(ClassLoader, PackagerFactory) for the details of what this value means.
Method Detail

registerPackager

public void registerPackager(String containerId,
                             PackagerType packagerType,
                             Class packagerClass)
Registers a Packager implementation.

Specified by:
registerPackager in interface PackagerFactory
Parameters:
containerId - the container attached to this packager
packagerType - the packager's type (directory, zip, etc)
packagerClass - the packager implementation class to register
See Also:
PackagerFactory.registerPackager(String, org.codehaus.cargo.container.packager.PackagerType, Class)

registerPackager

public void registerPackager(String containerId,
                             PackagerType packagerType,
                             String packagerClassName)
Registers a packager using a class specified as a String.

Parameters:
containerId -
packagerType -
packagerClassName - the packager implementation class to register as a String
See Also:
registerPackager(String, org.codehaus.cargo.container.packager.PackagerType, Class)

isPackagerRegistered

public boolean isPackagerRegistered(String containerId,
                                    PackagerType packagerType)

Specified by:
isPackagerRegistered in interface PackagerFactory
Parameters:
containerId - the container attached to this packager class
packagerType - the type to differentiate this packager from others for the specified container
Returns:
true if the specified packager is already registered or false otherwise
See Also:
PackagerFactory.isPackagerRegistered(String, org.codehaus.cargo.container.packager.PackagerType)

createPackager

public Packager createPackager(String containerId,
                               PackagerType packagerType,
                               String outputLocation)
Create a Packager instance matching the specified container id.

Specified by:
createPackager in interface PackagerFactory
Parameters:
containerId - the container for which we need to create a packager instance
packagerType - 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
See Also:
PackagerFactory.createPackager(java.lang.String, org.codehaus.cargo.container.packager.PackagerType, java.lang.String)

getConstructor

protected Constructor getConstructor(Class deployerClass,
                                     String hint,
                                     AbstractGenericHintFactory.GenericParameters parameters)
                              throws NoSuchMethodException
Create a constructor.

Specified by:
getConstructor in class AbstractGenericHintFactory
Parameters:
deployerClass - implementation class for which to create the constructor
hint - the hint to differentiate this implementation class from others
parameters - additional parameters necessary to create the constructor object
Returns:
the constructor to use for creating an instance
Throws:
NoSuchMethodException - in case of error
See Also:
AbstractGenericHintFactory.getConstructor(Class, String, org.codehaus.cargo.generic.spi.AbstractGenericHintFactory.GenericParameters)

createInstance

protected Object createInstance(Constructor constructor,
                                String hint,
                                AbstractGenericHintFactory.GenericParameters parameters)
                         throws Exception
Create an implementation class instance.

Specified by:
createInstance in class AbstractGenericHintFactory
Parameters:
constructor - the constructor to use for creating the instance
hint - the hint to differentiate this implementation class from others
parameters - additional parameters necessary to create the instance
Returns:
the created instance
Throws:
Exception - in case of error
See Also:
AbstractGenericHintFactory.createInstance(java.lang.reflect.Constructor, java.lang.String, org.codehaus.cargo.generic.spi.AbstractGenericHintFactory.GenericParameters)


Copyright © 2004-2012 Codehaus. All Rights Reserved.