|
SPT Object Database API | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.sptci.prevayler.PrevalentSystemFactory
public final class PrevalentSystemFactory
A factory class used to boot-strap PrevalentSystem instances.
This class may be configured using the following JVM system properties:
sptodb.data.dir - The directory under which the database
snapshot and journal files are stored. The default value used if this
property is not specified is /var/data/sptodb.sptodb.snapshot.interval - The interval in seconds at
which snapshots of the prevalent system are to be taken. The default
value used is 86400 (one day).sptodb.serialiser.format - The format to use for taking
snapshots of the prevalent system and creating transaction journals.
The supported options are:
java - Indicates that regular Java object
serialisation be used to take the snapshot and write journals.
This is the default unless otherwise specified.xml - Indicates that the journals should be written
and snapshot taken using
XStream. XML
serialisation is slower (both serialisation and de-serialisation),
however gives you more options processing the prevalent system
for other purposes. Also useful if you need to restore the
system after heavy modifications (refactoring) to the object
model.The following code shows sample usage of this class
import com.sptci.prevayler.PrevalentSystemFactory;
import com.sptci.prevayler.transaction.Save;
...
// MyPrevalentObject is a sub-class of PrevalentObject
final MyPrevalentObject obj1 = new MyPrevalentObject();
obj1.setXXX();
...
final Save<MyPrevalentObject> save = new Save<MyPrevalentObject>( obj1 );
final MyPrevalentObject obj2 = PrevalentSystemFactory.getPrevayler().execute( save );
System.out.format( "MyPrevalentObject created with OID: %s%n", obj2.getObjectId() );
© Copyright 2008 Sans Pareil Technologies, Inc.
| Nested Class Summary | |
|---|---|
private static class |
PrevalentSystemFactory.SnapshotTask
A TimerTask that is used to snapshot the PrevalentSystemFactory.SnapshotTask.prevayler periodically. |
| Field Summary | |
|---|---|
static String |
DATA_DIRECTORY
The system parameter used to configure the prevalent data directory. |
static String |
DEFAULT_DIRECTORY
The default value to use for the prevalent data directory. |
static String |
DEFAULT_SEARCH_BATCH_SIZE
The default value for the SEARCH_BATCH_SIZE property. |
static String |
DEFAULT_SERIALISER_FORMAT
The default value for the SERIALISER_FORMAT property. |
static String |
DEFAULT_SNAPSHOT_INTERVAL
The default snapshot interval to use. |
private static Logger |
logger
The logger to use to log messages. |
static String |
OBJECT_STORAGE
The directory under DATA_DIRECTORY in which the prevalent
objects are stored. |
static String |
SEARCH_BATCH_SIZE
The JVM system property used to specify the size of the batches in which the search index writer is to be committed. |
static String |
SEARCH_STORAGE
The directory under DATA_DIRECTORY under which lucene search
indices are stored. |
static String |
SERIALISER_FORMAT
The JVM system property used to configure the serialisation technique used for snapshots and transaction journals. |
static String |
SNAPSHOT_INTERVAL
The system property used to configure the interval at which a snapshot of the database is taken. |
private static ConcurrentMap<Class,Prevayler> |
systems
A map used to maintain the various prevalent systems maintained by the factory. |
| Constructor Summary | |
|---|---|
private |
PrevalentSystemFactory()
Default constructor. |
| Method Summary | |
|---|---|
protected static String |
getDatabaseDirectory(Class system)
Return the directory under which serialised instances of the specified class are to be stored. |
protected static String |
getDataDirectory()
Return the root directory under which the entire database system is stored. |
static Prevayler |
getPrevayler()
Boot-strap a prevalent system using the default PrevalentSystem
class. |
static Prevayler |
getPrevayler(Class system)
Create a prevalent system for the specified system class. |
static Prevayler |
getPrevayler(Class system,
String directory)
Create a prevalent system for the specified system class. |
static Prevayler |
getPrevayler(Class system,
String directory,
String serialiser)
Create a prevalent system for the specified system class. |
protected static int |
getSearchBatchSize()
Return the size of the batch at which lucene index writer is to be committed. |
protected static String |
getSearchDirectory(Class system)
Return the directory under which the lucene full-text search indices are to be stored. |
private static void |
snapshot(Prevayler prevayler)
Start a timer task for taking snapshots of the prevalent system. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String DATA_DIRECTORY
public static final String DEFAULT_DIRECTORY
public static final String OBJECT_STORAGE
DATA_DIRECTORY in which the prevalent
objects are stored.
"data"
public static final String SEARCH_STORAGE
DATA_DIRECTORY under which lucene search
indices are stored.
"search"
public static final String SNAPSHOT_INTERVAL
public static final String DEFAULT_SNAPSHOT_INTERVAL
public static final String SERIALISER_FORMAT
public static final String DEFAULT_SERIALISER_FORMAT
SERIALISER_FORMAT property. Defaults
to Java serialisation.
"java"
public static final String SEARCH_BATCH_SIZE
public static final String DEFAULT_SEARCH_BATCH_SIZE
SEARCH_BATCH_SIZE property.
"20"
private static final Logger logger
private static final ConcurrentMap<Class,Prevayler> systems
| Constructor Detail |
|---|
private PrevalentSystemFactory()
| Method Detail |
|---|
public static Prevayler getPrevayler()
throws PrevalentException
PrevalentSystem
class.
PrevalentException - If errors are encountered while boot strapping
the prevalent system.getPrevayler( Class )
public static Prevayler getPrevayler(Class system)
throws PrevalentException
system - The class that represents the prevalent system to be
managed.
PrevalentException - If errors are encountered while boot strapping
the prevalent system.getPrevayler( Class, String )
public static Prevayler getPrevayler(Class system,
String directory)
throws PrevalentException
system - The class that represents the prevalent system to be
managed.directory - The directory in which serialised state of the
prevalent system is to be stored. Note that you must specify different
directories if you are using this factory to boot-strap multiple
prevalent system instances.
PrevalentException - If errors are encountered while boot strapping
the prevalent system. Also thrown if the system specified
is not a sub-class of PrevalentSystem.getPrevayler( Class, String, String )
public static Prevayler getPrevayler(Class system,
String directory,
String serialiser)
throws PrevalentException
system - The class that represents the prevalent system to be
managed.directory - The directory in which serialised state of the
prevalent system is to be stored. Note that you must specify different
directories if you are using this factory to boot-strap multiple
prevalent system instances.serialiser - The serialiser to use for the transaction journals and
snapshots. Valid values are java or xml.
PrevalentException - If errors are encountered while boot strapping
the prevalent system. Also thrown if the system specified
is not a sub-class of PrevalentSystem.snapshot(org.prevayler.Prevayler)protected static String getDataDirectory()
DATA_DIRECTORY
as configured or the default value.
protected static String getDatabaseDirectory(Class system)
system - The class whose instances are to be stored.
protected static String getSearchDirectory(Class system)
system - The class whose search index location is to be returned
protected static int getSearchBatchSize()
private static void snapshot(Prevayler prevayler)
prevayler - The prevalent system to snapshot.
|
SPT Object Database API | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||