Overview | Package | Class | Tree | Deprecated | Index | Help
| J avolution v5.2 (J2SE 1.5+)
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## javolution.context
Class LocalContext

    java.lang.Object
      javolution.context.Context
          javolution.context.LocalContext

All Implemented Interfaces:
  java.io.Serializable, XMLSerializable

    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.

Version:
  3.6, September 24, 2005
Author:
  Jean-Marie Dautelle
See Also:
  `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

### LocalContext

    public LocalContext()

  Default constructor.

Method Detail

### enter

    public static LocalContext enter()

  Enters a `LocalContext` possibly recycled.

  Returns:
    the local context being entered.

### exit

    public static LocalContext exit()

  Exits the current local context.

  Returns:
    the local context being exited.
  Throws:
    `java.lang.ClassCastException` - if the context is not a local context.

### enterAction

    protected void enterAction()

  Description copied from class: `Context`
  The action to be performed after this context becomes the current context.

  Specified by:
    `enterAction` in class `Context`

### exitAction

    protected void exitAction()

  Description copied from class: `Context`
  The action to be performed before this context is no more the current context.

  Specified by:
    `exitAction` in class `Context`

Overview | Package | Class | Tree | Deprecated | Index | Help
| J avolution v5.2 (J2SE 1.5+)
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2005 - 2007 Javolution.