org.codehaus.cargo.generic
Class DefaultContainerFactory

java.lang.Object
  extended byorg.codehaus.cargo.util.log.LoggedObject
      extended byorg.codehaus.cargo.generic.spi.AbstractGenericHintFactory
          extended byorg.codehaus.cargo.generic.spi.AbstractIntrospectionGenericHintFactory
              extended byorg.codehaus.cargo.generic.DefaultContainerFactory
All Implemented Interfaces:
ContainerFactory, org.codehaus.cargo.util.log.Loggable

public class DefaultContainerFactory
extends AbstractIntrospectionGenericHintFactory
implements ContainerFactory

Default implementation of ContainerFactory. Registers all known containers.

Version:
$Id: DefaultContainerFactory.java 1233 2006-11-22 09:15:56Z vmassol $

Nested Class Summary
 
Nested classes inherited from class org.codehaus.cargo.generic.spi.AbstractGenericHintFactory
AbstractGenericHintFactory.GenericParameters
 
Constructor Summary
DefaultContainerFactory()
          Initialize container name mappings with container ids.
 
Method Summary
 org.codehaus.cargo.container.Container createContainer(java.lang.String containerId, org.codehaus.cargo.container.ContainerType containerType, org.codehaus.cargo.container.configuration.Configuration configuration)
          Create a container instance instantiated using the specified configuration.
protected  java.lang.Object createInstance(java.lang.reflect.Constructor constructor, java.lang.String containerType, AbstractGenericHintFactory.GenericParameters parameters)
          Create an implementation class instance.
protected  java.lang.reflect.Constructor getConstructor(java.lang.Class containerClass, java.lang.String containerType, AbstractGenericHintFactory.GenericParameters parameters)
          Create a constructor.
 java.lang.Class getContainerClass(java.lang.String containerId, org.codehaus.cargo.container.ContainerType containerType)
          
 java.util.Map getContainerIds()
          
 boolean isContainerRegistered(java.lang.String containerId, org.codehaus.cargo.container.ContainerType containerType)
          
 void registerContainer(java.lang.String containerId, org.codehaus.cargo.container.ContainerType containerType, java.lang.Class containerClass)
          
 void registerContainer(java.lang.String containerId, org.codehaus.cargo.container.ContainerType containerType, java.lang.String containerClassName)
          Registers a container 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

DefaultContainerFactory

public DefaultContainerFactory()
Initialize container name mappings with container ids.

Method Detail

isContainerRegistered

public boolean isContainerRegistered(java.lang.String containerId,
                                     org.codehaus.cargo.container.ContainerType containerType)

Specified by:
isContainerRegistered in interface ContainerFactory
Parameters:
containerId - the id of the container to check
containerType - the container type
Returns:
true if the specified container and type is already registered or false otherwise
See Also:
ContainerFactory.isContainerRegistered(String, ContainerType)

registerContainer

public void registerContainer(java.lang.String containerId,
                              org.codehaus.cargo.container.ContainerType containerType,
                              java.lang.Class containerClass)

Specified by:
registerContainer in interface ContainerFactory
Parameters:
containerId - the id of the container to register
containerType - the container type to register (ContainerType.INSTALLED, ContainerType.EMBEDDED or ContainerType.REMOTE)
containerClass - the container implementation class to register
See Also:
ContainerFactory.registerContainer(String, org.codehaus.cargo.container.ContainerType, Class)

registerContainer

public void registerContainer(java.lang.String containerId,
                              org.codehaus.cargo.container.ContainerType containerType,
                              java.lang.String containerClassName)
Registers a container using a class specified as a String.

Parameters:
containerId - {@inheritDoc}
containerType - {@inheritDoc}
containerClassName - the container implementation class to register as a String
See Also:
registerContainer(String, ContainerType, Class)

getContainerClass

public java.lang.Class getContainerClass(java.lang.String containerId,
                                         org.codehaus.cargo.container.ContainerType containerType)

Specified by:
getContainerClass in interface ContainerFactory
Parameters:
containerId - the id of the container for which to retrieve the implementation class
containerType - the container's type (ContainerType.INSTALLED, ContainerType.EMBEDDED or ContainerType.REMOTE)
Returns:
the container implementation class
See Also:
ContainerFactory.getContainerClass(java.lang.String, org.codehaus.cargo.container.ContainerType)

createContainer

public org.codehaus.cargo.container.Container createContainer(java.lang.String containerId,
                                                              org.codehaus.cargo.container.ContainerType containerType,
                                                              org.codehaus.cargo.container.configuration.Configuration configuration)
Create a container instance instantiated using the specified configuration.

Specified by:
createContainer in interface ContainerFactory
Parameters:
containerId - the name under which the container will be looked up
containerType - the container's type (local installed, local embedded, remote, etc)
configuration - the configuration to pass to the container's constructor
Returns:
the container whose class name matches the parameter passed
See Also:
ContainerFactory.createContainer(String, ContainerType, Configuration)

getConstructor

protected java.lang.reflect.Constructor getConstructor(java.lang.Class containerClass,
                                                       java.lang.String containerType,
                                                       AbstractGenericHintFactory.GenericParameters parameters)
                                                throws java.lang.NoSuchMethodException
Create a constructor.

Specified by:
getConstructor in class AbstractGenericHintFactory
Parameters:
containerClass - implementation class for which to create the constructor
containerType - 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:
java.lang.NoSuchMethodException - in case of error
See Also:
AbstractGenericHintFactory.getConstructor(java.lang.Class, java.lang.String, org.codehaus.cargo.generic.spi.AbstractGenericHintFactory.GenericParameters)

createInstance

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

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

getContainerIds

public java.util.Map getContainerIds()

Specified by:
getContainerIds in interface ContainerFactory
Returns:
the list of container ids that have been registered as Map. The Map keys are the container ids and the Map values are the lists of ContainerTypes registered for that container, as a Set.
See Also:
ContainerFactory.getContainerIds()


Copyright © 2004-2008 Codehaus. All Rights Reserved.