Interface Scope
- All Superinterfaces:
AutoCloseable
- All Known Implementing Classes:
AbstractScope
The lifespan of one or more variables.
Child scopes must call parent.addChild(this) at the end of their constructor and
parent.removeChild(this) at the end of their close() method.
Example implementation of the close() method:
public void close()
{
if (!closed.compareAndSet(false, true))
return;
parent.removeChild(this);
children.shutdown(CLOSE_TIMEOUT);
}
-
Method Summary
-
Method Details
-
addChild
Adds a child scope.- Parameters:
child- the child scope- Throws:
NullPointerException- ifchildis nullIllegalStateException- if the scope is closed
-
removeChild
Removes a child scope.- Parameters:
child- the child scope- Throws:
NullPointerException- ifchildis null
-
isClosed
boolean isClosed()Determines if the scope is closed.- Returns:
trueif the scope is closed
-
close
void close()- Specified by:
closein interfaceAutoCloseable
-