Re: BeanShell javax.script (JSR-223) adapter impl...

Mark Swanson <mark-e2GstmqqWGa5mcYau+xr2AC/[email protected]> Mon, 13 Jun 2005 22:33:21 -0400
Newsgroups gmane.comp.java.beanshell.devel
Message-ID <[email protected]>
Patrick Niemeyer wrote:
> If anyone is interested in playing with the javax.script API I've put up 
> a snapshot for you here:

I've integrated BeahShell with jsr223 into ScheduleWorld (unsigned JWS 
environment) and it works fine. Neat. I pasted some of your test code 
from BeanShell/engine/src/TestBshScriptEngine.java and the output I 
receive is:

Could not init static:java.security.AccessControlException: access 
denied (java.util.PropertyPermission debug read)
Passed...
Passed...
Passed...
Passed...
Passed...
Passed...
Passed...
Passed...
Passed...
Passed...

Interestingly, the javax.script jar file you provided us contains 
different constructors than the official JSR (ClassLoader arg to 
ScriptEngineManager). Probably a good thing I'm just wondering how much 
has changed.

Some neat JWS facts: It's in the sandbox, the bsh/script jar files are 
not downloaded (lazy) unless I actually execute bsh code (so I can 
dynamically enable this capability without penalizing others who never 
want to run scripts - unless I make scripts mandatory at some point).

Also, with pack200 bsh is 142953 bytes, and javax.script is 8508 bytes. 
~150KB is a pretty small footprint for some excellent scripting 
capability. (JDK1.5 folks auto-grab the pack.gz files and JDk1.4 folks 
grab the much larger ones - all taken care of by JWS).

It's also interesting that the scripting environment is very secure. 
F.E. scripts can not use reflection to grab protected or private 
information from ScheduleWorld internals. The ScheduleWorld public 
interface was designed to take advantage of this and provide the 
scripting environment access to public interfaces and depending on the 
security level of the user the scripting interface gets a read-only 
Object (F.E. iCalendar Event) or a read/write Object - or perhaps I'll 
always grant scripting read-only access to objects except when manually 
granted read-write access.

The nice thing about this is that you can't cast away const correctness 
like you can in any other language. It's a water-tight solution to the 
problem of having read-only or read-write access to objects.

Since I'm rambling the BSH environment will have access to full 
iCalendar Object model and will be able to do things that users have 
been requesting for some time - like writing small scripts to output 
iCalendar data in custom formats so they can get the data into packages 
to print large tournament schedules on the gym wall.

The new features in Java 6 will allow folks to create export scripts to 
integrate with timesheet applications, accounting applications, and more 
via TCP (yes, even from the sandbox). Well, if Sun fixes the bug I 
reported as it still has a dual-DNS-lookup problem. Anyway...

The bsh ClassLoader rules should allow me to create a public and private 
repository (via HTTP/XSD - eventually SOAP wrapped) of BSH scripts so 
folks can go wild with scripting if they so desire. It will be 
interesting to see what folks come up with over the next few years.

I'll post to the list if the existing ClassLoader support is good enough 
to let me do this or not. From previous posts to the list it seems Pat 
has done this correctly. I'm actually anxious to see if it works out in 
practice.

One last thing: It's about time BeanShell is approaching the tipping 
point. With sandbox support, JSR223 support, the BeanShell JSR, and JWS 
fixes (finally) in 1.5.0[2] it's all coming together. I personally think 
the future is very bright - exciting even.

Cheers.


-- 
Free replacement for Exchange and Outlook (Contacts and Calendar)
http://www.ScheduleWorld.com/
WAP: http://www.ScheduleWorld.com/sw/WAPToday?id=4000&tz=EST
WebDAV: http://www.ScheduleWorld.com/sw/webDAVDir/4000.ics
VFREEBUSY: http://www.ScheduleWorld.com/sw/freebusy/4000.ifb


-------------------------------------------------------
This SF.Net email is sponsored by: NEC IT Guy Games.  How far can you shotput
a projector? How fast can you ride your desk chair down the office luge track?
If you want to score the big prize, get to know the little guy.  
Play to win an NEC 61" plasma display: http://www.necitguy.com/?r=20