- Revision
- 706
- Author
- mauro
- Date
- 2008-06-14 06:07:15 -0500 (Sat, 14 Jun 2008)
Log Message
Updated ruby docs.
Modified Paths
- trunk/waffle-core/src/main/java/org/codehaus/waffle/registrar/ScriptedRegistrar.java
- trunk/waffle-distribution/src/site/content/sitemap.xml
Added Paths
- trunk/waffle-distribution/src/site/content/ruby/
- trunk/waffle-distribution/src/site/content/ruby/erb-views.html
- trunk/waffle-distribution/src/site/content/ruby/from-java-to-ruby.html
- trunk/waffle-distribution/src/site/content/ruby/ruby-controllers.html
Removed Paths
Diff
Modified: trunk/waffle-core/src/main/java/org/codehaus/waffle/registrar/ScriptedRegistrar.java (705 => 706)
--- trunk/waffle-core/src/main/java/org/codehaus/waffle/registrar/ScriptedRegistrar.java 2008-06-14 09:07:32 UTC (rev 705) +++ trunk/waffle-core/src/main/java/org/codehaus/waffle/registrar/ScriptedRegistrar.java 2008-06-14 11:07:15 UTC (rev 706) @@ -20,9 +20,9 @@ /** * Register a script with Waffle * - * @param key the name this script should be registred under - * @param className represent the name of the script class being registred + * @param key the key this script should be registred under + * @param scriptedClassName represent the name of the scripted class being registered */ - void registerScript(String key, String className); + void registerScript(String key, String scriptedClassName); }
Deleted: trunk/waffle-distribution/src/site/content/accessing-java-from-ruby.html (705 => 706)
--- trunk/waffle-distribution/src/site/content/accessing-java-from-ruby.html 2008-06-14 09:07:32 UTC (rev 705) +++ trunk/waffle-distribution/src/site/content/accessing-java-from-ruby.html 2008-06-14 11:07:15 UTC (rev 706) @@ -1,55 +0,0 @@ -<!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> -<h2>Access your Java components from 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 { - public MyRegistrar(Registrar delegate) { - super(delegate); - } - - @Override - public void application() { - register("person_dao", PersonDAOImpl.class); - registerRubyScript("person", "PersonController"); - } -}</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 that DAO object. -Gaining -access to this DAO from the controller is easy in Waffle, just call the -locate method:<br /> -<textarea class="ruby:nogutter:nocontrols" name="code"> -class PersonController - def index - @person_dao = locate(example.PersonDAO) - @people = @person_dao.findAll - render 'person.rhtml' - 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_<component -key>", here is the same controller using the locate_ convention:<br /> -<textarea class="ruby:nogutter:nocontrols" name="code">class -PersonController - def index - @person_dao = locate_person_dao - @people = @person_dao.findAll - render 'person.rhtml' - 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
Deleted: trunk/waffle-distribution/src/site/content/erb-views.html (705 => 706)
--- trunk/waffle-distribution/src/site/content/erb-views.html 2008-06-14 09:07:32 UTC (rev 705) +++ trunk/waffle-distribution/src/site/content/erb-views.html 2008-06-14 11:07:15 UTC (rev 706) @@ -1,14 +0,0 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> -<html> -<head> -<title>ERB Views</title> -</head> -<body> - -<h2>ERB Views</h2> - -<p>Waffle allows your views to be developed with ERB. Detailed documentation will be available soon.</p> - -</body> - -</html>
Copied: trunk/waffle-distribution/src/site/content/ruby/erb-views.html (from rev 702, trunk/waffle-distribution/src/site/content/erb-views.html) (0 => 706)
--- trunk/waffle-distribution/src/site/content/ruby/erb-views.html (rev 0) +++ trunk/waffle-distribution/src/site/content/ruby/erb-views.html 2008-06-14 11:07:15 UTC (rev 706) @@ -0,0 +1,14 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<html> +<head> +<title>ERB Views</title> +</head> +<body> + +<h2>ERB Views</h2> + +<p>Waffle allows your views to be developed with ERB. Detailed documentation will be available soon.</p> + +</body> + +</html>
Added: trunk/waffle-distribution/src/site/content/ruby/from-java-to-ruby.html (0 => 706)
--- trunk/waffle-distribution/src/site/content/ruby/from-java-to-ruby.html (rev 0) +++ trunk/waffle-distribution/src/site/content/ruby/from-java-to-ruby.html 2008-06-14 11:07:15 UTC (rev 706) @@ -0,0 +1,51 @@ +<!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>From Java to Ruby</title> + +</head> +<body> +<h2>Accessing Java components in Ruby controllers.</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 RubyScriptedRegistrar { + public MyRegistrar(Registrar delegate) { + super(delegate); + } + + @Override + public void application() { + register("person_dao", PersonDAOImpl.class); + registerScript("person", "PersonController"); + } +}</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 that DAO object. Gaining access to this DAO +from the controller is easy in Waffle, by invoking the <b>locate</b> method: +<br /> +<textarea class="ruby:nogutter:nocontrols" name="code"> +class PersonController + def index + @person_dao = locate(example.PersonDAO) + @people = @person_dao.findAll + render 'person.rhtml' + 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. +<blockquote> +<b>The convention is that "locate_<component key>" method is used by the controller to locate and retrieve a Java component by key.</b> +</blockquote> +<textarea class="ruby:nogutter:nocontrols" name="code">class +PersonController + def index + @person_dao = locate_person_dao + @people = @person_dao.findAll + render 'person.rhtml' + end +end</textarea> +As you can see this makes writing Ruby-based controllers with Waffle really easy. +</body> +</html> \ No newline at end of file
Copied: trunk/waffle-distribution/src/site/content/ruby/ruby-controllers.html (from rev 702, trunk/waffle-distribution/src/site/content/ruby-controllers.html) (0 => 706)
--- trunk/waffle-distribution/src/site/content/ruby/ruby-controllers.html (rev 0) +++ trunk/waffle-distribution/src/site/content/ruby/ruby-controllers.html 2008-06-14 11:07:15 UTC (rev 706) @@ -0,0 +1,79 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<html> +<head> +<title>Ruby Controllers</title> +</head> +<body> +<h2>Writing Waffle controllers in Ruby</h2> +Waffle provides built in support for Ruby, allowing you to easily write your controllers in Ruby. The integration is +simple and straightforward, taking advantage of functionality Waffle provides (without the Rails!). +<br /> +A key feature of Waffle has always been its pluggable architecture. From the beginning we believed that the default +behavior defined by the Waffle team might not be suitable for every situation. Therefor Waffle was built following an +Interface driven approach. Practically all of Waffle's built-in functionality can easily be extended or replaced. This +design made integrating Ruby support quite easy. The next 4 steps give a brief overview of how to integrate Ruby support +into your Waffle based applications. +<br /> +<br /> +<span style="font-weight: bold;">Step 1</span> +- Ensure dependency on waffle-ruby module +<textarea class="xml:nogutter:nocontrols" name="code"><context-param> + <dependency> + <groupId>org.codehaus.waffle</groupId> + <artifactId>waffle-ruby</artifactId> + <version>[version]</version> + </dependency> +</textarea> +<br /> +<span style="font-weight: bold;">Step 2</span> +- configure Waffle to be "Ruby Aware" +<br /> +<br /> +Waffle avoids XML like the plague but we still need to have a web.xml for our applications. This web.xml is where we can +take advantage of Waffle's pluggability. The following three context-param nodes need to be added to your applications +web.xml. This alerts Waffle that a few of its foundational components should be replaced with alternate implementations. + +<textarea class="xml:nogutter:nocontrols" name="code"><context-param> + <param-name>org.codehaus.waffle.context.ContextContainerFactory</param-name> + <param-value>org.codehaus.waffle.context.pico.RubyPicoContextContainerFactory</param-value> +</context-param> +<context-param> + <param-name>org.codehaus.waffle.bind.ControllerControllerDataBinder</param-name> + <param-value>org.codehaus.waffle.bind.RubyControllerControllerDataBinder</param-value> +</context-param> +<context-param> + <param-name>org.codehaus.waffle.controller.ControllerDefinitionFactory</param-name> + <param-value>org.codehaus.waffle.controller.RubyControllerDefinitionFactory</param-value> +</context-param></textarea> +<span style="font-weight: bold;">Step 3</span> +- Your application's Registrar should extended +<a href="" +to register your script as a controller: +<br /> +<textarea class="java:nogutter:nocontrols" name="code">public class MyRegistrar extends RubyScriptedRegistrar { + public MyRegistrar(Registrar delegate) { + super(delegate); + } + @Override + public void application() { + registerScript("foobar", "FooBar"); + } + ... +}</textarea> +In this example the Ruby class named 'FooBar' will be exposed as a controller under the name 'foobar' (e.g. +http://localhost:8080/ruby-webapp/foobar.waffle). +<br /> +<br /> +<span style="font-weight: bold;">Step 4</span> +- Write your Ruby controller class. Notice in the following example that your class does not need to extend or include +anything. + +<textarea class="ruby:nogutter:nocontrols" name="code">class FooBar + def index # This is the default action + "<h1>Hello World</h1>" + end +end</textarea> +And that is all the steps required to integrate Ruby within your Waffle Applications. + +</body> +</html> \ No newline at end of file
Deleted: trunk/waffle-distribution/src/site/content/ruby-controllers.html (705 => 706)
--- trunk/waffle-distribution/src/site/content/ruby-controllers.html 2008-06-14 09:07:32 UTC (rev 705) +++ trunk/waffle-distribution/src/site/content/ruby-controllers.html 2008-06-14 11:07:15 UTC (rev 706) @@ -1,78 +0,0 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> -<html> -<head> -<title>Ruby Controllers</title> -</head> -<body> -<h2>Utilizing Ruby in a Waffle web application</h2> -Waffle now provides built in support for Ruby. This will allow you to easily write your Controllers in Ruby. The -integration is simple and straightforward, taking advantage of functionality Waffle provides (without being a Rails -clone). -<br /> -<br /> -A key feature of Waffle has always been its pluggable architecture. From the beginning we believed that the default -behavior defined by the Waffle team might not be suitable for every situation. Therefor Waffle was built following an -Interface driven approach. Practically all of Waffle's built-in functionality can easily be extended or replaced. This -design made integrating Ruby support quite easy. The next 3 steps give a brief overview of how to integrate Ruby -support into your Waffle based applications. -<br /> -<br /> -<span style="font-weight: bold;">Step 0</span> -- Ensure dependency on waffle-ruby module -<br /> -<span style="font-weight: bold;">Step 1</span> -- configure Waffle to be "Script Aware" -<br /> -<br /> -Waffle avoids XML like the plague but we still need to have a web.xml for our applications. This web.xml is where we can -take advantage of Waffle's pluggability. The following three context-param nodes need to be added to your applications -web.xml. This alerts Waffle that a few of its foundational components should be replaced with alternate implementations. - -<textarea class="xml:nogutter:nocontrols" name="code"><context-param> - <param-name>org.codehaus.waffle.context.ContextContainerFactory</param-name> - <param-value>org.codehaus.waffle.context.pico.RubyPicoContextContainerFactory</param-value> -</context-param> -<context-param> - <param-name>org.codehaus.waffle.bind.ControllerControllerDataBinder</param-name> - <param-value>org.codehaus.waffle.bind.RubyControllerControllerDataBinder</param-value> -</context-param> -<context-param> - <param-name>org.codehaus.waffle.controller.ControllerDefinitionFactory</param-name> - <param-value>org.codehaus.waffle.controller.RubyControllerDefinitionFactory</param-value> -</context-param></textarea> -<span style="font-weight: bold;">Step 2</span> -- Your application's Registrar should extended <a href="" -<br /> -<br /> -This exposes a new registration method to use within your Registrar ... registerScript(String key, String -className). See the example below: - -<textarea class="java:nogutter:nocontrols" name="code">public class MyRegistrar extends AbstractScriptedRegistrar { - public MyRegistrar(Registrar delegate) { - super(delegate); - } - @Override - public void application() { - registerScript("foobar", "FooBar"); - } - ... -}</textarea> -In this example the Ruby class named 'FooBar' will be exposed as a Controller under the name 'foobar' (e.g. -http://localhost:8080/ruby/foobar.waffle). -<br /> -<br /> -<span style="font-weight: bold;">Step 3</span> -- Write your Ruby Controller class. Notice in the following example that your class does not need to extend or include -anything. - -<textarea class="ruby:nogutter:nocontrols" name="code">class FooBar - def index # This is the default action - "<h1>Hello World</h1>" - end -end</textarea> -And that is all the steps required to integrate Ruby within your Waffle Applications. - -<h3>Why are Ruby controllers desirable?</h3> -TODO -</body> -</html> \ No newline at end of file
Modified: trunk/waffle-distribution/src/site/content/sitemap.xml (705 => 706)
--- trunk/waffle-distribution/src/site/content/sitemap.xml 2008-06-14 09:07:32 UTC (rev 705) +++ trunk/waffle-distribution/src/site/content/sitemap.xml 2008-06-14 11:07:15 UTC (rev 706) @@ -8,7 +8,7 @@ <page>release-notes.html</page> </section> <section> - <name>Developing Java web apps</name> + <name>Developing Java Webapps</name> <page>action-controllers.html</page> <page>action-methods.html</page> <page>interceptors.html</page> @@ -27,10 +27,10 @@ <page>webapp-structure.html</page> </section> <section> - <name>Developing Ruby web apps</name> - <page>ruby-controllers.html</page> - <page>accessing-java-from-ruby.html</page> - <page>erb-views.html</page> + <name>Developing Scripted Webapps</name> + <page>ruby/ruby-controllers.html</page> + <page>ruby/from-java-to-ruby.html</page> + <page>ruby/erb-views.html</page> </section> <section> <name>Web 2.0</name>
To unsubscribe from this list please visit:
