Package org.codehaus.cargo.generic.spi
Class AbstractGenericHintFactory<T>
- java.lang.Object
-
- org.codehaus.cargo.util.log.LoggedObject
-
- org.codehaus.cargo.generic.spi.AbstractGenericHintFactory<T>
-
- All Implemented Interfaces:
Loggable
- Direct Known Subclasses:
AbstractIntrospectionGenericHintFactory
public abstract class AbstractGenericHintFactory<T> extends LoggedObject
Factory implementation that registers implementation classes under a given key of typeRegistrationKey. This abstract factory class is extended by all the different Cargo factories.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceAbstractGenericHintFactory.GenericParametersGeneric class to be extended by implementors ofAbstractGenericHintFactoryin order to provide possible additional parameters.
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractGenericHintFactory()Place to register default configurations.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected TcreateImplementation(RegistrationKey key, AbstractGenericHintFactory.GenericParameters parameters, String implementationConceptName)Generic method to create an implementation based on the registered implementation classes.protected abstract TcreateInstance(Constructor<? extends T> constructor, String hint, AbstractGenericHintFactory.GenericParameters parameters)Create an implementation class instance.protected abstract Constructor<? extends T>getConstructor(Class<? extends T> implementationClass, String hint, AbstractGenericHintFactory.GenericParameters parameters)Create a constructor.protected Class<? extends T>getMapping(RegistrationKey key)protected Map<RegistrationKey,Class<? extends T>>getMappings()protected booleanhasMapping(RegistrationKey key)protected voidregisterImplementation(RegistrationKey key, Class<? extends T> implementationClass)Register an implementation class for a given key.-
Methods inherited from class org.codehaus.cargo.util.log.LoggedObject
getLogger, setLogger
-
-
-
-
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 Class<? extends T> getMapping(RegistrationKey key)
- Parameters:
key- the key associated with the implementation class to return- Returns:
- the implementation class
-
getMappings
protected Map<RegistrationKey,Class<? extends T>> getMappings()
- Returns:
- the mappings indexed using a
RegistrationKey.
-
registerImplementation
protected void registerImplementation(RegistrationKey key, Class<? extends T> implementationClass)
Register an implementation class for a given key.- Parameters:
key- the key under which to register the implementation classimplementationClass- the implementation class to register
-
createImplementation
protected T createImplementation(RegistrationKey key, AbstractGenericHintFactory.GenericParameters parameters, String implementationConceptName)
Generic method to create an implementation based on the registered implementation classes.- Parameters:
key- the key under which the implementation class is registeredparameters- the additional parameters necessary to create the constructor objectimplementationConceptName- 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 Constructor<? extends T> getConstructor(Class<? extends T> implementationClass, String hint, AbstractGenericHintFactory.GenericParameters parameters) throws NoSuchMethodException
Create a constructor.- Parameters:
implementationClass- 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 abstract T createInstance(Constructor<? extends T> constructor, String hint, AbstractGenericHintFactory.GenericParameters parameters) throws Exception
Create an implementation class instance.- 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
-
-