From: <mar...@us...> - 2012-03-26 13:37:30
|
Revision: 15628 http://gate.svn.sourceforge.net/gate/?rev=15628&view=rev Author: markagreenwood Date: 2012-03-26 13:37:23 +0000 (Mon, 26 Mar 2012) Log Message: ----------- make groovy load it's classes into the plugin classloader to avoid clashes between groovy versions -- should possibly look at different classloader for each script (like jape) to allow for easier garbage collection Modified Paths: -------------- gate/trunk/plugins/Groovy/src/gate/groovy/GroovySupport.java gate/trunk/plugins/Groovy/src/gate/groovy/ScriptPR.java gate/trunk/plugins/Groovy/src/gate/groovy/ScriptableController.groovy Modified: gate/trunk/plugins/Groovy/src/gate/groovy/GroovySupport.java =================================================================== --- gate/trunk/plugins/Groovy/src/gate/groovy/GroovySupport.java 2012-03-26 01:19:19 UTC (rev 15627) +++ gate/trunk/plugins/Groovy/src/gate/groovy/GroovySupport.java 2012-03-26 13:37:23 UTC (rev 15628) @@ -80,7 +80,7 @@ catch(PersistenceException e) { throw new ResourceInstantiationException(e); } - + return this; } @@ -105,9 +105,9 @@ DefaultGroovyMethods.mixin(clazz, classToMix); } } - + private List<Action> actions; - + public List getActions() { if(actions == null) { actions = new ArrayList<Action>(); @@ -118,7 +118,7 @@ } private static final long serialVersionUID = 1L; public void actionPerformed(ActionEvent evt) { - groovy.ui.Console console = new groovy.ui.Console(Gate.getClassLoader()) { + groovy.ui.Console console = new groovy.ui.Console(GroovySupport.class.getClassLoader()) { /** * Overridden to (a) install a Binding that knows about the @@ -137,7 +137,7 @@ } }); } - + /** * This is a workaround for a strange behaviour in Groovy. At some * point the superclass attempts to do "scriptRunning = false" from @@ -159,7 +159,7 @@ catch(Exception e) { // give up } - } + } }; console.run(); } @@ -167,7 +167,7 @@ } return actions; } - + /** * Special Binding subclass that handles requests for the variables * corpora, docs, prs and apps by delegating to the creole register. @@ -176,7 +176,7 @@ GateBinding(Binding delegateBinding) { super(delegateBinding.getVariables()); } - + /** * Overridden to intercept requests for the 'pseudo-variables' * corpora, docs, prs and apps and direct them to the relevant Modified: gate/trunk/plugins/Groovy/src/gate/groovy/ScriptPR.java =================================================================== --- gate/trunk/plugins/Groovy/src/gate/groovy/ScriptPR.java 2012-03-26 01:19:19 UTC (rev 15627) +++ gate/trunk/plugins/Groovy/src/gate/groovy/ScriptPR.java 2012-03-26 13:37:23 UTC (rev 15628) @@ -1,11 +1,11 @@ /* * Copyright (c) 2010, The University of Sheffield. - * + * * This file is part of the GATE/Groovy integration layer, and is free software, * released under the terms of the GNU Lesser General Public Licence, version * 2.1 (or any later version). A copy of this licence is provided in the file * LICENCE in the distribution. - * + * * Groovy is developed by The Codehaus, details are available from * http://groovy.codehaus.org */ @@ -44,7 +44,7 @@ /** * Groovy Script PR. - * + * * @author Angus Roberts, Ian Roberts */ @CreoleResource(name = "Groovy scripting PR", comment = "Runs a Groovy script as a processing resource", helpURL = "http://gate.ac.uk/userguide/sec:api:groovy", icon = "/gate/groovy/script-pr") @@ -96,7 +96,7 @@ // Create the shell, with the GateClassLoader as its parent (so the script // will have access to plugin classes) - GroovyShell groovyShell = new GroovyShell(Gate.getClassLoader()); + GroovyShell groovyShell = new GroovyShell(ScriptPR.class.getClassLoader()); StringBuilder scriptText = new StringBuilder(); char[] buf = new char[4096]; @@ -166,7 +166,7 @@ * Check whether the script declares a method with the given name that takes a * corpus parameter, and if so, call it passing the corpus from the given * controller. If the controller is not a CorpusController, do nothing. - * + * * @throws ExecutionException * if the script method throws an ExecutionException we re-throw it */ @@ -251,7 +251,7 @@ /** * gets name of the output annotation set - * + * * @return */ public String getOutputASName() { @@ -260,7 +260,7 @@ /** * sets name of the output annotaiton set - * + * * @param outputAS */ @Optional @@ -272,7 +272,7 @@ /** * gets name of the input annotation set - * + * * @return */ public String getInputASName() { @@ -281,7 +281,7 @@ /** * sets name of the input annotaiton set - * + * * @param inputAS */ @Optional @@ -293,7 +293,7 @@ /** * gets URL of the Groovy script - * + * * @return */ public URL getScriptURL() { @@ -302,7 +302,7 @@ /** * sets File of the Groovy script - * + * * @param script */ @CreoleParameter(comment = "Location of the Groovy script that will be " @@ -329,7 +329,7 @@ /** * Get Map of parameters for the Groovy script - * + * * @return */ public FeatureMap getScriptParams() { @@ -338,7 +338,7 @@ /** * Set Map of parameters for the Groovy script - * + * * @return */ @Optional @@ -351,7 +351,7 @@ /** * Return the source of the loaded groovy script - * + * * @return the source of the loaded groovy script */ public String getGroovySrc() { Modified: gate/trunk/plugins/Groovy/src/gate/groovy/ScriptableController.groovy =================================================================== --- gate/trunk/plugins/Groovy/src/gate/groovy/ScriptableController.groovy 2012-03-26 01:19:19 UTC (rev 15627) +++ gate/trunk/plugins/Groovy/src/gate/groovy/ScriptableController.groovy 2012-03-26 13:37:23 UTC (rev 15628) @@ -95,7 +95,7 @@ */ protected void parseScript() throws ExecutionException { try { - script = new GroovyShell(Gate.getClassLoader()).parse( + script = new GroovyShell(ScriptableController.class.getClassLoader()).parse( controlScript + "\n\n\n" + GroovySupport.STANDARD_IMPORTS) // replace the binding with our "active" one that delegates // corpus, controller and prs variables through to the controller This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |