@CreoleResource(icon="application") public abstract class AbstractController extends AbstractResource implements Controller, ProcessingResource, Benchmarkable
Modifier and Type | Class and Description |
---|---|
protected class |
AbstractController.InternalStatusListener
A simple status listener used to forward the events upstream.
|
protected class |
AbstractController.IntervalProgressListener
A progress listener used to convert a 0..100 interval into a smaller one
|
Modifier and Type | Field and Description |
---|---|
protected Map<Object,Object> |
benchmarkFeatures
Shared featureMap
|
protected String |
benchmarkID
Benchmark ID of this resource.
|
protected boolean |
controllerCallbacksEnabled |
protected boolean |
interrupted |
name
features
Constructor and Description |
---|
AbstractController() |
Modifier and Type | Method and Description |
---|---|
void |
addControllerListener(ControllerListener l) |
void |
addProgressListener(ProgressListener l)
Adds a
ProgressListener to the list of listeners for
this processing resource. |
void |
addStatusListener(StatusListener l)
Adds a
StatusListener to the list of listeners for this
processing resource |
void |
cleanup()
Clears the internal data of the resource, when it gets released *
|
void |
execute()
Execute this controller.
|
protected void |
executeImpl()
Executes the PRs in this controller, according to the execution strategy of
the particular controller type (simple pipeline, parallel execution,
once-per-document in a corpus, etc.).
|
protected void |
fireProcessFinished()
Notifies all the
ProgressListener s of a progress
finished. |
protected void |
fireProgressChanged(int e)
Notifies all the
ProgressListener s of a progress change
event. |
protected void |
fireResourceAdded(ControllerEvent e) |
protected void |
fireResourceRemoved(ControllerEvent e) |
protected void |
fireStatusChanged(String e)
Notifies all the
StatusListener s of a change of status. |
String |
getBenchmarkId()
Returns the benchmark ID of this controller.
|
protected Set<ControllerAwarePR> |
getControllerAwarePRs()
Get the set of PRs from this controller that implement
ControllerAwarePR . |
List<ProcessingResource> |
getOffendingPocessingResources()
Checks whether all the contained PRs have all the required runtime
parameters set.
|
Resource |
init()
Initialise this resource, and return it.
|
void |
interrupt()
Notifies all the PRs in this controller that they should stop their
execution as soon as possible.
|
void |
invokeControllerExecutionAborted(Throwable thrown)
Invoke the controllerExecutionAborted method on this controller and all nested PRs and controllers.
|
void |
invokeControllerExecutionFinished()
Invoke the controllerExecutionFinished method on this controller and all nested PRs and controllers.
|
void |
invokeControllerExecutionStarted()
Invoke the controllerExecutionStarted method on this controller and all nested PRs and controllers.
|
boolean |
isInterrupted()
Returns true if this executable has been interrupted via the
Executable.interrupt() method since the last time its Executable.execute() method
was called |
void |
reInit()
Reinitialises the processing resource.
|
void |
removeControllerListener(ControllerListener l) |
void |
removeProgressListener(ProgressListener l)
Removes a
ProgressListener from the list of listeners
for this processing resource. |
void |
removeStatusListener(StatusListener l)
Removes a
StatusListener from the list of listeners for
this processing resource |
void |
setBenchmarkId(String benchmarkID)
Sets the benchmark ID of this controller.
|
void |
setControllerCallbacksEnabled(boolean flag)
Enable or disable the automatic invocation of the controller callbacks.
|
void |
setPRs(Collection<? extends ProcessingResource> PRs)
Populates this controller from a collection of
ProcessingResource s
(optional operation). |
checkParameterValues, flushBeanInfoCache, forgetBeanInfo, getBeanInfo, getInitParameterValues, getInitParameterValues, getName, getParameterValue, getParameterValue, getParameterValues, removeResourceListeners, setName, setParameterValue, setParameterValue, setParameterValues, setParameterValues, setResourceListeners, toString
getFeatures, setFeatures
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getPRs
getParameterValue, setParameterValue, setParameterValues
protected String benchmarkID
protected boolean interrupted
protected boolean controllerCallbacksEnabled
public void execute() throws ExecutionException
ControllerAwarePR
s of the start and end of execution, and
delegates to the executeImpl()
method to do the real work.
Subclasses should override executeImpl()
rather than this method.execute
in interface Controller
execute
in interface Executable
ExecutionException
protected Set<ControllerAwarePR> getControllerAwarePRs()
ControllerAwarePR
. If there are no such PRs in this controller, an
empty set is returned. This implementation simply filters the collection
returned by Controller.getPRs()
, override this method if your
subclass admits a more efficient implementation.protected void executeImpl() throws ExecutionException
execute()
method to handle sending
notifications to controller aware PRs.ExecutionException
public Resource init() throws ResourceInstantiationException
init
in interface Resource
init
in class AbstractResource
ResourceInstantiationException
public void reInit() throws ResourceInstantiationException
ProcessingResource
reInit
in interface ProcessingResource
ResourceInstantiationException
public void cleanup()
cleanup
in interface Resource
cleanup
in class AbstractResource
public void setPRs(Collection<? extends ProcessingResource> PRs)
ProcessingResource
s
(optional operation).
Controllers that are serializable must implement this method needed by GATE
to restore their contents.setPRs
in interface Controller
UnsupportedOperationException
- if the setPRs method is not supported by this
controller.public void interrupt()
interrupt
in interface Executable
public boolean isInterrupted()
Executable
Executable.interrupt()
method since the last time its Executable.execute()
method
was calledisInterrupted
in interface Executable
public void removeStatusListener(StatusListener l)
StatusListener
from the list of listeners for
this processing resourcepublic void addStatusListener(StatusListener l)
StatusListener
to the list of listeners for this
processing resourceprotected void fireStatusChanged(String e)
StatusListener
s of a change of status.e
- the message describing the status changepublic void addProgressListener(ProgressListener l)
ProgressListener
to the list of listeners for
this processing resource.public void removeProgressListener(ProgressListener l)
ProgressListener
from the list of listeners
for this processing resource.protected void fireProgressChanged(int e)
ProgressListener
s of a progress change
event.e
- the new value of execution completionprotected void fireProcessFinished()
ProgressListener
s of a progress
finished.public List<ProcessingResource> getOffendingPocessingResources() throws ResourceInstantiationException
List
of ProcessingResource
s that have required
parameters with null values if they exist null
otherwise.ResourceInstantiationException
- if problems occur while inspecting the parameters for one of the
resources. These will normally be introspection problems and are
usually caused by the lack of a parameter or of the read accessor
for a parameter.public void removeControllerListener(ControllerListener l)
public void addControllerListener(ControllerListener l)
protected void fireResourceAdded(ControllerEvent e)
protected void fireResourceRemoved(ControllerEvent e)
public void setBenchmarkId(String benchmarkID)
setBenchmarkId
in interface Benchmarkable
benchmarkID
- the benchmark ID, which must not contain spaces
as it is already used as a separator in the log, you can use
Benchmark.createBenchmarkId(String, String)
for it.public String getBenchmarkId()
getBenchmarkId
in interface Benchmarkable
public void invokeControllerExecutionStarted() throws ExecutionException
ExecutionException
public void invokeControllerExecutionFinished() throws ExecutionException
ExecutionException
public void invokeControllerExecutionAborted(Throwable thrown) throws ExecutionException
ExecutionException
public void setControllerCallbacksEnabled(boolean flag)
flag
- a boolean indicating if the callbacks should be enabled (true) or disabled (false)Copyright © 2024 GATE. All rights reserved.