ThreadedProcessExecutionEngineImpl.java revision 2
/*
* Created on 21.04.2005
*/
/**
* @author Michael Daenzer, University of Zurich
*/
public class ThreadedProcessExecutionEngineImpl extends ProcessExecutionEngineImpl
implements Runnable, ThreadedProcessExecutionEngine {
private static final int DEFAULT_INTERVAL = 5000;
private boolean resultReady = false;
private boolean interrupted = false;
private int interval = DEFAULT_INTERVAL;
private String processName;
/* (non-Javadoc)
* @see java.lang.Runnable#run()
*/
public void run() {
}
/* (non-Javadoc)
* @see org.mindswap.owls.process.execution.ProcessExecutionEngine#execute(org.mindswap.owls.process.Process, org.mindswap.query.ValueMap)
*/
this.process = p;
this.processName = p.getName();
if (this.processName == null)
this.processName = p.getLocalName();
}
// starts a method asynchronously in a separate thread
public void execAsynchronous() {
setResultReady(false);
}
/**
* @see impl.owls.process.execution.ProcessExecutionEngine#createSequence(org.mindswap.owls.process.Sequence)
*/
if (isInterrupted())
}
}
/* (non-Javadoc)
* @see impl.owls.process.execution.ProcessExecutionEngineImpl#executeAnyOrder(org.mindswap.owls.process.AnyOrder)
*/
// AnyOrder says it doesn't matter in which order subelements
// are executed so let's try the sequential order
// FIXME check preconditions to find a correct ordering
if (isInterrupted())
}
}
if(performResult == null)
if (isInterrupted())
}
}
do {
if (isInterrupted())
}
while( isTrue( whileCondition ) );
}
while( isTrue( whileCondition ) ) {
if (isInterrupted())
}
}
return result;
}
if (param.isIndividual()) {
//OWLIndividual ind = (OWLIndividual) param;
//if (ind.isType(NextOnt.nextOutput) || ind.isType(NextOnt.nextInput))
}
}
return values;
}
public void continueExec() {
setInterrupted(false);
}
public void interruptExec() {
}
public void interruptExec(int millisToSleep) {
setInterrupted(true);
}
protected boolean isInterrupted() {
return interrupted;
}
protected void setInterrupted(boolean interrupted) {
this.interrupted = interrupted;
}
setResultReady(true);
}
}
public ValueMap getResultMap() {
setResultReady(false);
return resultMap;
}
public boolean isResultReady() {
return resultReady;
}
public void setResultReady(boolean resultState) {
if (resultState)
}
// waits until the interruption ended
private void processInterruption() {
while (isInterrupted()) {
try {
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
/**
* invokes executionInterrupted() on all registred listeners
*/
protected void executionInterrupted() {
}
/**
* invokes executionContinued() on all registred listeners
*/
protected void executionContinued() {
}
/**
* invokes atomicProcessStarted(AtomicProcess atomicProcess) on all registred listeners
* @param atomicProcess the AtomicProcess whichs execution started
*/
}
/**
* invokes atomicProcessEnded(AtomicProcess atomicProcess) on all registred listeners
* @param atomicProcess the AtomicProcess whichs execution finished
*/
}
}
protected void executionHasFinished() {
}
protected void executionHasStarted() {
}
/* (non-Javadoc)
* @see org.mindswap.owls.process.execution.ThreadedProcessExecutionEngine#addExecutionListener(org.mindswap.owls.process.execution.ThreadedProcessExecutionListener)
*/
}
/* (non-Javadoc)
* @see org.mindswap.owls.process.execution.ThreadedProcessExecutionEngine#removeExecutionListener(org.mindswap.owls.process.execution.ThreadedProcessExecutionListener)
*/
}
public int getInterval() {
return interval;
}
public void setInterval(int interval) {
}
public String getProcessName() {
return processName;
}
}