T
- The type of the instances being served by the factory.@FunctionalInterface public interface TypeFactory<T>
TypeFactory
defines the functionality which must be provided in
order to represent a factory for object creation 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 TypeFactory
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 TypeFactory
. 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
TypeFactory
may return singletons or dedicated separate instances
when queried for instances.
Modifier and Type | Method | Description |
---|---|---|
T |
createInstance() |
This method creates / retrieves an instance of the given type with the
given identifier (name) constructed as defined in one to many
configuration files.
|
default T |
createInstance(Map<String,String> aProperties) |
This method creates / retrieves an instance of the given type with the
given identifier (name) constructed as defined in one to many
configuration files.
|
T createInstance()
ClassCastException
- in case the fabricated type is not type
compatible with the required type T.default T createInstance(Map<String,String> aProperties)
aProperties
- The dynamic properties which are used to configure the
desired bean.ClassCastException
- in case the fabricated type is not type
compatible with the required type T.Copyright © 2018. All rights reserved.