Revision: 18563
http://sourceforge.net/p/gate/code/18563
Author: johann_p
Date: 2015-02-09 16:38:02 +0000 (Mon, 09 Feb 2015)
Log Message:
-----------
Make the optional disabling of the controller callbacks and explicit invocation
work with
AnalyserControllers too, Also, change things so that the AbstractController
does not have to know
about its subclasses anymore, since we need to override the invoke methods
anyway.
Modified Paths:
--------------
gate/trunk/src/main/gate/creole/AbstractController.java
gate/trunk/src/main/gate/creole/ConditionalSerialAnalyserController.java
gate/trunk/src/main/gate/creole/SerialAnalyserController.java
Modified: gate/trunk/src/main/gate/creole/AbstractController.java
===================================================================
--- gate/trunk/src/main/gate/creole/AbstractController.java 2015-02-09
16:18:22 UTC (rev 18562)
+++ gate/trunk/src/main/gate/creole/AbstractController.java 2015-02-09
16:38:02 UTC (rev 18563)
@@ -461,18 +461,7 @@
* @throws ExecutionException
*/
public void invokeControllerExecutionStarted() throws ExecutionException {
- CorpusController thisAsCorpusController = null;
- if(this instanceof CorpusController) {
- thisAsCorpusController = (CorpusController)this;
- }
for (ControllerAwarePR pr : getControllerAwarePRs()) {
- // If the pr is a nested corpus controller, make sure its corpus is set
- // This is necessary because the nested corpus controller will
immediately
- // notify its own controller aware PRs and those should be able to know
about
- // the corpus.
- if (thisAsCorpusController != null && pr instanceof LanguageAnalyser) {
- ((LanguageAnalyser) pr).setCorpus(thisAsCorpusController.getCorpus());
- }
pr.controllerExecutionStarted(this);
}
}
@@ -485,18 +474,8 @@
* @throws ExecutionException
*/
public void invokeControllerExecutionFinished() throws ExecutionException {
- CorpusController thisAsCorpusController = null;
- if(this instanceof CorpusController) {
- thisAsCorpusController = (CorpusController)this;
- }
for (ControllerAwarePR pr : getControllerAwarePRs()) {
- if (pr instanceof LanguageAnalyser) {
- ((LanguageAnalyser) pr).setCorpus(thisAsCorpusController.getCorpus());
- }
pr.controllerExecutionFinished(this);
- if (pr instanceof LanguageAnalyser) {
- ((LanguageAnalyser) pr).setCorpus(null);
- }
}
}
@@ -508,18 +487,8 @@
* @throws ExecutionException
*/
public void invokeControllerExecutionAborted(Throwable thrown) throws
ExecutionException {
- CorpusController thisAsCorpusController = null;
- if(this instanceof CorpusController) {
- thisAsCorpusController = (CorpusController)this;
- }
for (ControllerAwarePR pr : getControllerAwarePRs()) {
- if (pr instanceof LanguageAnalyser) {
- ((LanguageAnalyser) pr).setCorpus(thisAsCorpusController.getCorpus());
- }
pr.controllerExecutionAborted(this, thrown);
- if (pr instanceof LanguageAnalyser) {
- ((LanguageAnalyser) pr).setCorpus(null);
- }
}
}
Modified:
gate/trunk/src/main/gate/creole/ConditionalSerialAnalyserController.java
===================================================================
--- gate/trunk/src/main/gate/creole/ConditionalSerialAnalyserController.java
2015-02-09 16:18:22 UTC (rev 18562)
+++ gate/trunk/src/main/gate/creole/ConditionalSerialAnalyserController.java
2015-02-09 16:38:02 UTC (rev 18563)
@@ -117,15 +117,8 @@
// inform ControllerAware PRs that execution has started, but only if we
are not
// running as a subpipeline of another corpus pipeline.
if(!runningAsSubPipeline) {
- for(ControllerAwarePR pr : getControllerAwarePRs()) {
- // If the pr is a nested corpus controller, make sure its corpus is
set
- // This is necessary because the nested corpus controller will
immediately
- // notify its own controller aware PRs and those should be able to
know about
- // the corpus.
- if(pr instanceof LanguageAnalyser) {
- ((LanguageAnalyser)pr).setCorpus(corpus);
- }
- pr.controllerExecutionStarted(this);
+ if(controllerCallbacksEnabled) {
+ invokeControllerExecutionStarted();
}
}
Throwable thrown = null;
@@ -145,28 +138,16 @@
if(thrown == null) {
// successfully completed
if(!runningAsSubPipeline) {
- for(ControllerAwarePR pr : getControllerAwarePRs()) {
- if(pr instanceof LanguageAnalyser) {
- ((LanguageAnalyser)pr).setCorpus(corpus);
- }
- pr.controllerExecutionFinished(this);
- if(pr instanceof LanguageAnalyser) {
- ((LanguageAnalyser)pr).setCorpus(null);
- }
+ if(controllerCallbacksEnabled) {
+ invokeControllerExecutionFinished();
}
}
}
else {
// aborted
if(!runningAsSubPipeline) {
- for(ControllerAwarePR pr : getControllerAwarePRs()) {
- if(pr instanceof LanguageAnalyser) {
- ((LanguageAnalyser)pr).setCorpus(corpus);
- }
- pr.controllerExecutionAborted(this, thrown);
- if(pr instanceof LanguageAnalyser) {
- ((LanguageAnalyser)pr).setCorpus(null);
- }
+ if(controllerCallbacksEnabled) {
+ invokeControllerExecutionAborted(thrown);
}
}
// rethrow the aborting exception or error
@@ -511,4 +492,69 @@
}
}
}
+
+ /**
+ * Invoke the controllerExecutionStarted method on this controller and all
nested PRs and controllers.
+ * This method is intended to be used after if the automatic invocation of
the controller
+ * callback methods has been disabled with a call
setControllerCallbackEnabled(false). Normally
+ * the callback methods are automatically invoked at the start and end of
execute().
+ * @throws ExecutionException
+ */
+ @Override
+ public void invokeControllerExecutionStarted() throws ExecutionException {
+ for (ControllerAwarePR pr : getControllerAwarePRs()) {
+ // If the pr is a nested corpus controller, make sure its corpus is set
+ // This is necessary because the nested corpus controller will
immediately
+ // notify its own controller aware PRs and those should be able to know
about
+ // the corpus.
+ if (pr instanceof LanguageAnalyser) {
+ ((LanguageAnalyser) pr).setCorpus(getCorpus());
+ }
+ pr.controllerExecutionStarted(this);
+ }
+ }
+
+ /**
+ * Invoke the controllerExecutionFinished method on this controller and all
nested PRs and controllers.
+ * This method is intended to be used after if the automatic invocation of
the controller
+ * callback methods has been disabled with a call
setControllerCallbackEnabled(false). Normally
+ * the callback methods are automatically invoked at the start and end of
execute().
+ * @throws ExecutionException
+ */
+ @Override
+ public void invokeControllerExecutionFinished() throws ExecutionException {
+ for (ControllerAwarePR pr : getControllerAwarePRs()) {
+ if (pr instanceof LanguageAnalyser) {
+ ((LanguageAnalyser) pr).setCorpus(getCorpus());
+ }
+ pr.controllerExecutionFinished(this);
+ if (pr instanceof LanguageAnalyser) {
+ ((LanguageAnalyser) pr).setCorpus(null);
+ }
+ }
+ }
+
+ /**
+ * Invoke the controllerExecutionAborted method on this controller and all
nested PRs and controllers.
+ * This method is intended to be used after if the automatic invocation of
the controller
+ * callback methods has been disabled with a call
setControllerCallbackEnabled(false). Normally
+ * the callback methods are automatically invoked at the start and end of
execute().
+ * @param thrown The Throwable to pass on to the controller callback method.
+ * @throws ExecutionException
+ */
+ @Override
+ public void invokeControllerExecutionAborted(Throwable thrown) throws
ExecutionException {
+ for (ControllerAwarePR pr : getControllerAwarePRs()) {
+ if (pr instanceof LanguageAnalyser) {
+ ((LanguageAnalyser) pr).setCorpus(getCorpus());
+ }
+ pr.controllerExecutionAborted(this, thrown);
+ if (pr instanceof LanguageAnalyser) {
+ ((LanguageAnalyser) pr).setCorpus(null);
+ }
+ }
+ }
+
+
+
}
Modified: gate/trunk/src/main/gate/creole/SerialAnalyserController.java
===================================================================
--- gate/trunk/src/main/gate/creole/SerialAnalyserController.java
2015-02-09 16:18:22 UTC (rev 18562)
+++ gate/trunk/src/main/gate/creole/SerialAnalyserController.java
2015-02-09 16:38:02 UTC (rev 18563)
@@ -111,11 +111,8 @@
// inform ControllerAware PRs that execution has started, but only if we
are not
// running as a subpipeline of another corpus pipeline.
if(!runningAsSubPipeline) {
- for(ControllerAwarePR pr : getControllerAwarePRs()) {
- if(pr instanceof LanguageAnalyser) {
- ((LanguageAnalyser)pr).setCorpus(corpus);
- }
- pr.controllerExecutionStarted(this);
+ if(controllerCallbacksEnabled) {
+ invokeControllerExecutionStarted();
}
}
Throwable thrown = null;
@@ -135,28 +132,16 @@
if(thrown == null) {
// successfully completed
if(!runningAsSubPipeline) {
- for(ControllerAwarePR pr : getControllerAwarePRs()) {
- if(pr instanceof LanguageAnalyser) {
- ((LanguageAnalyser)pr).setCorpus(corpus);
- }
- pr.controllerExecutionFinished(this);
- if(pr instanceof LanguageAnalyser) {
- ((LanguageAnalyser)pr).setCorpus(null);
- }
+ if(controllerCallbacksEnabled) {
+ invokeControllerExecutionFinished();
}
}
}
else {
// aborted
if(!runningAsSubPipeline) {
- for(ControllerAwarePR pr : getControllerAwarePRs()) {
- if(pr instanceof LanguageAnalyser) {
- ((LanguageAnalyser)pr).setCorpus(corpus);
- }
- pr.controllerExecutionAborted(this, thrown);
- if(pr instanceof LanguageAnalyser) {
- ((LanguageAnalyser)pr).setCorpus(null);
- }
+ if(controllerCallbacksEnabled) {
+ invokeControllerExecutionAborted(thrown);
}
}
// rethrow the aborting exception or error
@@ -460,4 +445,70 @@
}
}
}
+
+ /**
+ * Invoke the controllerExecutionStarted method on this controller and all
nested PRs and controllers.
+ * This method is intended to be used after if the automatic invocation of
the controller
+ * callback methods has been disabled with a call
setControllerCallbackEnabled(false). Normally
+ * the callback methods are automatically invoked at the start and end of
execute().
+ * @throws ExecutionException
+ */
+ @Override
+ public void invokeControllerExecutionStarted() throws ExecutionException {
+ for (ControllerAwarePR pr : getControllerAwarePRs()) {
+ // If the pr is a nested corpus controller, make sure its corpus is set
+ // This is necessary because the nested corpus controller will
immediately
+ // notify its own controller aware PRs and those should be able to know
about
+ // the corpus.
+ if (pr instanceof LanguageAnalyser) {
+ ((LanguageAnalyser) pr).setCorpus(getCorpus());
+ }
+ pr.controllerExecutionStarted(this);
+ }
+ }
+
+ /**
+ * Invoke the controllerExecutionFinished method on this controller and all
nested PRs and controllers.
+ * This method is intended to be used after if the automatic invocation of
the controller
+ * callback methods has been disabled with a call
setControllerCallbackEnabled(false). Normally
+ * the callback methods are automatically invoked at the start and end of
execute().
+ * @throws ExecutionException
+ */
+ @Override
+ public void invokeControllerExecutionFinished() throws ExecutionException {
+ for (ControllerAwarePR pr : getControllerAwarePRs()) {
+ if (pr instanceof LanguageAnalyser) {
+ ((LanguageAnalyser) pr).setCorpus(getCorpus());
+ }
+ pr.controllerExecutionFinished(this);
+ if (pr instanceof LanguageAnalyser) {
+ ((LanguageAnalyser) pr).setCorpus(null);
+ }
+ }
+ }
+
+ /**
+ * Invoke the controllerExecutionAborted method on this controller and all
nested PRs and controllers.
+ * This method is intended to be used after if the automatic invocation of
the controller
+ * callback methods has been disabled with a call
setControllerCallbackEnabled(false). Normally
+ * the callback methods are automatically invoked at the start and end of
execute().
+ * @param thrown The Throwable to pass on to the controller callback method.
+ * @throws ExecutionException
+ */
+ @Override
+ public void invokeControllerExecutionAborted(Throwable thrown) throws
ExecutionException {
+ for (ControllerAwarePR pr : getControllerAwarePRs()) {
+ if (pr instanceof LanguageAnalyser) {
+ ((LanguageAnalyser) pr).setCorpus(getCorpus());
+ }
+ pr.controllerExecutionAborted(this, thrown);
+ if (pr instanceof LanguageAnalyser) {
+ ((LanguageAnalyser) pr).setCorpus(null);
+ }
+ }
+ }
+
+
+
+
}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Dive into the World of Parallel Programming. The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net/
_______________________________________________
GATE-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gate-cvs