com.werken.blissed
Class ProcessEngine

java.lang.Object
  |
  +--com.werken.blissed.ProcessEngine
All Implemented Interfaces:
java.lang.Runnable

public class ProcessEngine
extends java.lang.Object
implements java.lang.Runnable

Process controller engine.

Version:
$Id: ProcessEngine.java,v 1.11 2002/09/18 17:59:57 bob Exp $
Author:
bob mcwhirter

Constructor Summary
ProcessEngine()
          Construct.
 
Method Summary
 void call(Process process, ProcessContext context)
          Call another Process from another instance.
 boolean checkTransitions(ProcessContext context)
          Check a ProcessContext for progress possibilities.
protected  void enterState(State state, ProcessContext context)
          Enter a State for a particular ProcessContext.
protected  void exitState(State state, ProcessContext context)
          Exit a State for a particular ProcessContext.
protected  void finishProcess(Process process, ProcessContext context)
          Finish a Process for a particular ProcessContext.
protected  void followTransition(ProcessContext context, Transition transition)
          Cause a ProcessContext to follow a passing Transition.
 int getThreads()
          Retrieve the number of service threads.
 boolean hasContextToService()
          Determine if this engine has a ProcessContext waiting in the queue.
 boolean isStarted()
          Determine if this ProcessEngine is started.
 void run()
          Run the service thread loop.
 void setThreads(int numThreads)
          Set the number of service threads.
 ProcessContext spawn(Process process)
          Spawn an instance of a Process.
 ProcessContext spawn(Process process, boolean async)
          Spawn an instance of a Process.
 ProcessContext spawn(Process process, ProcessContext parent)
          Spawn an instance of a Process as a child of another instance.
 void start()
          Start the service threads.
protected  void startProcess(Process process, ProcessContext context)
          Begin a Process for a particular ProcessContext.
 void stop()
          Stop the service threads.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ProcessEngine

public ProcessEngine()
Construct.
Method Detail

setThreads

public void setThreads(int numThreads)
Set the number of service threads.
Parameters:
numThreads - Number of service threads.

getThreads

public int getThreads()
Retrieve the number of service threads.
Returns:
The number of service threads.

start

public void start()
Start the service threads.

stop

public void stop()
          throws java.lang.InterruptedException
Stop the service threads.
Throws:
java.lang.InterruptedException - If the calling thread is interrupted while waiting for service threads to terminate.

isStarted

public boolean isStarted()
Determine if this ProcessEngine is started.
Returns:
true if this process engine is started and servicing the queue, otherwise false.

run

public void run()
Run the service thread loop.
Specified by:
run in interface java.lang.Runnable

hasContextToService

public boolean hasContextToService()
Determine if this engine has a ProcessContext waiting in the queue.
Returns:
true if a process context is available for servicing, otherwise false.

spawn

public ProcessContext spawn(Process process)
                     throws ActivityException,
                            InvalidMotionException
Spawn an instance of a Process.
Parameters:
process - The process to spawn.
Returns:
The ProcessContext representing the instance of the newly spawned process.
Throws:
ActivityException - If an activity causes an error.
InvalidMotionException - If a motion error occurs while attempting to spawn the process.

spawn

public ProcessContext spawn(Process process,
                            boolean async)
                     throws ActivityException,
                            InvalidMotionException
Spawn an instance of a Process.
Parameters:
process - The process to spawn.
async - Flag indicating if processing of context should occur asynchronously, or if it should use the calling thread for motion.
Returns:
The ProcessContext representing the instance of the newly spawned process.
Throws:
ActivityException - If an activity causes an error.
InvalidMotionException - If a motion error occurs while attempting to spawn the process.

spawn

public ProcessContext spawn(Process process,
                            ProcessContext parent)
                     throws ActivityException,
                            InvalidMotionException
Spawn an instance of a Process as a child of another instance.
Parameters:
process - The process to spawn.
parent - The parent context.
Returns:
The ProcessContext representing the instance of the newly spawned process.
Throws:
ActivityException - If an activity causes an error.
InvalidMotionException - If a motion error occurs while attempting to spawn the process.

call

public void call(Process process,
                 ProcessContext context)
          throws ActivityException,
                 InvalidMotionException
Call another Process from another instance.
Parameters:
process - The process to call.
context - The process context.
Throws:
ActivityException - If an activity causes an error.
InvalidMotionException - If a motion error occurs while attempting to spawn the process.

startProcess

protected void startProcess(Process process,
                            ProcessContext context)
                     throws ActivityException,
                            InvalidMotionException
Begin a Process for a particular ProcessContext.
Parameters:
process - The process to start.
context - The process context.
Throws:
ActivityException - If an activity causes an error.
InvalidMotionException - If a motion error occurs while attempting to begin a process.

enterState

protected void enterState(State state,
                          ProcessContext context)
                   throws ActivityException,
                          InvalidMotionException
Enter a State for a particular ProcessContext.
Parameters:
state - The state to enter.
context - The process context.
Throws:
ActivityException - If an activity causes an error.
InvalidMotionException - If a motion error occurs while attempting to enter a state.

exitState

protected void exitState(State state,
                         ProcessContext context)
                  throws InvalidMotionException
Exit a State for a particular ProcessContext.
Parameters:
state - The state to exit.
context - The process context.
Throws:
InvalidMotionException - If a motion error occurs while attempting to exit a state.

finishProcess

protected void finishProcess(Process process,
                             ProcessContext context)
                      throws InvalidMotionException
Finish a Process for a particular ProcessContext.
Parameters:
process - The process to finish.
context - The process context.
Throws:
InvalidMotionException - If a motion error occurs while attempting to finish a process.

checkTransitions

public boolean checkTransitions(ProcessContext context)
                         throws ActivityException,
                                InvalidMotionException
Check a ProcessContext for progress possibilities.
Parameters:
context - The context to check.
Returns:
true if the ProcessContext performed motion, otherwise false.
Throws:
ActivityException - If an activity causes an error.
InvalidMotionException - If the transitions of the context attempt an invalid motion.

followTransition

protected void followTransition(ProcessContext context,
                                Transition transition)
                         throws ActivityException,
                                InvalidMotionException
Cause a ProcessContext to follow a passing Transition.
Parameters:
context - The process context.
transition - The passing transition.
Throws:
ActivityException - If an activity causes an error.
InvalidMotionException - If the process context may not transition.


Copyright © 2002-2002 The Werken Company. All Rights Reserved.