org.codehaus.cargo.generic.spi
Class AbstractGenericHintFactory

java.lang.Object
  extended byorg.codehaus.cargo.util.log.LoggedObject
      extended byorg.codehaus.cargo.generic.spi.AbstractGenericHintFactory
All Implemented Interfaces:
org.codehaus.cargo.util.log.Loggable
Direct Known Subclasses:
AbstractIntrospectionGenericHintFactory

public abstract class AbstractGenericHintFactory
extends org.codehaus.cargo.util.log.LoggedObject

Factory implementation that registers implementation classes under a given key of type RegistrationKey. This abstract factory class is extended by all the different Cargo factories.

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

Nested Class Summary
static interface AbstractGenericHintFactory.GenericParameters
          Generic class to be extended by implementors of AbstractGenericHintFactory in order to provide possible additional parameters.
 
Constructor Summary
protected AbstractGenericHintFactory()
          Place to register default configurations.
 
Method Summary
protected  java.lang.Object createImplementation(RegistrationKey key, AbstractGenericHintFactory.GenericParameters parameters, java.lang.String implementationConceptName)
          Generic method to create an implementation based on the registered implementation classes.
protected abstract  java.lang.Object createInstance(java.lang.reflect.Constructor constructor, java.lang.String hint, AbstractGenericHintFactory.GenericParameters parameters)
          Create an implementation class instance.
protected abstract  java.lang.reflect.Constructor getConstructor(java.lang.Class implementationClass, java.lang.String hint, AbstractGenericHintFactory.GenericParameters parameters)
          Create a constructor.
protected  java.lang.Class getMapping(RegistrationKey key)
           
protected  java.util.Map getMappings()
           
protected  boolean hasMapping(RegistrationKey key)
           
protected  void registerImplementation(RegistrationKey key, java.lang.Class implementationClass)
          Register an implementation class for a given key.
 
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

AbstractGenericHintFactory

protected AbstractGenericHintFactory()
Place to register default configurations.

Method Detail

hasMapping

protected boolean hasMapping(RegistrationKey key)
Parameters:
key - the key associated with the implementation class
Returns:
true if the mapping is already registered or false otherwise

getMapping

protected java.lang.Class getMapping(RegistrationKey key)
Parameters:
key - the key associated with the implementation class to return
Returns:
the implementation class

getMappings

protected java.util.Map getMappings()
Returns:
the mappings indexed using a RegistrationKey.

registerImplementation

protected void registerImplementation(RegistrationKey key,
                                      java.lang.Class implementationClass)
Register an implementation class for a given key.

Parameters:
key - the key under which to register the implementation class
implementationClass - the implementation class to register

createImplementation

protected java.lang.Object createImplementation(RegistrationKey key,
                                                AbstractGenericHintFactory.GenericParameters parameters,
                                                java.lang.String implementationConceptName)
Generic method to create an implementation based on the registered implementation classes.

Parameters:
key - the key under which the implementation class is registered
parameters - the additional parameters necessary to create the constructor object
implementationConceptName - the name of what the implementation class is representing. This is used in exception text messages to provide message customization. For example "container", "configuration", "deployable', etc.
Returns:
the created instance

getConstructor

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

Parameters:
implementationClass - 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:
java.lang.NoSuchMethodException - in case of error

createInstance

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

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:
java.lang.Exception - in case of error


Copyright © 2004-2008 Codehaus. All Rights Reserved.