Interface ContextLookupFactory<T,TID,CTX>

Type Parameters:
T - The expected type produced by the factory.
TID - The type of the TID being used.
CTX - The context which may influence the object being created by this factory.
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface ContextLookupFactory<T,TID,CTX>
The ContextLookupFactory defines the functionality which must be provided in order to represent a factory for object creation of objects identified by an TID String and of a predefined type specified with a generic argument (in contrast to the BeanLookupFactory, which creates instances of an expected type). Many alternative implementations of a ContextLookupFactory may may exist which construct the instances their way.

Having factories that generic as we define it here, we are able to decouple our business logic from any specific framework: Your business logic must not know anything about how the instances are generated. It mainly just needs to know how to use the ContextLookupFactory. It is up to the application "end point", i.e. a command line tool with a main-method or a web-application to finally decide which factory to use.

Depending on the implementation used or configuration provided, the ContextLookupFactory may return singletons or dedicated separate instances when queried for instances.

  • Method Summary

    Modifier and Type
    Method
    Description
    createInstance(TID aIdentifier, CTX aContext)
    This method creates / retrieves an instance of the configured type identified with the given identifier (name).
    default T
    createInstance(TID aIdentifier, CTX aContext, Map<String,String> aProperties)
    This method creates / retrieves an instance of the configured type identified with the given identifier (name).
  • Method Details

    • createInstance

      T createInstance(TID aIdentifier, CTX aContext)
      This method creates / retrieves an instance of the configured type identified with the given identifier (name).
      Parameters:
      aIdentifier - The name identifying the instance to be created / retrieved.
      aContext - The context which may influence the object being created by this factory.
      Returns:
      The instance being fabricated by this factory for the given instance name (identifier).
    • createInstance

      default T createInstance(TID aIdentifier, CTX aContext, Map<String,String> aProperties)
      This method creates / retrieves an instance of the configured type identified with the given identifier (name).
      Parameters:
      aIdentifier - The name identifying the instance to be created / retrieved.
      aContext - The context which may influence the object being created by this factory.
      aProperties - The dynamic properties which are used to configure the desired bean.
      Returns:
      The instance being fabricated by this factory for the given instance name (identifier).
      Throws:
      ClassCastException - in case the fabricated type is not type compatible with the required type T.