Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Introducing RhinoLoader

6 views
Skip to first unread message

hannes wallnoefer

unread,
Nov 28, 2006, 6:04:56 AM11/28/06
to
As a byproduct of my work on Helma, I came up with a neat way of
extending Java applications with Rhino/JS. I called it RhinoLoader,
it's simply a java classloader that creates classes from javascript
files. See this page for details and code:

http://dev.helma.org/Wiki/RhinoLoader/

One thing I've tested it with is to create/mount JS-implemented
servlets and servlet filters in Jetty simply from the XML config file
(using Context.setClassLoader(), Context.addServlet(),
Context.addFilter()), and it worked very well.

The RhinoLoader class is currently pretty minimal, for real world usage
it would probably need some hooks to access the scope object, configure
the rhino context, and so on.

I don't think it makes much sense to maintain and distribute this as
standalone package, so I'd be happy if it (or something similar) could
be included with Rhino. What does everybody think?

Hannes

fch...@netbeans.jp

unread,
Nov 28, 2006, 7:18:58 AM11/28/06
to dev-tech-...@lists.mozilla.org
Hi Hannes,
Looks interesting! If you could let those abitery functions be executed
from Java, it would be great though. But that's not the point now, isn't
it;)

David Fu
--
firecat server-side javascript webserver
http://firecat.nihonsoft.org
http://blog.netbeans.jp/roller/page/fchoong

> _______________________________________________
> dev-tech-js-engine mailing list
> dev-tech-...@lists.mozilla.org
> https://lists.mozilla.org/listinfo/dev-tech-js-engine
>

hannes wallnoefer

unread,
Nov 28, 2006, 7:55:31 AM11/28/06
to
fch...@netbeans.jp schrieb:

> Looks interesting! If you could let those abitery functions be executed
> from Java, it would be great though. But that's not the point now, isn't
> it;)

For JS functions to be callable from Java, they'd need a Java method
declaration including parameter types, return types, accessibility,
thrown exceptions. You just can't do that (easily) with JavaScript.
Furthermore, the class then had to be around at compile time, which is
not the case with RhinoLoader.

The usage scenario for RhinoLoader is to have an interface (or base
class) on which the Java application operates, and have RhinoLoader
create a class that implements the interface (or extends the base
class) at runtime.

hannes

fch...@netbeans.jp

unread,
Nov 28, 2006, 8:43:41 PM11/28/06
to dev-tech-...@lists.mozilla.org
Hi Hannes,
That is what I thought it was for, so the abitery function invocation was
not really what you were looking for anyway. Still pretty useful!

David Fu
--
firecat server-side javascript webserver
http://firecat.nihonsoft.org
http://blog.netbeans.jp/roller/page/fchoong

> fch...@netbeans.jp schrieb:

0 new messages