Scripting updates...

It has been a while. I've not updated on scripting.dev.java.net project and related activities. Here it is ...

You probably know this already, but just in case you missed: JavaFX Script has jsr-223 script engine for it (included in javafxrt.jar). See also:

Comments:

The original Rhino defined a 'load()' function that allowed you to bring in symbols from a different script file to your scope. I've been huntring around for an equivalent in the Java 6 (or 7) implementation but am coming up short. Any pointers? Or is it something we should just copy-n-paste over :-) Chris

Posted by Chris Winters on June 07, 2007 at 07:07 PM IST #

There is no built-in "load" function to load scripts from files/URLs. But, it is possible to write one - the trick is to expose current engine object as a variable and call ScriptEngine.eval overloads to load scripts from URLs, Files or Strings. Or it is possible to use JavaScript built-in "eval" function. Within "jrunscript" tool there is a load function. You may want to consult the source code of "jrunscript" tool from openjdk.

Posted by A. Sundararajan on June 08, 2007 at 02:31 AM IST #

I see. I'm curious as to why it was left out from Rhino as it's pretty useful -- even though it's fairly straightforward to roll your own :-) Are there tricky security implications? Was Rhino's implementation buggy? Or was it deemed just not necessary?

Posted by Chris Winters on June 08, 2007 at 11:42 AM IST #

No, Rhino core never had "load" function. Only Rhino shell tool (whose language independent equivalent is jrunscript in JDK 6) has the "load" function defined. As for security is concerned, the usual Java networking policy [for remote loading of scripts] and file system policy [for file scripts] will be used. There is one tricky issue though -- let us say, you are writing a browser like app in Java with support for JavaScript [or any jsr-223 compliant language] and your app could load scripts from multiple sites. You may want to attach permission set based on script origin site -- much like applets are constrained by applet origin. This is really tricky. I guess you need to work with explicit AccessControlContexts/DomainCombiner/doPrivileged etc.

Posted by A. Sundararajan on June 08, 2007 at 01:25 PM IST #

Post a Comment:
Comments are closed for this entry.
About

sundararajan

Search

Archives
« July 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
  
       
Today
Bookmarks
Links

No bookmarks in folder

Blogroll

No bookmarks in folder

News

No bookmarks in folder