com.sourceforge.jpatterns.patterns.factory
Interface IJPFactory

All Superinterfaces:
com.zmicer.utils.model.ICheckable, IJPattern, Serializable
All Known Implementing Classes:
JPFactoryImpl

public interface IJPFactory
extends IJPattern

The factory pattern implementation (in the terms of the JPatterns concept). Please be noticed the real implementation of this interface is specified at the JPatterns config properties file. When we have the factory pattern working then we would be able to save other implementationsw at the factory. Be noticed that there would be mapping castor type base name <-> implementation of the JPatterns interface we would need for working with the concrete castor type.
All the methods of this interface have "scope" argument. It is optional. If this is null we use the scope of the appropriate Factory object to obtain the scope of the implementation. if it is not null - we are using it as the scope id - please review comments to IJPEngine.getFactory(String,String) for more on that. todo [zmicer]: provide XML based examples of the configurations for the each method. Document the pattern.

note [zmicer]: be noticed this interface and the implementation are used for both consumer and framework specific operations.

$Author:: zmicer $
$Rev:: 67 $
* $Date:: 2007-08-28 21:37:07 #$


Method Summary
 Object getImplementation(Class interfaceClass, String scope)
          Get implementation of the interface defined by the given class and the scope we need to obtain.
 Object getImplementation(Class interfaceClass, String implType, String scope)
          Get implementation of the interface defined by the given class and the scope we need to obtain.
 Object getImplementation(String interfaceClassBaseName, String scope)
          Get implementation of the interface defined by the given class (class of the interface).
 Object getImplementation(String interfaceClassBaseName, String implType, String scope)
          Get implementation of the interface defined by the given class (class of the interface).
 String getImplementationFullName(Class interfaceClass, String scope)
          Get the full name of the implementation of the interface defined by the given class and the scope we need to obtain.
 String getImplementationFullName(String interfaceClassBaseName, String scope)
          Get the full name of the implementation of the interface defined by the given class (class of the interface).
 Map<String,Object> getImplementations(Class interfaceClass, String scope)
          Get the Map of implementations of the interface defined by the given class and the scope we need to obtain.
 Map<String,Object> getImplementations(String interfaceClassBaseName, String scope)
          Get the Map of implementations of the interface defined by the given class and the scope we need to obtain.
 Map<String,String> getImplementationsFullNames(Class interfaceClass, String scope)
          Get the Map of implementations of the interface defined by the given class and the scope we need to obtain.
 Map<String,String> getImplementationsFullNames(String interfaceClassBaseName, String scope)
          Get the Map of implementations of the interface defined by the given class and the scope we need to obtain.
 Object getOperator(Class productBaseClass, Class operatorBaseClass, Object productObj, String scope)
          The the operator for the provided object and scope.
 Map<Object,Object> getOperators(Class productBaseClass, Class operatorBaseClass, List<Object> productObjs, String scope)
          Get the mappings between the operators (which would be created at this methods) and the List of the products objects provided here.
 
Methods inherited from interface com.sourceforge.jpatterns.patterns.IJPattern
checkCastorConfig, init
 
Methods inherited from interface com.zmicer.utils.model.ICheckable
check
 

Method Detail

getImplementation

Object getImplementation(Class interfaceClass,
                         String scope)
                         throws JPConfigException
Get implementation of the interface defined by the given class and the scope we need to obtain.
Be noticed the validation if the implementation specified at the JPatterns config file is casted to the interface provided.

Parameters:
interfaceClass - the class representing the interface Can not be null (otherwise IllegalArgumentException would appear).
scope - the scope where do we need to find the implementation. In the case this is null - the default value for scope would be used (would be taken from factory object)
Returns:
the Object = the real implementation of the class.
Throws:
JPConfigException - in the case we can not retrieve the implementation for some reasons

getImplementation

Object getImplementation(String interfaceClassBaseName,
                         String scope)
                         throws JPConfigException
Get implementation of the interface defined by the given class (class of the interface).
Validation if the implementation is casted to the interface defining by interfaceClassBaseName is not done here as this String could be just any key string

