T
- The expected type produced by the factory.ID
- The type of the ID being used.@FunctionalInterface public interface LookupFactory<T,ID>
LookupFactory
defines the functionality which must be
provided in order to represent a factory for object creation of objects
identified by an ID 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
LookupFactory
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 instance are generated. It mainly just needs to
know how to use the LookupFactory
. 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
LookupFactory
may return singletons or dedicated separate
instances when queried for instances.
Modifier and Type | Method and Description |
---|---|
T |
toInstance(ID aIdentifier)
This method creates / retrieves an instance of the configured type
identified with the given identifier (name).
|
default T |
toInstance(ID aIdentifier,
org.refcodes.collection.Properties aProperties)
This method creates / retrieves an instance of the configured type
identified with the given identifier (name).
|
T toInstance(ID aIdentifier)
aIdentifier
- The name identifying the instance to be created /
retrieved.default T toInstance(ID aIdentifier, org.refcodes.collection.Properties aProperties)
aIdentifier
- The name identifying the instance to be created /
retrieved.aProperties
- The dynamic properties which are used to configure the
desired bean.Copyright © 2017. All rights reserved.