- Revision
- 584
- Author
- paul
- Date
- 2008-02-06 15:08:32 -0600 (Wed, 06 Feb 2008)
Log Message
as per Peter Kovac's suggestion
Modified Paths
Added Paths
Diff
Added: trunk/waffle-distribution/src/site/content/accessing-java-from-ruby.html (0 => 584)
--- trunk/waffle-distribution/src/site/content/accessing-java-from-ruby.html (rev 0) +++ trunk/waffle-distribution/src/site/content/accessing-java-from-ruby.html 2008-02-06 21:08:32 UTC (rev 584) @@ -0,0 +1,25 @@ +<!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> + +<body> + +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 /><br />public class MyRegistrar extends AbstractRubyAwareRegistrar {<br /><br /> public MyRegistrar(Registrar delegate) {<br /> super(delegate);<br /> }<br /><br /> @Override<br /> public void application() {<br /> register("the_dao", PersonDAOImpl.class);<br /><br /> registerRubyScript("person", "PersonController");<br /> }<br />}<br /><br />A +DAO, PersonDAOImpl, is registered under the name "the_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 +access to this DAO from the controller is easy in Waffle, just call the +locate method:<br />class PersonController<br /><br /> def index<br /> @person_dao = locate(example.PersonDAO)<br /><br /> @people = @person_dao.findAll<br /> render 'person.rhtml'<br /> end<br /><br />end<br /><br />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_<component +key>", here is the same controller using the locate_ convention:<br />class PersonController<br /><br /> def index<br /> @person_dao = locate_the_dao<br /><br /> @people = @person_dao.findAll<br /> render 'person.rhtml'<br /> end<br /><br />end<br /><br />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
Modified: trunk/waffle-distribution/src/site/content/sitemap.xml (583 => 584)
--- trunk/waffle-distribution/src/site/content/sitemap.xml 2008-02-06 21:05:06 UTC (rev 583) +++ trunk/waffle-distribution/src/site/content/sitemap.xml 2008-02-06 21:08:32 UTC (rev 584) @@ -46,6 +46,7 @@ <section> <name>Developing Ruby webapps</name> <page>ruby-controllers.html</page> + <page>accessing-java-from-ruby.html</page> <page>erb-views.html</page> </section> <section>
To unsubscribe from this list please visit:
