RhinoLoaderRhinoLoaderRhinoLoader is a Java Classloader that can load Java classes from JavaScript scripts. The scripts are compiled to Java classes and executed using the Rhino JavaScript engine. The great benefit from this approach is that applications can be extended through scripting without using any Rhino or otherwise scripting specific APIs. The hosting application just uses the java.lang.ClassLoader and java.lang.Class API to get classes and instances as if it was dealing with ordinary Java classes. Class name to Script lookup follows a very simple resolution mechanism where class "foo.Bar" is resolved to path "foo/Bar.js". Subclassing other Java class or implementing Java interfaces is also straightforward. Just include something like this in your script:
The generated class can override Java methods simply by defining JavaScript functions with the method name. Note that functions that don't have a corresponding method in a Java class or Interface can't be invoked from Java, though. To invoke an overridden Java method from JavaScript use the super$ prefix:
A simple example is contained in the demo folder. To run it, just run ant target "demo":
DownloadYou can get RhinoLoader from the Subversion repository at http://dev.helma.org/svn/helma/branches/rhinoloader/, browse the code or download it here:
Pages linking to this page: Using Helma 2 as Library |
navigation
Download
Community
Weblog
Mailing Lists
IRC Channel
Documentation
Introductions
Tools
Reference
Project
Roadmap
Bug Reporting
Source
Helma NG Wiki
Wiki
Tags
Updates
Related Projects
Sites using Helma
Shop
search
tags for this page
all tags
Tagsapps (1) bugs (2) class (1) community (2) compatibility (1) concurrency (1) continuations (2) Documentation (6) dogfood (1) formatting (1) gobi (1) helma (6) helma 1.6 (13) helma 1.7 (8) helma 2 (11) helma ng (17) hopobject (1) html (1) inheritance (5) introspection (1) java (2) javascript (5) jetty (1) JSDoc (1) lazy (1) marius person (1) metaprogramming (2) modules (3) oop (1) organization (2) ORM (2) parsing (1) plugins (1) project (2) projects (1) prototype (1) Rabbit (2) Reference (1) REPL (1) rhino (4) roadmap (3) shell (1) shop (0) Skin Rendering (5) Snippets (1) source svn (1) sugar (3) templates (13) testing (4) Tobi (7) xml (1) Pages linking to this page: Wiki Overview Text Draft, wiki pages linking here
|