|
J avolution v5.2 (J2SE 1.5+) | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjavolution.context.Context
javolution.context.LocalContext
public class LocalContext
This class represents a context to define locally scoped environment
settings. This settings are held by LocalContext.Reference
and typically wrapped within a static method:
LocalContext.enter();
try {
ModuloInteger.setModulus(m); // Performs integer operations modulo m.
Length.showAs(NonSI.INCH); // Shows length in inches.
RelativisticModel.select(); // Uses relativistic physical model.
} finally {
LocalContext.exit(); // Reverts to previous settings.
}
Calls to locally scoped methods should be performed either at start-up (global setting) or within a local context (to avoid impacting other threads).
As for any context, local context settings are inherited during
concurrent executions.
LocalMap,
Serialized Form| Nested Class Summary | |
|---|---|
static class |
LocalContext.Reference<T>
This class represents a reference whose setting is local to the current LocalContext. |
| Field Summary |
|---|
| Fields inherited from class javolution.context.Context |
|---|
ROOT |
| Constructor Summary | |
|---|---|
LocalContext()
Default constructor. |
|
| Method Summary | |
|---|---|
static LocalContext |
enter()
Enters a LocalContext possibly recycled. |
protected void |
enterAction()
The action to be performed after this context becomes the current context. |
static LocalContext |
exit()
Exits the current local context. |
protected void |
exitAction()
The action to be performed before this context is no more the current context. |
| Methods inherited from class javolution.context.Context |
|---|
enter, enter, exit, getCurrent, getOuter, getOwner, setCurrent, toString |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public LocalContext()
| Method Detail |
|---|
public static LocalContext enter()
LocalContext possibly recycled.
public static LocalContext exit()
java.lang.ClassCastException - if the context is not a local context.protected void enterAction()
Context
enterAction in class Contextprotected void exitAction()
Context
exitAction in class Context
|
J avolution v5.2 (J2SE 1.5+) | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||