Class Scopelet<S extends Scopelet<S>>
java.lang.Object
org.microbean.scopelet.Scopelet<S>
- Type Parameters:
S- theScopeletsubtype extending this class
- All Implemented Interfaces:
AutoCloseable,Constable,Aggregate,Factory<S>
- Direct Known Subclasses:
MapBackedScopelet,NoneScopelet
public abstract class Scopelet<S extends Scopelet<S>>
extends Object
implements AutoCloseable, Factory<S>
A manager of object lifespans on behalf of one or more notional scopes.
- Author:
- Laird Nelson
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final AttributesAnAttributesidentifying the (well-known and normal) application scope.static final AttributesAnAttributesidentifying the (well-known) none pseudo-scope.static final AttributesAnAttributesidentifying the scope designator.static final AttributesAnAttributesidentifying the (well-known) singleton pseudo-scope.Fields inherited from interface org.microbean.bean.Aggregate
EMPTY_ASSIGNMENTS, EMPTY_DEPENDENCIES -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanactive()Returnstrueif and only if thisScopeletis active at the moment of the call.voidclose()protected final booleanclosed()Returnstrueif and only if at the moment of invocation thisScopeletis (irrevocably) closed (and therefore also not active).final SCreates thisScopeletby simply returning it.final booleandestroys()abstract <I> Ibooleanfinal SReturns thisScopeletif it has been created via thecreate(Creation)method, ornullif that method has not yet been invoked.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.microbean.bean.Aggregate
assign, dependenciesMethods inherited from interface org.microbean.bean.Factory
describeConstable, destroy
-
Field Details
-
SCOPE
AnAttributesidentifying the scope designator. -
SINGLETON_ID
AnAttributesidentifying the (well-known) singleton pseudo-scope.The
Attributesconstituting the singleton pseudo-scope identifier is attributed with the scope designator, the qualifier designator, and the primordial qualifier, indicating that the scope it identifies governs itself. -
APPLICATION_ID
AnAttributesidentifying the (well-known and normal) application scope. -
NONE_ID
AnAttributesidentifying the (well-known) none pseudo-scope.
-
-
Constructor Details
-
Scopelet
-
-
Method Details
-
create
-
singleton
-
destroys
-
active
-
instance
Checks to see if thisScopeletis active and then returns a pre-existing or created-on-demand contextual instance suitable for the combination of identifier,FactoryandCreation, ornull- Type Parameters:
I- the type of contextual instance- Parameters:
id- an identifier that can identify a contextual instance; may benullfactory- aFactory; may benullcreation- aCreation, typically the one in effect that is causing this method to be invoked in the first place; may benull- Returns:
- a contextual instance, possibly pre-existing, or possibly created just in time, or
null - Throws:
InactiveScopeletException- if thisScopeletis not activeClassCastException- ifcreationis non-nulland does not implementDestruction, a requirement of its contract- See Also:
-
remove
Checks to see if thisScopeletis active and then removes any contextual instance stored under the suppliedid, returningtrueif and only if removal actually took place.The default implementation of this method always returns
false. Subclasses are encouraged to override it as appropriate.- Parameters:
id- an identifier; may benull- Returns:
trueif and only if removal actually occurred- Throws:
InactiveScopeletException- if thisScopeletis not active
-
close
Irrevocably closes thisScopelet, and, by doing so, notionally makes it irrevocably closed and inactive.Overrides of this method must call
super.close()as part of their implementation or undefined behavior may result.- Specified by:
closein interfaceAutoCloseable- See Also:
-
closed
Returnstrueif and only if at the moment of invocation thisScopeletis (irrevocably) closed (and therefore also not active).- Returns:
trueif and only if at the moment of invocation thisScopeletis (irrevocably) closed (and therefore also not active)- See Also:
-