public class LocalContext extends Context
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.
... // Operations performed using local settings.
} 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| Modifier and Type | Class | Description |
|---|---|---|
static class |
LocalContext.Reference<T> |
This class represents a reference whose setting is local to the current
LocalContext. |
| Constructor | Description |
|---|---|
LocalContext() |
Default constructor.
|
| Modifier and Type | Method | Description |
|---|---|---|
static void |
enter() |
Enters a
LocalContext possibly recycled. |
protected void |
enterAction() |
The action to be performed after this context becomes the current
context.
|
static void |
exit() |
Exits the current local context.
|
protected void |
exitAction() |
The action to be performed before this context is no more the current
context.
|
enter, enter, exit, exit, getCurrentContext, getOuter, getOwner, setConcurrentContext, toStringpublic static void enter()
LocalContext possibly recycled.public static void exit()
java.lang.ClassCastException - if the context is not a local context.protected void enterAction()
ContextenterAction in class Contextprotected void exitAction()
ContextexitAction in class ContextCopyright © 2005 - 2009 Javolution.