|
J avolution v3.7 (J2SE 1.5+) | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjavolution.realtime.Context
javolution.realtime.LocalContext
public class LocalContext
This class represents a local context; it is used to define locally
scoped setting through the use of LocalReference typically
wrapped within a static method. For example:
LocalContext.enter();
try {
LargeInteger.setModulus(m); // Performs integer operations modulo m.
Length.showAs(NonSI.INCH); // Shows length in inches.
RelativisticModel.select(); // Uses relativistic physical model.
QuantityFormat.getInstance(); // Returns local format for quantities.
XmlFormat.setFormat(Foo.class, myFormat); // Uses myFormat for instances of Foo.
} 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).
Finally, local settings are inherited by concurrent threads spawned while in a local context scope.
LocalMap| Constructor Summary | |
|---|---|
LocalContext()
Default constructor. |
|
| Method Summary | |
|---|---|
void |
clear()
Removes all local settings for this context. |
static LocalContext |
current()
Returns the current local context or null |
static void |
enter()
Enters a LocalContext. |
protected void |
enterAction()
The action to be performed after this context becomes the current context. |
static void |
exit()
Exits the current LocalContext. |
protected void |
exitAction()
The action to be performed before this context is no more the current context. |
| Methods inherited from class javolution.realtime.Context |
|---|
enter, enter, exit, exit, getOuter, getOwner |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public LocalContext()
| Method Detail |
|---|
public static LocalContext current()
null if the current
thread does not execute within a local context (global context).
- Returns:
- the current local context.
public static void enter()
LocalContext.
public static void exit()
LocalContext.
java.lang.IllegalStateException - if the current context
is not an instance of LocalContext.public void clear()
clear in class Contextprotected void enterAction()
Context
enterAction in class Contextprotected void exitAction()
Context
exitAction in class Context
|
J avolution v3.7 (J2SE 1.5+) | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||