Package org.codehaus.cargo.generic
Class DefaultContainerFactory
- java.lang.Object
-
- org.codehaus.cargo.util.log.LoggedObject
-
- org.codehaus.cargo.generic.spi.AbstractGenericHintFactory<T>
-
- org.codehaus.cargo.generic.spi.AbstractIntrospectionGenericHintFactory<Container>
-
- org.codehaus.cargo.generic.DefaultContainerFactory
-
- All Implemented Interfaces:
ContainerFactory
,Loggable
public class DefaultContainerFactory extends AbstractIntrospectionGenericHintFactory<Container> implements ContainerFactory
Default implementation ofContainerFactory
. Registers all known containers.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.codehaus.cargo.generic.spi.AbstractGenericHintFactory
AbstractGenericHintFactory.GenericParameters
-
-
Constructor Summary
Constructors Constructor Description DefaultContainerFactory()
Initialize container name mappings with container ids.DefaultContainerFactory(ClassLoader classLoader)
Register packager name mappings.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Container
createContainer(String containerId, ContainerType containerType, Configuration configuration)
Create a container instance instantiated using the specified configuration.protected Container
createInstance(Constructor<? extends Container> constructor, String containerType, AbstractGenericHintFactory.GenericParameters parameters)
Create an implementation class instance.protected Constructor<? extends Container>
getConstructor(Class<? extends Container> containerClass, String containerType, AbstractGenericHintFactory.GenericParameters parameters)
Create a constructor.Class<? extends Container>
getContainerClass(String containerId, ContainerType containerType)
Map<String,Set<ContainerType>>
getContainerIds()
boolean
isContainerRegistered(String containerId, ContainerType containerType)
void
registerContainer(String containerId, ContainerType containerType, Class<? extends Container> containerClass)
void
registerContainer(String containerId, ContainerType containerType, 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
-
-
-
-
Constructor Detail
-
DefaultContainerFactory
public DefaultContainerFactory()
Initialize container name mappings with container ids.
-
DefaultContainerFactory
public DefaultContainerFactory(ClassLoader classLoader)
Register packager name mappings.- Parameters:
classLoader
- ClassLoader to discover implementations from. SeeAbstractFactoryRegistry.register(ClassLoader, ContainerFactory)
for the details of what this value means.
-
-
Method Detail
-
isContainerRegistered
public boolean isContainerRegistered(String containerId, ContainerType containerType)
- Specified by:
isContainerRegistered
in interfaceContainerFactory
- Parameters:
containerId
- the id of the container to checkcontainerType
- the container type- Returns:
- true if the specified container and type is already registered or false otherwise
-
registerContainer
public void registerContainer(String containerId, ContainerType containerType, Class<? extends Container> containerClass)
- Specified by:
registerContainer
in interfaceContainerFactory
- Parameters:
containerId
- the id of the container to registercontainerType
- the container type to register (ContainerType.INSTALLED
,ContainerType.EMBEDDED
orContainerType.REMOTE
)containerClass
- the container implementation class to register
-
registerContainer
public void registerContainer(String containerId, ContainerType containerType, String containerClassName)
Registers a container using a class specified as a String.- Parameters:
containerId
- Container id.containerType
- Container type.containerClassName
- Container implementation class to register as a String- See Also:
registerContainer(String, ContainerType, Class)
-
getContainerClass
public Class<? extends Container> getContainerClass(String containerId, ContainerType containerType)
- Specified by:
getContainerClass
in interfaceContainerFactory
- Parameters:
containerId
- the id of the container for which to retrieve the implementation classcontainerType
- the container's type (ContainerType.INSTALLED
,ContainerType.EMBEDDED
orContainerType.REMOTE
)- Returns:
- the container implementation class
-
createContainer
public Container createContainer(String containerId, ContainerType containerType, Configuration configuration)
Create a container instance instantiated using the specified configuration.- Specified by:
createContainer
in interfaceContainerFactory
- Parameters:
containerId
- the name under which the container will be looked upcontainerType
- 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
-
getConstructor
protected Constructor<? extends Container> getConstructor(Class<? extends Container> containerClass, String containerType, AbstractGenericHintFactory.GenericParameters parameters) throws NoSuchMethodException
Create a constructor.- Specified by:
getConstructor
in classAbstractGenericHintFactory<Container>
- Parameters:
containerClass
- implementation class for which to create the constructorcontainerType
- 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 Container createInstance(Constructor<? extends Container> constructor, String containerType, AbstractGenericHintFactory.GenericParameters parameters) throws Exception
Create an implementation class instance.- Specified by:
createInstance
in classAbstractGenericHintFactory<Container>
- Parameters:
constructor
- the constructor to use for creating the instancecontainerType
- 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
-
getContainerIds
public Map<String,Set<ContainerType>> getContainerIds()
- Specified by:
getContainerIds
in interfaceContainerFactory
- Returns:
- the list of container ids that have been registered as Map.
-
-