
I was super-excited this morning, when I saw the announcement that Google had released a Java version of their App Engine environment. My heart sank a bit when I read that they had a class white-list for security reasons, and told myself that I wouldn't be surprised if that means that you cant run Server-side JavaScript at all.
However, after reading Ola Bini's quick article on how to enable JRuby, I felt that it might be doable, after all, JS doesn't even have Threads (which more or less thankfully are disabled in GAE). It _should_ work.
So I went and downloaded the eclipse plugin, created a new project, which came with its own "Hello World" servlet and dropped the Mozilla labs JS version 1.7 jar (from the Dojo Ajax Toolkit's util/shrinksafe folder) into the lib/ folder of the GAE project, added some paths here and there -- and it worked.
I tried something really simple like this;
...
String s = "var foo = {foo: 17, bar: 4711}; foo.foo;";
Object result = cx.evaluateString(scope, s, "
resp.getWriter().println(Context.toString(result));
...
And out I got a
17
:)
I just saw that Google has limited the Java GAE SDK for the 10 first to register. I guess Sweden was the right place to be :) If you want to see my sample project, you can download it from here;
http://genericwitticism.com/rhino.zip
Cheers,
PS
11 comments:
Cool, Peter, now we got what we have been waiting for ! Was offline yesterday, and today, after googeling for appengine and rhino this was the top entry !
i almost can't wait to get home to try this out. unfortunately, i'll have to :(
@Roberto Saccon :) That's good to hear. Now I'll just try to find time to read in a file and to port the REST server interface I did for Babble/10gen.
@Ivan: Work is soon over! Time to play.
Nice to see another language work.
I wrote aboutn bringing up a sinatra app.
You can find it here.
http://blog.bigcurl.de
Thanks
Sam
It runs very well indeed. If you're seriously interested in running Rhino on App Engine, make sure you check out Helma NG, a compact yet powerful server-side JS runtime based on Rhino.
http://helma-ng.appspot.com/
@Hannes Wallnoefer: You're right of course. I hadn't even thought of that yet, having a lot to do. It all depends on what kind of magic Helma does with Java under the hood, since the GAE/J has a class whitelist. No dojox.tools, for example, and so on. No Threads stuff. But either it would work directly, or it will be possibly to do a 'Helma lite' och 'Helma GAE' version, I'm sure.
Thanks for the idea!
Peter, I think what Hannes meant is that helma-ng is already running well on App Engine.
Hannes has posted a howto on itAnd in his comment above is the link to the demo app running on appspot.
@Makrim Lin: You are right, of course. Maybe it wold help if I actually read what I was commenting :)
i have gone through your site information and it is the sae oppertunity that i was looking for thr facilities,
the process that what you are offering , are perfectely matched to my expection, very soon you will get
responce from my side
online job
JavaScript is a good program and very easy to use. I don´t like a complex program. I prefer javascript because i consider it like a device very eficient and it have a good quality.
I always looking for the quality that is why i prefer to buy viagra because i always have a great result in my sexual life.
Post a Comment