Class InterceptingProducer<I>
java.lang.Object
org.microbean.producer.InterceptingProducer<I>
- Type Parameters:
I- the contextual instance type
- All Implemented Interfaces:
org.microbean.assign.Aggregate, Producer<I>
- Author:
- Laird Nelson
-
Field Summary
Fields inherited from interface org.microbean.assign.Aggregate
EMPTY_ASSIGNMENTS, EMPTY_DEPENDENCIES -
Constructor Summary
ConstructorsConstructorDescriptionInterceptingProducer(Domain domain, Qualifiers qualifiers, Producer<I> delegate, InterceptionProxier proxier) Creates a newInterceptingProducer. -
Method Summary
Modifier and TypeMethodDescriptionSequencedSet<? extends org.microbean.assign.Assignment<?>> final SequencedSet<org.microbean.assign.AttributedElement> A convenience method that returns an immutable, determinateSequencedSetofAttributedElements consisting of thisProducer's production dependencies followed by its initialization dependencies.final voiddispose(I i, Destruction d) Disposes of the supplied contextual instance.SequencedSet<org.microbean.assign.AttributedElement> Returns an immutable, determinateSequencedSetofAttributedElements representing dependencies required for initialization.final IProduces 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 org.microbean.assign.Assignment<?>> assignments) Produces a new contextual instance and returns it, possibly (often) making use of the supplied assignments.SequencedSet<org.microbean.assign.AttributedElement> Returns an immutable, determinateSequencedSetofAttributedElements representing dependencies required for production.
-
Constructor Details
-
InterceptingProducer
public InterceptingProducer(Domain domain, Qualifiers qualifiers, Producer<I> delegate, InterceptionProxier proxier) Creates a newInterceptingProducer.- Parameters:
domain- aDomain; must not benullqualifiers- aQualifiers; must not benulldelegate- aProducerto which ultimate production will be delegated; must not benullproxier- anInterceptionProxier; must not benull- Throws:
NullPointerException- if any argument isnull
-
-
Method Details
-
dependencies
Description copied from interface:ProducerA convenience method that returns an immutable, determinateSequencedSetofAttributedElements 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:
dependenciesin interfaceorg.microbean.assign.Aggregate- Specified by:
dependenciesin interfaceProducer<I>- Returns:
- a non-
null, immutable, determinateSequencedSetofAttributedElements consisting of thisProducer's production dependencies followed by its initialization dependencies - See Also:
-
dispose
Description copied from interface:ProducerDisposes of the supplied contextual instance.The default implementation of this method checks to see if
iis an instance ofAutoCloseable, and, if so, callsclose()on it, throwing any resulting exception as aDisposalException. -
produce
Description copied from interface:ProducerProduces 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.There is normally no need to override the default implementation of this method.
-
assign
public SequencedSet<? extends org.microbean.assign.Assignment<?>> assign(Function<? super org.microbean.assign.AttributedType, ?> f) - Specified by:
assignin interfaceorg.microbean.assign.Aggregate
-
initializationDependencies
Description copied from interface:ProducerReturns an immutable, determinateSequencedSetofAttributedElements representing dependencies required for initialization.Such dependencies may represent initialization method parameters and/or fields.
Contrast initialization dependencies with production dependencies.
- Specified by:
initializationDependenciesin interfaceProducer<I>- Returns:
- a non-
null, immutable, determinateSequencedSetofAttributedElements representing dependencies required for initialization - See Also:
-
produce
Description copied from interface:ProducerProduces 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:
producein interfaceProducer<I>- Parameters:
id- anIdfor which production is occurring; must not benullassignments- aSequencedSetofAssignments thisProducerneeds to complete production and possibly initialization; must not benull- Returns:
- a new contextual instance, or
null
-
productionDependencies
Description copied from interface:ProducerReturns an immutable, determinateSequencedSetofAttributedElements representing dependencies required for production.Such dependencies normally represent constructor parameters.
Contrast production dependencies with initialization dependencies.
- Specified by:
productionDependenciesin interfaceProducer<I>- Returns:
- a non-
null, immutable, determinateSequencedSetofAttributedElements representing dependencies required for production - See Also:
-