gate.creole
Interface ControllerAwarePR

All Superinterfaces:
Executable, FeatureBearer, NameBearer, ProcessingResource, Resource, Serializable
All Known Implementing Classes:
ANNIETransducer, OntologyAwareTransducer, Transducer, VPChunker

public interface ControllerAwarePR
extends ProcessingResource

This interface should be implemented by processing resources that need to know when any containing controller starts and ends its execution, for example to initialise internal data structures or to do some aggregate processing of data gathered from a whole corpus.

If a controller contains several PRs that implement this interface, the order in which their controllerExecutionStarted (Finished or Aborted) methods are called is not specified. In particular, the "ended" methods may be called in a different order from the "started" ones. Also, if one PR throws an exception from its controllerExecutionFinished method, the other finished methods may not be called at all for this run. PRs should be robust to this possibility.

The controller should call this PRs started and finished (or aborted) methods at most once per run, even if the controller allows the same PR to be added multiple times.


Method Summary
 void controllerExecutionAborted(Controller c, Throwable t)
          Called by a controller containing this PR when the controller's execution has been aborted by an exception thrown by one of the contained PR's execute methods, or by the controller itself.
 void controllerExecutionFinished(Controller c)
          Called by a controller containing this PR when the controller's execution has completed successfully.
 void controllerExecutionStarted(Controller c)
          Called by a controller containing this PR when the controller begins executing.
 
Methods inherited from interface gate.ProcessingResource
reInit
 
Methods inherited from interface gate.Resource
cleanup, getParameterValue, init, setParameterValue, setParameterValues
 
Methods inherited from interface gate.util.FeatureBearer
getFeatures, setFeatures
 
Methods inherited from interface gate.util.NameBearer
getName, setName
 
Methods inherited from interface gate.Executable
execute, interrupt, isInterrupted
 

Method Detail

controllerExecutionStarted

void controllerExecutionStarted(Controller c)
                                throws ExecutionException
Called by a controller containing this PR when the controller begins executing. When this method is called, it is guaranteed that none of the PRs in this controller have yet been executed on this run.

Parameters:
c - the Controller that is executing.
Throws:
ExecutionException - if an error occurs that requires the controller to abort its execution.

controllerExecutionFinished

void controllerExecutionFinished(Controller c)
                                 throws ExecutionException
Called by a controller containing this PR when the controller's execution has completed successfully. When this method is called, it is guaranteed that there will be no more calls to the execute method of any of this controller's PRs in this run.

Parameters:
c - the Controller that is executing.
Throws:
ExecutionException - if an error occurs that requires the controller to abort its execution.

controllerExecutionAborted

void controllerExecutionAborted(Controller c,
                                Throwable t)
                                throws ExecutionException
Called by a controller containing this PR when the controller's execution has been aborted by an exception thrown by one of the contained PR's execute methods, or by the controller itself. When this method is called, it is guaranteed that there will be no more calls to the execute method of any of this controller's PRs in this run.

Parameters:
c - the Controller that is executing.
t - the Throwable that caused the controller to abort. This will be either an ExecutionException, a RuntimeException or an Error.
Throws:
ExecutionException - if an error occurs in this method that requires the controller to abort its execution. This method should not rethrow t, as the controller will do this after informing any other ControllerAware PRs it contains.