Atavism Version 2018.1AGIS API

atavism.server.engine
Class PersistenceManager

java.lang.Object
  extended by java.lang.Thread
      extended by atavism.server.engine.PersistenceManager
All Implemented Interfaces:
java.lang.Runnable

public class PersistenceManager
extends java.lang.Thread

For use by EnginePlugins, handles periodically saving objects using the object persistence plugin. You must call start() for this to begin its save loop, this is usually done via the EnginePlugin startPersistenceManager() method. You add dirty entities to the PersistenceManager, and it will save it to the database when it goes through its list. You can add dirty entities more than once, it will ignore subsequent calls.

The PersistenceManager gets the database object from Engine.getDatabase()

See Also:
EnginePlugin

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
PersistenceManager()
           
 
Method Summary
 void callSaveHooks(Entity e)
           
 void clearDirty(Entity entity)
          Remove entity from the dirty list.
 boolean isDirty(Entity entity)
          True if the entity is on the dirty list.
 void persistEntity(Entity e)
           
 void persistEntity(java.lang.String persistenceKey, Entity e)
           
 void registerSaveHook(Namespace namespace, EnginePlugin.SaveHook saveHook)
          Register a save hook.
 void run()
           
 void setDirty(Entity entity)
          Add entity to the dirty list.
 void start()
           
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PersistenceManager

public PersistenceManager()
Method Detail

registerSaveHook

public void registerSaveHook(Namespace namespace,
                             EnginePlugin.SaveHook saveHook)
Register a save hook.

Parameters:
saveHook - the hook to be used when your sub object is marked dirty and needs to be saved. it should handle deep copy if needed. this will be called by the persistenceManager when it wants to save the object. if saveHook is null, it will use the default handler which does not do a deep copy

setDirty

public void setDirty(Entity entity)
Add entity to the dirty list. The entity will be saved during the next "save object" cycle. setDirty() will start the persistence manager on first use.


clearDirty

public void clearDirty(Entity entity)
Remove entity from the dirty list.


isDirty

public boolean isDirty(Entity entity)
True if the entity is on the dirty list.


start

public void start()
Overrides:
start in class java.lang.Thread

run

public void run()
Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread

persistEntity

public void persistEntity(java.lang.String persistenceKey,
                          Entity e)

persistEntity

public void persistEntity(Entity e)

callSaveHooks

public void callSaveHooks(Entity e)


Copyright © 2018 Dragonsan Studios Sp. z o.o.