Title: [519] trunk/rails-integration/src/main/java/org/jruby/webapp: Add factory method for creating Rails, code by Jon Tirsen
Revision
519
Author
olabini
Date
2007-04-30 05:08:00 -0400 (Mon, 30 Apr 2007)

Log Message

Add factory method for creating Rails, code by Jon Tirsen

Modified Paths


Diff

Modified: trunk/rails-integration/src/main/java/org/jruby/webapp/AbstractRailsServlet.java (518 => 519)


--- trunk/rails-integration/src/main/java/org/jruby/webapp/AbstractRailsServlet.java	2007-04-28 07:23:00 UTC (rev 518)
+++ trunk/rails-integration/src/main/java/org/jruby/webapp/AbstractRailsServlet.java	2007-04-30 09:08:00 UTC (rev 519)
@@ -47,7 +47,7 @@
 		}
 
 		// create the factory
-		RailsFactory railsFactory = new RailsFactory();
+		RailsFactory railsFactory = createRailsFactory();
 		railsFactory.setRailsRoot(railsRoot);
 		railsFactory.setRailsEnvironment(getDeploymentEnvironment());
 		railsFactory.setServletContext(getServletContext());
@@ -63,7 +63,11 @@
 		createObjectPool(railsFactory);
 	}
 
-	public void destroy() {
+    protected RailsFactory createRailsFactory() {
+        return new RailsFactory();
+    }
+
+    public void destroy() {
 		try {
 			runtimePool.close();
 		} catch (Exception e) {

Modified: trunk/rails-integration/src/main/java/org/jruby/webapp/RailsFactory.java (518 => 519)


--- trunk/rails-integration/src/main/java/org/jruby/webapp/RailsFactory.java	2007-04-28 07:23:00 UTC (rev 518)
+++ trunk/rails-integration/src/main/java/org/jruby/webapp/RailsFactory.java	2007-04-30 09:08:00 UTC (rev 519)
@@ -83,7 +83,9 @@
 		Ruby runtime;
 		try {
 			long startTime = System.currentTimeMillis();
-			runtime = JavaEmbedUtils.initialize(loadPaths);
+            runtime = createRubyRuntime();
+            runtime.getLoadService().init(loadPaths);
+            runtime.getLoadService().require("java");
 			if (showLoadingInfo) log("JRuby init time: " + (System.currentTimeMillis() - startTime) + "ms");
 		} catch (RaiseException e) {
 			throw new ServletException("Failed to initialize JRuby", e);
@@ -148,7 +150,11 @@
 		return runtime;
 	}
 
-	public boolean validateObject(Object object) {
+    protected Ruby createRubyRuntime() {
+        return Ruby.getDefaultInstance();
+    }
+
+    public boolean validateObject(Object object) {
 		return true;
 	}
 
_______________________________________________
Jruby-extras-devel mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/jruby-extras-devel

Reply via email to