com.googlecode.sarasvati.hib
Class HibEngine

java.lang.Object
  extended by com.googlecode.sarasvati.impl.BaseEngine
      extended by com.googlecode.sarasvati.hib.HibEngine
All Implemented Interfaces:
Engine

public class HibEngine
extends BaseEngine


Constructor Summary
HibEngine()
          This constructor can be used in cases when the session will be set in later or when performing operations that don't require a session, such as adding global execution listeners.
HibEngine(org.hibernate.Session session)
          Creates a new HibEngine with the default application context.
HibEngine(String applicationContext)
          This constructor can be used in cases when the session will be set in later or when performing operations that don't require a session, such as adding global execution listeners.
HibEngine(String applicationContext, org.hibernate.Session session)
          Creates a new HibEngine with the given application context.
 
Method Summary
 void addExecutionListener(GraphProcess process, Class<? extends ExecutionListener> listenerClass, ExecutionEventType... eventTypes)
          Adds a listener for the given event types for the given process.
static void addToConfiguration(org.hibernate.cfg.AnnotationConfiguration config, boolean enableCaching)
           
 List<ArcToken> getActiveArcTokens(HibTokenSet tokenSet)
           
 List<NodeToken> getActiveNodeTokens(HibTokenSet tokenSet)
           
 HibGraphFactory getFactory()
          Returns an appropriate GraphFactory for this Engine.
 GraphLoader<HibGraph> getLoader()
          Returns an appropriate GraphLoader for this Engine.
 GraphLoader<HibGraph> getLoader(GraphValidator validator)
          Returns an appropriate GraphLoader for this Engine.
 HibGraphRepository getRepository()
          Returns an appropriate GraphRepository for this Engine.
 org.hibernate.Session getSession()
           
 HibEngine newEngine()
          Creates a new engine base on the same parameters as this.
 void removeExecutionListener(GraphProcess process, Class<? extends ExecutionListener> listenerClass, ExecutionEventType... eventTypes)
          Will remove the listener from the given proces.
 void setSession(org.hibernate.Session session)
           
 
Methods inherited from class com.googlecode.sarasvati.impl.BaseEngine
addExecutionListener, addGlobalCustomNodeType, addNodeType, backtrack, cancelProcess, complete, completeAsynchronous, completeWithNewTokenSet, evaluateGuard, executeQueuedArcTokens, finalizeCancel, finalizeComplete, fireEvent, getParentEngine, newEngine, newJoinLangEnv, newRubricEnv, removeExecutionListener, setupScriptEnv, startProcess, startProcess, startProcess
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HibEngine

public HibEngine()
This constructor can be used in cases when the session will be set in later or when performing operations that don't require a session, such as adding global execution listeners. The HibEngine is created with the default application context.

Each application context has it's own set of global listeners. This allows different applications running the same JVM to have different sets of listeners without having to add them at the process level.


HibEngine

public HibEngine(String applicationContext)
This constructor can be used in cases when the session will be set in later or when performing operations that don't require a session, such as adding global execution listeners. The HibEngine is created with the given application context.

Each application context has it's own set of global listeners. This allows different applications running the same JVM to have different sets of listeners without having to add them at the process level.


HibEngine

public HibEngine(org.hibernate.Session session)
Creates a new HibEngine with the default application context.

Each application context has it's own set of global listeners. This allows different applications running the same JVM to have different sets of listeners without having to add them at the process level.

Parameters:
session - The hibernate session.

HibEngine

public HibEngine(String applicationContext,
                 org.hibernate.Session session)
Creates a new HibEngine with the given application context.

Each application context has it's own set of global listeners. This allows different applications running the same JVM to have different sets of listeners without having to add them at the process level.

Parameters:
session - The hibernate session.
Method Detail

getSession

public org.hibernate.Session getSession()

setSession

public void setSession(org.hibernate.Session session)

getRepository

public HibGraphRepository getRepository()
Description copied from interface: Engine
Returns an appropriate GraphRepository for this Engine. Subclasses may override this to provide custom behavior.

Returns:
An appropriate GraphRepository for this Engine

getFactory

public HibGraphFactory getFactory()
Description copied from interface: Engine
Returns an appropriate GraphFactory for this Engine. Subclasses may override this provide customer behavior.

Returns:
A GraphFactory which will generate the appropriate types for this Engine.

getLoader

public GraphLoader<HibGraph> getLoader()
Description copied from interface: Engine
Returns an appropriate GraphLoader for this Engine. Subclasses may override this provide customer behavior.

Equivalent to getLoader( null )

Returns:
A GraphLoader which, by default, will use the factory and repository from this engine.

getLoader

public GraphLoader<HibGraph> getLoader(GraphValidator validator)
Description copied from interface: Engine
Returns an appropriate GraphLoader for this Engine. Subclasses may override this provide customer behavior.

Returns:
A GraphLoader which, by default, will use the factory and repository from this engine.

addExecutionListener

public void addExecutionListener(GraphProcess process,
                                 Class<? extends ExecutionListener> listenerClass,
                                 ExecutionEventType... eventTypes)
Description copied from interface: Engine
Adds a listener for the given event types for the given process.
ExecutionListener Execution listeners must be thread safe. Because listeners are specified by type, they must have a default constructor and be instantiatable by a call to listenerClass.newInstance().
Process level execution listeners are specified by class because they may be stored in the database as class names. This is so they can be reinstantiated after a JVM restart.

Specified by:
addExecutionListener in interface Engine
Overrides:
addExecutionListener in class BaseEngine
Parameters:
process - The process to add the listener for, or null for all processes
listenerClass - The listener type to be added.
eventTypes - The event types to be notified for. If no listener types are specified, the listener is added for all event types.

removeExecutionListener

public void removeExecutionListener(GraphProcess process,
                                    Class<? extends ExecutionListener> listenerClass,
                                    ExecutionEventType... eventTypes)
Description copied from interface: Engine
Will remove the listener from the given proces. If no event types are specified, the listener will be removed for all event types. Otherwise it will be removed for only the specified event types.
The listener doesn't need to match exactly. All listeners of this type will be matched. What matches types is determined by the implementation, but usually it means same class.

Specified by:
removeExecutionListener in interface Engine
Overrides:
removeExecutionListener in class BaseEngine
Parameters:
process - The process to remove the listener from, or null to remove from the global listener set
listenerClass - The type of listener to remove
eventTypes - The set of event types to remove the listener for, or none to remove for all

newEngine

public HibEngine newEngine()
Description copied from class: BaseEngine
Creates a new engine base on the same parameters as this. For example, if the engine is database backed, it should share the same database engine.

Returns:
A new engine

getActiveArcTokens

public List<ArcToken> getActiveArcTokens(HibTokenSet tokenSet)

getActiveNodeTokens

public List<NodeToken> getActiveNodeTokens(HibTokenSet tokenSet)

addToConfiguration

public static void addToConfiguration(org.hibernate.cfg.AnnotationConfiguration config,
                                      boolean enableCaching)