Revision: 18635
http://sourceforge.net/p/gate/code/18635
Author: markagreenwood
Date: 2015-04-13 14:43:04 +0000 (Mon, 13 Apr 2015)
Log Message:
-----------
nullify most of the bindings we set in execute() so that the document gets
properly released afterwards
Modified Paths:
--------------
gate/trunk/plugins/Groovy/src/gate/groovy/ScriptPR.java
Modified: gate/trunk/plugins/Groovy/src/gate/groovy/ScriptPR.java
===================================================================
--- gate/trunk/plugins/Groovy/src/gate/groovy/ScriptPR.java 2015-04-13
13:07:24 UTC (rev 18634)
+++ gate/trunk/plugins/Groovy/src/gate/groovy/ScriptPR.java 2015-04-13
14:43:04 UTC (rev 18635)
@@ -242,35 +242,47 @@
fireStatusChanged("Groovy script PR running");
}
fireProgressChanged(0);
-
- // Create the variable bindings
+
Binding binding = groovyScript.getBinding();
- binding.setVariable("doc", document);
- binding.setVariable("corpus", corpus);
- if(document != null) {
- binding.setVariable("content", document.getContent().toString());
- } else {
- binding.setVariable("content", null);
- }
- binding.setVariable("inputAS", inputAS);
- binding.setVariable("outputAS", outputAS);
-
- // these should be deprecated, really, they're no longer necessary with the
- // imports
- binding.setVariable("gate", Gate.class);
- binding.setVariable("factory", gate.Factory.class);
-
- // The FeatureMap is passed in its entirety, making the keys available in
- // a bean-like way. So in a map with k=v, the script can say
- // assert scriptParams.k == v
- binding.setVariable("scriptParams", scriptParams);
-
- // Run the script engine
+
try {
+ // Create the variable bindings
+ binding.setVariable("doc", document);
+ binding.setVariable("corpus", corpus);
+ if(document != null) {
+ binding.setVariable("content", document.getContent().toString());
+ } else {
+ binding.setVariable("content", null);
+ }
+ binding.setVariable("inputAS", inputAS);
+ binding.setVariable("outputAS", outputAS);
+
+ // these should be deprecated, really, they're no longer necessary with
the
+ // imports
+ binding.setVariable("gate", Gate.class);
+ binding.setVariable("factory", gate.Factory.class);
+
+ // The FeatureMap is passed in its entirety, making the keys available in
+ // a bean-like way. So in a map with k=v, the script can say
+ // assert scriptParams.k == v
+ binding.setVariable("scriptParams", scriptParams);
+
+ // Run the script engine
groovyScript.run();
} catch(RuntimeException re) {
throw new ExecutionException("Problem running Groovy script", re);
}
+ finally {
+ binding.setVariable("doc", null);
+ binding.setVariable("corpus", null);
+ binding.setVariable("content", null);
+ binding.setVariable("inputAS", null);
+ binding.setVariable("outputAS", null);
+
+ // TODO not sure if we should nullify scriptParams as well, but I'm
+ // thinking it's fairly safe not to as they shouldn't be document/corpus
+ // based
+ }
// We've done
fireProgressChanged(100);
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
BPM Camp - Free Virtual Workshop May 6th at 10am PDT/1PM EDT
Develop your own process in accordance with the BPMN 2 standard
Learn Process modeling best practices with Bonita BPM through live exercises
http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual- event?utm_
source=Sourceforge_BPM_Camp_5_6_15&utm_medium=email&utm_campaign=VA_SF
_______________________________________________
GATE-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gate-cvs