public abstract class AbstractDelegatingFactory<SCOPE> extends Object implements Factory
ServiceProducer
annotation, whose return type is assignable from
the class requested in the getObject(String,Class)
method. NOTE: It does not require an
exact match of the return type, only that it is assignable. Subclasses should not declare
ambiguous ServiceProducer
methods (without specifying a unique name
) in the
annotation, or else users may be surprised by which object is returned.
It is possible to differentiate between two objects that are of the same type (or supertype) by using
the name
attribute on the ServiceProducer
annotation. If provided, the name
of the producer takes precedence over unnamed producer methods.
If an object created in this factory is flagged as cached (using the cache
attribute of
the ServiceProducer
annotation, the object will be cached against the name
(if provided,
or else the simple name of the requested type will be used) for the lifetime of this factory.Modifier | Constructor and Description |
---|---|
protected |
AbstractDelegatingFactory(SCOPE scope,
Factory delegate) |
Modifier and Type | Method and Description |
---|---|
<T> T |
getObject(String name,
Class<T> fieldType)
Return an object with the type specified.
|
String |
toString() |
public final <T> T getObject(String name, Class<T> fieldType)
Factory
getObject
in interface Factory
T
- the type of the object to returnname
- the name used to identify the variant of the class
to be returned. If no name is specified, then the
class name of the type specified is assumed.fieldType
- the type of the oblject to returnCopyright © 2010–2017. All rights reserved.