ruby-on-railstomcatjrubywarbler

Using Java to change ruby views


I have a program written in jruby that is deployed on a tomcat server. Everything about the program works fine except I cannot figure out a way to notify the user when the java processes have been completed. Java does most of the heavy lifting of the program and I want a ruby view to pop up saying that the processing has been finished. The closest I got was to use an http get request to try and show the "show" view within ruby but it appears to not work, I'm assuming because it is functioning in a different program runtime.
Is there anyway that upon completion of server tomcat java code to invoke a ruby view change on a client machine.

Edit: The ruby code runs in parallel as well as the java code. The java code converges into one output but the ruby code doesn't converge and mainly just runs the java code and deals with the front end.


Solution

  • JRuby has Java-Integration and depending on how you Java classes are "shared" (or not) on Tomcat you can have access to such classes from within the Rails app. the question is mostly about designing such a solution to fit, which is hard to tell without knowing the exact requirements.

    you would obviously need to share some state (global) between the two apps (assuming different contexts). be it a semaphore or an atomic flag. check out Java concurrent utilities - although if you do not want polling on Ruby's end it might end up a bit tight coupled.

    maybe try gaining the servlet-context from one app to another and exporting a shared state (e.g. a queue object) or simply send a request using a dispatcher from the Java context to the Rails one.