Title: [waffle-scm] [586] trunk/waffle-distribution/src/site/content/accessing-java-from-ruby.html: words and style
Revision
586
Author
paul
Date
2008-02-07 00:06:52 -0600 (Thu, 07 Feb 2008)

Log Message

words and style

Modified Paths


Diff

Modified: trunk/waffle-distribution/src/site/content/accessing-java-from-ruby.html (585 => 586)

--- trunk/waffle-distribution/src/site/content/accessing-java-from-ruby.html	2008-02-07 05:47:31 UTC (rev 585)
+++ trunk/waffle-distribution/src/site/content/accessing-java-from-ruby.html	2008-02-07 06:06:52 UTC (rev 586)
@@ -1,24 +1,55 @@
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html><head><meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type" />
-<title>Accessing Java from Ruby</title></head>
+<html><head>
+<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type" /><title>Accessing Java from Ruby</title>
+
+</head>
 <body>
+<h2>Access your Java components from&nbsp;Ruby Actions.</h2>
+Here we examine Ruby based controllers, and the invoking of Java
+functionaility from them. Consider:<br />
+<textarea class="java:nogutter:nocontrols" name="code">
+public class MyRegistrar extends AbstractRubyAwareRegistrar {
+&nbsp; public MyRegistrar(Registrar delegate) {
+&nbsp;&nbsp;&nbsp; super(delegate);
+&nbsp; }
 
-Waffle: How to access your Java components from your Ruby Actions.<br /><br />In
-my last post I gave an overview of how you can easily integrate JRuby
-with Waffle. Now we will examine Ruby based controller in a bit more
-depth. Lets assume we have the following Waffle Registrar for our
-application:<br /><pre>public class MyRegistrar extends AbstractRubyAwareRegistrar {<br />&nbsp; public MyRegistrar(Registrar delegate) {<br />&nbsp;&nbsp;&nbsp; super(delegate);<br />&nbsp; }</pre><pre><br />&nbsp; @Override<br />&nbsp; public void application() {<br />&nbsp;&nbsp;&nbsp; register("the_dao", PersonDAOImpl.class);<br />&nbsp;&nbsp;&nbsp; registerRubyScript("person", "PersonController");<br />&nbsp; }<br />}</pre>A
-DAO, PersonDAOImpl, is registered under the name "the_dao" and we have
+&nbsp;@Override
+&nbsp; public void application() {
+&nbsp;&nbsp;&nbsp;register("person_dao", PersonDAOImpl.class);
+&nbsp;&nbsp;&nbsp; registerRubyScript("person", "PersonController");
+&nbsp; }
+}</textarea>
+A
+DAO, PersonDAOImpl, is registered under the name "person_dao" and we
+have
 one Ruby based controller available. Now its probably safe to assume
-that this Ruby PersonController will need access to the DAO. Gaining
+that this Ruby PersonController will need access to that DAO object.
+Gaining
 access to this DAO from the controller is easy in Waffle, just call the
-locate method:<br /><pre>class PersonController<br />&nbsp; def index<br />&nbsp;&nbsp;&nbsp; @person_dao = locate(example.PersonDAO)<br />&nbsp;&nbsp;&nbsp; @people = @person_dao.findAll<br />&nbsp;&nbsp;&nbsp; render 'person.rhtml'<br />&nbsp; end<br />end</pre>Notice
+locate method:<br />
+<textarea class="java:nogutter:nocontrols" name="code">
+class PersonController
+&nbsp; def index
+&nbsp;&nbsp;&nbsp; @person_dao = locate(example.PersonDAO)
+&nbsp;&nbsp;&nbsp; @people = @person_dao.findAll
+&nbsp;&nbsp;&nbsp; render 'person.rhtml'
+&nbsp;end
+end</textarea>
+Notice
 that we were able to retrieve the DAO by its interface. Additionally,
 since this DAO was registered with a key you can use a convention to
 retrieve the component. The convention is "locate_&lt;component
-key&gt;", here is the same controller using the locate_ convention:<br /><pre>class PersonController<br />&nbsp; def index<br />&nbsp;&nbsp;&nbsp; @person_dao = locate_the_dao<br />&nbsp;&nbsp;&nbsp; @people = @person_dao.findAll<br />&nbsp;&nbsp;&nbsp; render 'person.rhtml'<br />&nbsp; end<br />end</pre>As
+key&gt;", here is the same controller using the locate_ convention:<br />
+<textarea class="java:nogutter:nocontrols" name="code">class
+PersonController
+&nbsp; def index
+&nbsp;&nbsp;&nbsp; @person_dao = locate_person_dao
+&nbsp;&nbsp;&nbsp; @people = @person_dao.findAll
+&nbsp;&nbsp;&nbsp; render 'person.rhtml'
+&nbsp;end
+end</textarea>
+As
 you can see this makes writing Ruby based Controllers/Actions with
 Waffle really easy. In my next post I'll detail how to access request
 parameter and context attributes with ease.
-
 </body></html>
\ No newline at end of file


To unsubscribe from this list please visit:

http://xircles.codehaus.org/manage_email

Reply via email to