Scripting example and demo

I wrote up some things on my first go at implementing scripting here:

http://www.darkstarusers.com/news/2007/04/02/scripting-darkstar-using-groovy-part-0/

It shows interactive evaluation as well as adding a script to an object and executing it based on a user generated event.

If you have problems connecting via the applet, you can connect old-skool style via telnet at darkstarusers.com 4000. If you have any ideas about what might be wrong with the applet, let me know. It seems some people can use it and some can’t.

I just thought I would throw out a little issue I “discovered” when trying to use the javax.scripting API. By “discovered” I mean read the documentation :slight_smile: It does not appear possible to use Java security with the javax.scripting implementation, specifically when dealing with a script that is interpreted without being loaded from a particular location.

For example, with the native Groovy interface, you can do something like this:


  String script="println('Hello World');";
  GroovyCodeSource src =  new GroovyCodeSource(script,"someScript", "/sandbox");
  new GroovyShell().parse(src);

Where “/sandbox” is a codebase you can configure via a java.security.policy like


grant codeBase "file:/sandbox" {
  //don't grant anything! 
};

With the javax.scripting API, there is no way to specify a codebase in which you would like a random script to executed. This may or may not be a problem depending on who you want to have access to scripting of course.

You might want to RFE this over in the official Java bug database.