Parameters:
interfaceClassBaseName - the base name of the interface (e.g. IJPFactory), also it could be just String key (just logical case for which we need to obtain smth.)
scope - the scope where do we need to find the implementation. In the case this is null - the default value for scope would be used (would be taken from factory object)
Returns:
the Object = the real implementation of the class.
Throws:
JPConfigException - in the case we can not retrieve the implementation for some reasons

getImplementationFullName

String getImplementationFullName(Class interfaceClass,
                                 String scope)
                                 throws JPConfigException
Get the full name of the implementation of the interface defined by the given class and the scope we need to obtain.

Parameters:
interfaceClass - the class representing the interface Can not be null (otherwise IllegalArgumentException would appear).
scope - the scope where do we need to find the implementation. In the case this is null - the default value for scope would be used (would be taken from factory object)
Returns:
the Object = the real implementation of the class.
Throws:
JPConfigException - in the case we can not retrieve the implementation for some reasons

getImplementationFullName

String getImplementationFullName(String interfaceClassBaseName,
                                 String scope)
                                 throws JPConfigException
Get the full name of the implementation of the interface defined by the given class (class of the interface).

Parameters:
interfaceClassBaseName - the base name of the interface (e.g. IJPFactory)
scope - the scope where do we need to find the implementation. In the case this is null - the default value for scope would be used (would be taken from factory object)
Returns:
the Object = the real implementation of the class.
Throws:
JPConfigException - in the case we can not retrieve the implementation for some reasons

getImplementation

Object getImplementation(Class interfaceClass,
                         String implType,
                         String scope)
                         throws JPConfigException
Get implementation of the interface defined by the given class and the scope we need to obtain.
note [zmicer]: be noticed that validation if the given interface is the super type of the implementation is performed in this method

Parameters:
interfaceClass - the class representing the interface Can not be null (otherwise IllegalArgumentException would appear).
implType - the type of implementation
scope - the scope where do we need to find the implementation. In the case this is null - the default value for scope would be used (would be taken from factory object)
Returns:
the Object = the real implementation of the class.
Throws:
JPConfigException - in the case we can not retrieve the implementation for some reasons

getImplementation

Object getImplementation(String interfaceClassBaseName,
                         String implType,
                         String scope)
                         throws JPConfigException
Get implementation of the interface defined by the given class (class of the interface).
note [zmicer]: be noticed that validation if the given interface is the super type of the implementation is not performed in this method

Parameters:
interfaceClassBaseName - the base name of the interface (e.g. IJPFactory)
implType - the type of implementation
scope - the scope where do we need to find the implementation. In the case this is null - the default value for scope would be used (would be taken from factory object)
Returns:
the Object = the real implementation of the class.
Throws:
JPConfigException - in the case we can not retrieve the implementation for some reasons

getImplementations

Map<String,Object> getImplementations(Class interfaceClass,
                                      String scope)
                                      throws JPConfigException
Get the Map of implementations of the interface defined by the given class and the scope we need to obtain.
The format is as follows: #key: logical type we need #value: the Object - the concrete implementation of the interface provided corresponding to the logical type

Parameters:
interfaceClass - the class representing the interface Can not be null (otherwise IllegalArgumentException would appear).
scope - the scope where do we need to find the implementation. In the case this is null - the default value for scope would be used (would be taken from factory object)
Returns:
the Object = the real implementation of the class.
Throws:
JPConfigException - in the case we can not retrieve the implementation for some reasons

getImplementations

Map<String,Object> getImplementations(String interfaceClassBaseName,
                                      String scope)
                                      throws JPConfigException
Get the Map of implementations of the interface defined by the given class and the scope we need to obtain.
The format is as follows: #key: logical type we need #value: the Object - the concrete implementation of the interface provided corresponding to the logical type

Parameters:
interfaceClassBaseName - the base name of the interface (e.g. IJPFactory)
scope - the scope where do we need to find the implementation. In the case this is null - the default value for scope would be used (would be taken from factory object)
Returns:
the Object = the real implementation of the class.
Throws:
JPConfigException - in the case we can not retrieve the implementation for some reasons

