Title: [590] trunk/rails-integration/src/main/java/org/jruby/webapp/RailsTaskServlet.java: Added RailsTaskServlet that makes it possible to run other Rails tasks such as for example ActiveMessaging
- Revision
- 590
- Author
- tirsen
- Date
- 2007-05-16 04:25:47 -0400 (Wed, 16 May 2007)
Log Message
Added RailsTaskServlet that makes it possible to run other Rails tasks such as for example ActiveMessaging
Added Paths
Diff
Added: trunk/rails-integration/src/main/java/org/jruby/webapp/RailsTaskServlet.java (0 => 590)
--- trunk/rails-integration/src/main/java/org/jruby/webapp/RailsTaskServlet.java (rev 0)
+++ trunk/rails-integration/src/main/java/org/jruby/webapp/RailsTaskServlet.java 2007-05-16 08:25:47 UTC (rev 590)
@@ -0,0 +1,38 @@
+package org.jruby.webapp;
+
+import org.jruby.Ruby;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+public class RailsTaskServlet extends RailsServlet {
+ public void init(final ServletConfig servletConfig) throws ServletException {
+ super.init(servletConfig);
+ final String script = servletConfig.getInitParameter("script");
+ new Thread(new Runnable() {
+ public void run() {
+ try {
+ while (true) {
+ Ruby runtime = (Ruby) getRuntimePool().borrowObject();
+ servletConfig.getServletContext().log("Starting " + script);
+ try {
+ runtime.evalScript("load(RAILS_ROOT + '/" + script + "')");
+ } catch (Exception e) {
+ servletConfig.getServletContext().log("Script died, restarting: " + script, e);
+ getRuntimePool().invalidateObject(runtime);
+ }
+ }
+ } catch (Exception e) {
+ servletConfig.getServletContext().log("Could not start " + script, e);
+ }
+ }
+ }).start();
+ }
+
+ protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ throw new ServletException("Not supported");
+ }
+}
_______________________________________________
Jruby-extras-devel mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/jruby-extras-devel