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 PersistentContext

    java.lang.Object
      javolution.context.Context
          javolution.context.PersistentContext

All Implemented Interfaces:
  java.io.Serializable, XMLSerializable

    public class PersistentContext

extends Context

This class represents a context persistent accross multiple program executions. It is typically used to hold `persistent references`.

How this context is loaded/saved is application specific. Although, the simplest way is to use Javolution XML serialization facility. For example:``

          import javolution.xml.XMLObjectReader;
          import javolution.xml.XMLObjectWriter;
          public void main(String[]) {
               // Loads persistent context (typically at start-up).
               XMLObjectReader reader = XMLObjectReader.newInstance(new FileInputStream("C:/persistent.xml"));
               PersistentContext.setCurrent(reader.read(PersistentContext.class));
               ...
               ...
               // Saves persistent context for future execution.
               XMLObjectWriter writer = XMLObjectWriter.newInstance(new FileOutputStream("C:/persistent.xml"));
               writer.write(PersistentContext.getCurrent(), PersistentContext.class);
          }

Version:
  4.2, December 31, 2006
Author:
  Jean-Marie Dautelle
See Also:
  Serialized Form

Nested Class Summary
`static class` | `PersistentContext.Reference<T>` This class represents a reference over an object which can be kept persistent accross multiple program executions.

Field Summary

Fields inherited from class javolution.context.Context
`ROOT`

Constructor Summary
`PersistentContext()` Default constructor.

Method Summary
`protected void` | `enterAction()` Throws `UnsupportedOperationException` persistent context are global to all threads (singleton).
`protected void` | `exitAction()` Throws `UnsupportedOperationException` persistent context are global to all threads (singleton).
`static PersistentContext` | `getCurrent()` Returns the persistent context instance (singleton).
`java.util.Map<java.lang.String,java.lang.Object>` | `getIdToValue()` Returns the ID to value mapping for this persistent context.
`static void` | `setCurrent(PersistentContext ctx)` Sets the persistent instance.

Methods inherited from class javolution.context.Context
`enter, enter, exit, exit, getOuter, getOwner, setCurrent, toString`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Constructor Detail

### PersistentContext

    public PersistentContext()

  Default constructor.

Method Detail

### setCurrent

    public static void setCurrent(PersistentContext ctx)

  Sets the persistent instance.

  Parameters:
    `ctx` - the persistent instance.

### getCurrent

    public static PersistentContext getCurrent()

  Returns the persistent context instance (singleton).

  Returns:
    the persistent context instance.

### getIdToValue

    public java.util.Map<java.lang.String,java.lang.Object> getIdToValue()

  Returns the ID to value mapping for this persistent context.

  Returns:
    the persistent value indexed by identifiers.

### enterAction

    protected void enterAction()

  Throws `UnsupportedOperationException` persistent context are global to all threads (singleton).

  Specified by:
    `enterAction` in class `Context`

### exitAction

    protected void exitAction()

  Throws `UnsupportedOperationException` persistent context are global to all threads (singleton).

  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.