Class Request<I,R>
java.lang.Object
org.microbean.reference.Request<I,R>
- Type Parameters:
I- the contextual instance type being instantiated (see for exampleCreation)R- the contextual reference type being sought (seeReferences)
- All Implemented Interfaces:
AutoCloseable,Iterable<R>,Creation<I>,Destruction,References<R>,ReferencesSelector,DestructorRegistry
public final class Request<I,R>
extends Object
implements Creation<I>, Destruction, DestructorRegistry, References<R>
A central object representing a request for dependencies that is a
Creation (and therefore also a Destruction), a DestructorRegistry, and a References.
Instances of this class are the heart and soul of a dependency injection and acquisition system.
- Author:
- Laird Nelson
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.microbean.reference.DestructorRegistry
DestructorRegistry.Destructor -
Constructor Summary
ConstructorsConstructorDescriptionRequest(Domain d, org.microbean.assign.Selectable<? super org.microbean.assign.AttributedType, Bean<?>> s, Instances instances, ClientProxier cp) Creates a newRequest.Request(Domain d, org.microbean.assign.Selectable<? super org.microbean.assign.AttributedType, Bean<?>> s, Instances instances, DestructorTree destructorTree, ClientProxier cp) Creates a newRequest. -
Method Summary
Modifier and TypeMethodDescriptionfinal voidclose()final booleanfinal Domaindomain()final Idid()iterator()final <R> Rfinal <X> References<X> references(org.microbean.assign.AttributedType rType) final booleanregister(Object reference, DestructorRegistry.Destructor destructor) Registers the supplied contextual instance such that at some future moment, or perhaps not at all, the suppliedDestructorRegistry.Destructorwill be run to destroy it idempotently, and returnstrueif and only if the registration was successful.final intsize()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliteratorMethods inherited from interface org.microbean.bean.References
getMethods inherited from interface org.microbean.bean.ReferencesSelector
reference
-
Constructor Details
-
Request
public Request(Domain d, org.microbean.assign.Selectable<? super org.microbean.assign.AttributedType, Bean<?>> s, Instances instances, ClientProxier cp) Creates a newRequest.- Parameters:
d- aDomain; must not benulls- aSelectableproviding access toBeans byAttributedType; must not benull; must be safe for concurrent use by multiple threads; often assembled out of methods present in theSelectablesandBeansclasses, among other such utility classesinstances- anInstancesresponsible for using aBeanto acquire an appropriateSupplierof contextual instances; must not benullcp- aClientProxier; must not benull- Throws:
NullPointerException- if any argument isnull- See Also:
-
Request
public Request(Domain d, org.microbean.assign.Selectable<? super org.microbean.assign.AttributedType, Bean<?>> s, Instances instances, DestructorTree destructorTree, ClientProxier cp) Creates a newRequest.- Parameters:
d- aDomain; must not benulls- aSelectableproviding access toBeans byAttributedType; must not benull; must be safe for concurrent use by multiple threads; often assembled out of methods present in theSelectablesandBeansclasses, among other such utility classesinstances- anInstancesresponsible for using aBeanto acquire an appropriateSupplierof contextual instances; must not benulldestructorTree- aDestructorTree; may benullin which case a default implementation will be used insteadcp- aClientProxier; must not benull- Throws:
NullPointerException- ifs,instances, orcpisnull
-
-
Method Details
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceDestruction
-
destroy
- Specified by:
destroyin interfaceReferencesSelector
-
domain
- Specified by:
domainin interfaceReferencesSelector
-
id
-
iterator
-
reference
- Specified by:
referencein interfaceReferencesSelector
-
references
- Specified by:
referencesin interfaceReferencesSelector
-
register
Description copied from interface:DestructorRegistryRegisters the supplied contextual instance such that at some future moment, or perhaps not at all, the suppliedDestructorRegistry.Destructorwill be run to destroy it idempotently, and returnstrueif and only if the registration was successful.- Specified by:
registerin interfaceDestructorRegistry- Parameters:
reference- a contextual instance; may benullin which case no action will be taken andfalsewill be returneddestructor- aDestructorRegistry.Destructor; may benullin which case no action will be taken andfalsewill be returned- Returns:
trueif and only if registration was successful;falseotherwise- See Also:
-
size
- Specified by:
sizein interfaceReferences<I>
-