Hi all,
There has been some discussion about supporting JavaScript in Wildfly/Undertow for a while
now, and as a result I have come up with a simple proof of concept of the form I think
this support could take.
The form that this is taking is undertow.js, which is a jar file that you can include in
your apps and allows you to register JavaScript based handlers. These handlers can be
mapped to URL's, and inject container resources such as CDI beans and JNDI data
sources. It also provide some simple JavaScript wrappers to make some EE objects easier to
use from scripts.
Injection support is pluggable, and this can be used programatically from embedded
Undertow.
At the moment handlers are mainly useful as REST endpoints, although if there is interest
I am planning on adding template engine support as well.
When using Wildfly upstream's new external resources feature this allows for changes
in your script files to be immediately visible, without even needing to copy to an
exploded deployment.
I envisage the main use of this will not be creating node.js like apps that are pure
javascript, but rather to allow simpler parts of the of a mostly Java app to be written in
JavaScript, providing a hybrid approach and this avoiding the compile+redeploy cycle for
the javascript parts.
Full details are here:
https://github.com/undertow-io/undertow.js
I have an example of the Kitchen Sink Wildfly quickstart that has been re-done to use this
here:
https://github.com/wildfly/quickstart/compare/master...stuartwdouglas:js#...
At this stage I am really not sure how this will evolve, or if it will go anywhere, I am
just putting it out there to get some feedback.
Stuart