groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Pascal Schumacher (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (GROOVY-7351) Behaviour difference between GroovyEngine and CachingGroovyEngine
Date Sun, 05 Jul 2015 14:56:04 GMT

     [ https://issues.apache.org/jira/browse/GROOVY-7351?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Pascal Schumacher updated GROOVY-7351:
--------------------------------------
    Description: 
When using BSF to interact with GroovyEngine it was seen that a Groovy class that was created
as a result of a previous execution was not available for subsequent execution when GroovyEngine
was used.
If CachingGroovyEngine was used, it would work.
Sample code is given below

{code}
public class GroovyUsePreviousClass {

	public static void main(String[] args) {
		try {
			String myScript1 = "public class BSFHelloWorld {\n public static void main(" +
					"String[] args ) { println(\'BSF: main: Hello World!\'); }\n };";
			String myScript2 = "import BSFHelloWorld;\n inst = new BSFHelloWorld();\n";
			BSFManager bsfm = new BSFManager();
			// Problem can be resolved by uncommenting the line below:
			//BSFManager.registerScriptingEngine("groovy", "org.codehaus.groovy.bsf.CachingGroovyEngine",
new String[]{"groovy", "gy"});
			BSFEngine anEngine = bsfm.loadScriptingEngine("groovy");
			anEngine.exec("Step HelloWorld1", 0, 0, myScript1) ;
			anEngine.exec("Step HelloWorld2", 0, 0, myScript2) ;

		} catch (BSFException bse) {
			bse.printStackTrace();
		}
	}
}{code}

  was:
When using BSF to interact with GroovyEngine it was seen that a Groovy class that was created
as a result of a previous execution was not available for subsequent execution when GroovyEngine
was used.
If CachingGroovyEngine was used, it would work.
Sample code is given below

public class GroovyUsePreviousClass {

	public static void main(String[] args) {
		try {
			String myScript1 = "public class BSFHelloWorld {\n public static void main(" +
					"String[] args ) { println(\'BSF: main: Hello World!\'); }\n };";
			String myScript2 = "import BSFHelloWorld;\n inst = new BSFHelloWorld();\n";
			BSFManager bsfm = new BSFManager();
			// Problem can be resolved by uncommenting the line below:
			//BSFManager.registerScriptingEngine("groovy", "org.codehaus.groovy.bsf.CachingGroovyEngine",
new String[]{"groovy", "gy"});
			BSFEngine anEngine = bsfm.loadScriptingEngine("groovy");
			anEngine.exec("Step HelloWorld1", 0, 0, myScript1) ;
			anEngine.exec("Step HelloWorld2", 0, 0, myScript2) ;

		} catch (BSFException bse) {
			bse.printStackTrace();
		}
	}


> Behaviour difference between GroovyEngine and CachingGroovyEngine
> -----------------------------------------------------------------
>
>                 Key: GROOVY-7351
>                 URL: https://issues.apache.org/jira/browse/GROOVY-7351
>             Project: Groovy
>          Issue Type: Bug
>          Components: GroovyScriptEngine
>    Affects Versions: 2.3.3
>            Reporter: Sebu Koleth
>
> When using BSF to interact with GroovyEngine it was seen that a Groovy class that was
created as a result of a previous execution was not available for subsequent execution when
GroovyEngine was used.
> If CachingGroovyEngine was used, it would work.
> Sample code is given below
> {code}
> public class GroovyUsePreviousClass {
> 	public static void main(String[] args) {
> 		try {
> 			String myScript1 = "public class BSFHelloWorld {\n public static void main(" +
> 					"String[] args ) { println(\'BSF: main: Hello World!\'); }\n };";
> 			String myScript2 = "import BSFHelloWorld;\n inst = new BSFHelloWorld();\n";
> 			BSFManager bsfm = new BSFManager();
> 			// Problem can be resolved by uncommenting the line below:
> 			//BSFManager.registerScriptingEngine("groovy", "org.codehaus.groovy.bsf.CachingGroovyEngine",
new String[]{"groovy", "gy"});
> 			BSFEngine anEngine = bsfm.loadScriptingEngine("groovy");
> 			anEngine.exec("Step HelloWorld1", 0, 0, myScript1) ;
> 			anEngine.exec("Step HelloWorld2", 0, 0, myScript2) ;
> 		} catch (BSFException bse) {
> 			bse.printStackTrace();
> 		}
> 	}
> }{code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message