Class InterceptingProducer<I>
java.lang.Object
org.microbean.producer.InterceptingProducer<I>
-
Field Summary
Fields inherited from interface org.microbean.bean.Aggregate
EMPTY_ASSIGNMENTS, EMPTY_DEPENDENCIES
-
Constructor Summary
ConstructorsConstructorDescriptionInterceptingProducer
(Domain domain, Producer<I> delegate, InterceptionProxier proxier) Creates a newInterceptingProducer
. -
Method Summary
Modifier and TypeMethodDescriptionSequencedSet
<? extends Assignment<?>> assign
(Function<? super AttributedType, ?> f) final SequencedSet
<AttributedElement> A convenience method that returns an immutable, determinateSequencedSet
ofAttributedElement
s consisting of thisProducer
's production dependencies followed by its initialization dependencies.final void
dispose
(I i, Destruction d) Disposes of the supplied contextual instance.Returns an immutable, determinateSequencedSet
ofAttributedElement
s representing dependencies required for initialization.final I
Produces a new contextual instance and returns it by calling theProducer.produce(Id, SequencedSet)
method with the return value of an invocation of theAggregate.assign(Function)
method with a reference to the suppliedCreation
'sreference(AttributedType)
method.produce
(Id id, SequencedSet<? extends Assignment<?>> assignments) Produces a new contextual instance and returns it, possibly (often) making use of the supplied assignments.Returns an immutable, determinateSequencedSet
ofAttributedElement
s representing dependencies required for production.
-
Constructor Details
-
InterceptingProducer
Creates a newInterceptingProducer
.- Parameters:
domain
- aDomain
; must not benull
delegate
- aProducer
to which ultimate production will be delegated; must not benull
proxier
- anInterceptionProxier
; must not benull
- Throws:
NullPointerException
- if any argument isnull
-
-
Method Details
-
dependencies
Description copied from interface:Producer
A convenience method that returns an immutable, determinateSequencedSet
ofAttributedElement
s consisting of thisProducer
's production dependencies followed by its initialization dependencies.There is normally no need to override the default implementation of this method.
- Specified by:
dependencies
in interfaceAggregate
- Specified by:
dependencies
in interfaceProducer<I>
- Returns:
- a non-
null
, immutable, determinateSequencedSet
ofAttributedElement
s consisting of thisProducer
's production dependencies followed by its initialization dependencies - See Also:
-
dispose
Description copied from interface:Producer
Disposes of the supplied contextual instance.The default implementation of this method checks to see if
i
is an instance ofAutoCloseable
, and, if so, callsclose()
on it, throwing any resulting exception as aDisposalException
. -
produce
Description copied from interface:Producer
Produces a new contextual instance and returns it by calling theProducer.produce(Id, SequencedSet)
method with the return value of an invocation of theAggregate.assign(Function)
method with a reference to the suppliedCreation
'sreference(AttributedType)
method. -
assign
-
initializationDependencies
Description copied from interface:Producer
Returns an immutable, determinateSequencedSet
ofAttributedElement
s representing dependencies required for initialization.Such dependencies may represent initialization method parameters and/or fields.
Contrast initialization dependencies with production dependencies.
- Specified by:
initializationDependencies
in interfaceProducer<I>
- Returns:
- a non-
null
, immutable, determinateSequencedSet
ofAttributedElement
s representing dependencies required for initialization - See Also:
-
produce
Description copied from interface:Producer
Produces a new contextual instance and returns it, possibly (often) making use of the supplied assignments.Implementations of this method must not call
Producer.produce(Creation)
or an infinite loop may result.- Specified by:
produce
in interfaceProducer<I>
- Parameters:
id
- anId
for which production is occurring; must not benull
assignments
- aSequencedSet
ofAssignment
s thisProducer
needs to complete production and possibly initialization; must not benull
- Returns:
- a new contextual instance, or
null
-
productionDependencies
Description copied from interface:Producer
Returns an immutable, determinateSequencedSet
ofAttributedElement
s representing dependencies required for production.Such dependencies normally represent constructor parameters.
Contrast production dependencies with initialization dependencies.
- Specified by:
productionDependencies
in interfaceProducer<I>
- Returns:
- a non-
null
, immutable, determinateSequencedSet
ofAttributedElement
s representing dependencies required for production - See Also:
-