You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Don Brown <do...@gmail.com> on 2006/04/27 20:44:06 UTC
[proposal] JSExtensions - Integrating Java into Javascript
I propose a new commons sandbox project, JSExtensions, aimed at providing a
library of server-side Javascript (Rhino ATM) extensions that better
integrate Java into the Javascript environment. This is implemented in two
areas:
- Making the Java collections more natural to Javascript
- Extending the Java API to add convenience properties and methods
The inital code will come from Struts Flow[1], a Struts sandbox project that
brought server-side Javascript to Struts. In its development, I looked at
Groovy and saw how they improved the Java API [2] to make it better
integrated and more natural in the Groovy environment. I brought its ideas
over to Struts Flow [3], attempting to do the same for Javascript. This
code is better suited as an individual project, usable by other
Javascript-using Apache projects like Cocoon. In addition, these changes
make Javascript equally appropriate for standalone shell scripting-type
tasks.
As a quick example, here is the eachLine() extension method on the
java.io.File object, printing each line's contents to System.out:
file = new java.io.File("foo.txt");
file.eachLine(function(line) { print(line) });
To be clear, this proposal has nothing to do with client-side Javascript,
only server-side Javascript through Rhino and soon Java 6. The code already
runs and uses a special unit testing framework for testing. Looking forward
to the feedback.
Don
[1] http://struts.apache.org/struts-sandbox/struts-flow/
[2] http://groovy.codehaus.org/groovy-jdk.html
[3] http://struts.apache.org/struts-sandbox/struts-flow/FileExtensions.html(one
example)
Re: [proposal] JSExtensions - Integrating Java into Javascript
Posted by Martin Cooper <ma...@apache.org>.
On 4/27/06, Don Brown <do...@gmail.com> wrote:
>
> I propose a new commons sandbox project, JSExtensions, aimed at providing
> a
> library of server-side Javascript (Rhino ATM) extensions that better
> integrate Java into the Javascript environment. This is implemented in
> two
> areas:
>
> - Making the Java collections more natural to Javascript
> - Extending the Java API to add convenience properties and methods
Sounds fine to me. Interesting implementation, too. ;-)
--
Martin Cooper
The inital code will come from Struts Flow[1], a Struts sandbox project that
> brought server-side Javascript to Struts. In its development, I looked at
> Groovy and saw how they improved the Java API [2] to make it better
> integrated and more natural in the Groovy environment. I brought its
> ideas
> over to Struts Flow [3], attempting to do the same for Javascript. This
> code is better suited as an individual project, usable by other
> Javascript-using Apache projects like Cocoon. In addition, these changes
> make Javascript equally appropriate for standalone shell scripting-type
> tasks.
>
> As a quick example, here is the eachLine() extension method on the
> java.io.File object, printing each line's contents to System.out:
>
> file = new java.io.File("foo.txt");
> file.eachLine(function(line) { print(line) });
>
>
> To be clear, this proposal has nothing to do with client-side Javascript,
> only server-side Javascript through Rhino and soon Java 6. The code
> already
> runs and uses a special unit testing framework for testing. Looking
> forward
> to the feedback.
>
> Don
>
> [1] http://struts.apache.org/struts-sandbox/struts-flow/
> [2] http://groovy.codehaus.org/groovy-jdk.html
> [3]
> http://struts.apache.org/struts-sandbox/struts-flow/FileExtensions.html(one
> example)
>
>