Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run node-js from Java or Groovy

anyone experimented on how to run node.js module or a script from java or groovy?

Could groovy command.execute() do it? If so then would it behave the same across different op sys.

Worth noting is that ideally, I would like that node.js would not be depended upon installation in the system and node command, but but packaged via ./configure and make, so that it could be used as a library..

Thanks

Edit: Basically I want this so that I could use node.js module, a client side framework(coffee-script, jade,stylus etc. And this is bundeled in Brunch), as a Grails plugin. So that the plugin is self-contained with no system dependency.

like image 759
Jor Avatar asked Feb 02 '12 20:02

Jor


1 Answers

You might find what you're looking for in vert.x.

From the site:

What is vert.x?

The next generation polyglot asynchronous application framework. (Formerly known as node.x)

  • Runs on the JVM.
  • Embraces the good bits of event driven frameworks like node.js then adds some even juicier bits.
  • Everything is non-blocking.
  • Polyglot. vert.x will be usable from multiple languages: Ruby, Groovy, Java, JavaScript, Python, Clojure, Scala. Currently we support Java and Ruby and have partial Groovy support. Write your code in the language you choose. Leverage the power of vert.x from that language.
  • Goes with the recent developments with InvokeDynamic in Java 7 and bets on the JVM being the future premier runtime for dynamic languages.
  • Enables you to create network servers or clients incredibly easily.
  • True scalability. Unlike other well-known event-driven frameworks, you can have more than one event loop per process. No more spinning up 32 instances just to utilise the cores on your server.
  • Incredibly simple concurrency model. Write your code as single threaded but watch it scale across multiple cores. No need to worry about race conditions or locks.
  • Understands multiple network protocols out of the box including: TCP, SSL, HTTP, HTTPS, Websockets.
  • Efficiently serve static files from the filesystem bypassing user-space altogether.
  • Simple Sinatra/Express style resource based web routing.
  • Distributed event bus. Multiple vert.x instances work together seamlessly to provide a distributed event bus
  • SockJS support
like image 146
Nicholas Avatar answered Oct 08 '22 11:10

Nicholas