getImplementationsFullNames

Map<String,String> getImplementationsFullNames(Class interfaceClass,
                                               String scope)
                                               throws JPConfigException
Get the Map of implementations of the interface defined by the given class and the scope we need to obtain.
The format is as follows: #key: logical type we need #value: the full name of the concrete implementation of the interface provided corresponding to the logical type

Parameters:
interfaceClass - the class representing the interface Can not be null (otherwise IllegalArgumentException would appear).
scope - the scope where do we need to find the implementation. In the case this is null - the default value for scope would be used (would be taken from factory object)
Returns:
the Object = the real implementation of the class.
Throws:
JPConfigException - in the case we can not retrieve the implementation for some reasons

getImplementationsFullNames

Map<String,String> getImplementationsFullNames(String interfaceClassBaseName,
                                               String scope)
                                               throws JPConfigException
Get the Map of implementations of the interface defined by the given class and the scope we need to obtain.
The format is as follows: #key: logical type we need #value: the full name of the concrete implementation of the interface provided corresponding to the logical type

Parameters:
interfaceClassBaseName - the base name of the interface (e.g. IJPFactory)
scope - the scope where do we need to find the implementation. In the case this is null - the default value for scope would be used (would be taken from factory object)
Returns:
the Object = the real implementation of the class.
Throws:
JPConfigException - in the case we can not retrieve the implementation for some reasons

getOperator

Object getOperator(Class productBaseClass,
                   Class operatorBaseClass,
                   Object productObj,
                   String scope)
                   throws JPConfigException
The the operator for the provided object and scope. This method would determine the base interface of the product (we would consider the implementation class implements the appropriate interface at once).
The key we would find to obtained the appropriate castor config item would be: %base name of productBaseClass% + "_" + %base name of operatorBaseClass%

Parameters:
productBaseClass - the interface or base class of the product for which we are finding the implementation of the operator. Still the actual class of the product provided would be used too. Can not be null (otherwise IllegalArgumentException would appear).
operatorBaseClass - the interface of the base class of the operator we would need to obtain the appropriate configuration item. Be noticed this base class defines the scope we need to consider to obtain the necessary operator Can not be null (otherwise IllegalArgumentException would appear).
productObj - the product for which we need the implementation. This product should of the productBaseClass class Can not be null (otherwise IllegalArgumentException would appear).
scope - the scope where do we need to find the implementation. In the case this is null - the default value for scope would be used (would be taken from factory object)
Returns:
the instance of the operator to be used for the given product.
Throws:
JPConfigException - in the case we can not retrieve the implementation for some reasons

getOperators

Map<Object,Object> getOperators(Class productBaseClass,
                                Class operatorBaseClass,
                                List<Object> productObjs,
                                String scope)
                                throws JPConfigException
Get the mappings between the operators (which would be created at this methods) and the List of the products objects provided here. Also the classes for the products and operators are provided as the base path to the necessary Jpatterns configuration. note [zmicer]: In the case there are some different products instances with identical class only one operator would be created.

Parameters:
productBaseClass - the interface or base class of the product for which we are finding the implementation of the operator. Still the actual class of the product provided would be used too. Can not be null (otherwise IllegalArgumentException would appear).
operatorBaseClass - the interface of the base class of the operator we would need to obtain the appropriate configuration item. Be noticed this base class defines the scope we need to consider to obtain the necessary operator Can not be null (otherwise IllegalArgumentException would appear).
productObjs - the List of the products for which we need to obtain the appropriate operators. These products should of the productBaseClass class. Can not be null (otherwise IllegalArgumentException would appear).
scope - the scope where do we need to find the implementation. In the case this is null - the default value for scope would be used (would be taken from factory object)
Returns:
the mapping between the products objects (all of them were provided as the members of the productObjs list) and the appropriate operators.
Throws:
JPConfigException - in the case we can not retrieve the implementation for some reasons


Copyright © 2007 jzmicer.team. All Rights Reserved.