| This class represents a context persistent accross multiple program
executions. It is typically used to hold
Reference persistent references .
How this context is loaded/saved is application specific.
Although, the simplest way is to use Javolution XML serialization
facility. For example:[code]
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);
}[/code]
author: Jean-Marie Dautelle version: 4.2, December 31, 2006 |