commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simonetrip...@apache.org
Subject svn commit: r1078287 - /commons/sandbox/digester3/trunk/src/site/xdoc/guide/dvsd3.xml
Date Sat, 05 Mar 2011 13:45:02 GMT
Author: simonetripodi
Date: Sat Mar  5 13:45:01 2011
New Revision: 1078287

URL: http://svn.apache.org/viewvc?rev=1078287&view=rev
Log:
added universal loader description

Modified:
    commons/sandbox/digester3/trunk/src/site/xdoc/guide/dvsd3.xml

Modified: commons/sandbox/digester3/trunk/src/site/xdoc/guide/dvsd3.xml
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/site/xdoc/guide/dvsd3.xml?rev=1078287&r1=1078286&r2=1078287&view=diff
==============================================================================
--- commons/sandbox/digester3/trunk/src/site/xdoc/guide/dvsd3.xml (original)
+++ commons/sandbox/digester3/trunk/src/site/xdoc/guide/dvsd3.xml Sat Mar  5 13:45:01 2011
@@ -137,12 +137,64 @@ limitations under the License.
       and will be ready to create new Digester instances with pre-filled rules.</p>
     </section>
 
-    <section name="One single configuration point">
-      <p>TODO</p>
-    </section>
+    <section name="One single configuration point, one single universal loader">
+      <p>As shown above, basic Digester2.X usage would be creating a Digester then
setting the rules:</p>
+      <source>Digester digester = new Digester();
+    digester.addObjectCreate("root", "org.apache.commons.digester.SimpleTestBean");
+    digester.addBeanPropertySetter("root", "alpha");
+    digester.addBeanPropertySetter("root/alpha", "beta");
+    digester.addBeanPropertySetter("root/delta", "delta");</source>
 
-    <section name="One single universal loader">
-      <p>TODO</p>
+      <p>Alternatively, users can create the <code>Rules</code> instance,
set the rules and pass it to the Digester:</p>
+      <source>ExtendedBaseRules rules = new ExtendedBaseRules();
+    rules.addRule("root", new ObjectCreateRule("org.apache.commons.digester.SimpleTestBean"));
+    rules.addRule("root", new BeanPropertySetterRule("alpha"));
+    rules.addRule("root/alpha", new BeanPropertySetterRule("beta"));
+    rules.addRule("root/delta", new BeanPropertySetterRule("delta"));
+
+    Digester digester = new Digester();
+    digester.setRules(rules);
+    </source>
+
+      <p>Last, but not least, special loader classes have been created to gain more
benefits from <code>RuleSet</code>:
+like the <code>annotations</code> package <code>DigesterLoader</code>,
to avoid scanning class elements each time
+users want to create a new Digester instance to parse <code>Channel</code> type:</p>
+      <source>import org.apache.commons.digester.annotations.*;
+
+DigesterLoader digesterLoader = new DigesterLoaderBuilder()
+    .useDefaultAnnotationRuleProviderFactory()
+    .useDefaultDigesterLoaderHandlerFactory();
+Digester digester = digesterLoader.createDigester(Channel.class);</source>
+
+      <p>In Digester3 there is just one universal loader that aggregates all the power
of the components described above,
+configurations are expressed via <code>(Abstract)RulesModule</code></p>
+      <source>class SimpleTestBeanModule extends AbstractRulesModule {
+
+  @Override
+  protected void configure() {
+    forPattern("root")
+      .createObject().ofType("org.apache.commons.digester.SimpleTestBean")
+      .then()
+      .setBeanProperty("alpha");
+    forPattern("root/alpha").setBeanProperty("beta");
+    forPattern("root/delta").setBeanProperty("delta");
+  }
+
+}</source>
+      <p>Users can simply create new Digester instances:</p>
+      <source>DigesterLoader loader = newLoader(new SimpleTestBeanModule());
+    ...
+    Digester digester = loader.newDigester();</source>
+
+      <p>Users can create new Digester instances on top of different <code>Rules</code>
types:</p>
+      <code>Digester digester = loader.newDigester(new ExtendedBaseRules());</code>
+
+      <p>An, by the nature of the universal loader, auxiliary optimizations are not
needed:</p>
+      <source>DigesterLoader loader = newLoader(new FromAnnotationsRuleModule(Channel.class))
+    ...
+    Digester digester = loader.newDigester();
+    ...
+    digester = loader.newDigester(); // Channel.class won't be analyzed again!</source>
     </section>
 
     <section name="Extensions optimization">
@@ -153,4 +205,4 @@ limitations under the License.
       <p>TODO</p>
     </section>
   </body>
-</document>
\ No newline at end of file
+</document>



Mime
View raw message