ow2-proactive / scheduling

Multi-platform Scheduling and Workflows Engine
http://www.activeeon.com/workflows-scheduling
GNU Affero General Public License v3.0
62 stars 55 forks source link

add BeanShell to our script engines #1959

Open activeeon-bot opened 10 years ago

activeeon-bot commented 10 years ago

Original issue created by Fabien Viale on 31, Oct 2014 at 12:36 PM - SCHEDULING-2195


I think BeanShell should be added to our script engines, I've seen it very present in frameworks like Taverna (scientific workflow system) and JMeter.

It is fully compatible with the Java Syntax unlike other scripting engines, with of course the addition of loose types. For example :

int addTwoNumbers( int a, int b ) { return a + b; }

sum = addTwoNumbers( 5, 7 ); // 12

activeeon-bot commented 10 years ago

Original comment posted by Fabien Viale on 31, Oct 2014 at 12:38 PM


You can as well implement interfaces anonymously :

ActionListener scriptedListener = new ActionListener() { actionPerformed( event ) { ... } }

activeeon-bot commented 10 years ago

Original comment posted by Fabien Viale on 31, Oct 2014 at 12:39 PM


You can both use typed syntax and loosely typed syntax :

Hashtable hashtable = new Hashtable(); Date date = new Date(); hashtable.put( "today", date );

or

hashtable = new Hashtable(); date = new Date(); hashtable.put( "today", date );

activeeon-bot commented 10 years ago

Original comment posted by Fabien Viale on 31, Oct 2014 at 12:40 PM


You can as well try/catch like in Java

try { int i = 1/0; } catch ( ArithmeticException e ) { print( e ); }

or with a loose type catch :

try { ... } catch ( e ) { print( "caught exception: "+e ); }

activeeon-bot commented 10 years ago

Original comment posted by Fabien Viale on 31, Oct 2014 at 12:41 PM


evrything is there, foreach loop syntax, boxing/autoboxing ,

activeeon-bot commented 10 years ago

Original comment posted by Youri Bonnaffe on 31, Oct 2014 at 13:50 PM


Groovy is also compatible with Java, it can probably already be used for everything you could do in Beanshell

activeeon-bot commented 10 years ago

Original comment posted by Fabien Viale on 31, Oct 2014 at 14:21 PM


It is not 100% compatible:

http://groovy.codehaus.org/Differences+from+Java

I didn't see that the for(String str : strings) kind of construct work in groovy, but maybe I'm wrong.

The try/catch statement works like in Java.

Of course you can do the same things in groovy than in beanshell, as in jruby, etc, ... It's not a feature problem, and it's true that groovy adds some very interesting constructs (like closures).

But groovy or jruby is not as known and widely used as Java, and for default examples, having a 100% Java compatible syntax makes sense, especially the ability to copy/paste java code without touching anything is a plus.