|
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.PersistentContext
public class PersistentContext
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);
}
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 |
---|
public PersistentContext()
Method Detail |
---|
public static void setCurrent(PersistentContext ctx)
ctx
- the persistent instance.public static PersistentContext getCurrent()
public java.util.Map<java.lang.String,java.lang.Object> getIdToValue()
protected void enterAction()
UnsupportedOperationException
persistent context
are global to all threads (singleton).
enterAction
in class Context
protected void exitAction()
UnsupportedOperationException
persistent context
are global to all threads (singleton).
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 |