You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by hl...@apache.org on 2003/10/06 23:27:19 UTC
cvs commit: jakarta-commons-sandbox/hivemind/xdocs interceptors.xml
hlship 2003/10/06 14:27:19
Modified: hivemind/xdocs interceptors.xml
Log:
Simplify the initial interceptor example.
Revision Changes Path
1.9 +12 -14 jakarta-commons-sandbox/hivemind/xdocs/interceptors.xml
Index: interceptors.xml
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/xdocs/interceptors.xml,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- interceptors.xml 29 Sep 2003 16:16:35 -0000 1.8
+++ interceptors.xml 6 Oct 2003 21:27:18 -0000 1.9
@@ -95,7 +95,6 @@
import java.lang.reflect.Modifier;
-import org.apache.commons.hivemind.service.BodyBuilder;
import org.apache.commons.hivemind.service.ClassFab;
import org.apache.commons.hivemind.service.impl.AbstractServiceInterceptorFactory;
@@ -109,21 +108,13 @@
Class[] parameterTypes,
Class[] exceptionTypes)
{
- BodyBuilder builder = new BodyBuilder();
-
- builder.begin();
- builder.add("return ($r) _inner.");
- builder.add(methodName);
- builder.add("($$);");
- builder.end();
-
classFab.addMethod(
Modifier.PUBLIC,
methodName,
returnType,
parameterTypes,
exceptionTypes,
- builder.toString());
+ "{ return ($r) _inner." + methodName + "($$); }");
}
}
@@ -145,9 +136,7 @@
</p>
<p>
-The
-<a href="&apiroot;/service/BodyBuilder.html">BodyBuilder</a> class helps
-with assembling method bodies from bits and pieces. The <code>_inner</code> variable is a private instance variable,
+The <code>_inner</code> variable is a private instance variable,
the inner for this interceptor. The <code>($r)</code> reference means "cast to the return type for this method", and properly handles
void methods. The <code>$$</code> is a placeholder for a comma-seperated list of all the parameters to the method.
</p>
@@ -379,6 +368,15 @@
]]></source>
</p>
+<p>
+A bit more is going on here; since the method bodies for the fabricated methods are more complex,
+we're using the
+<a href="&apiroot;/service/BodyBuilder.html">BodyBuilder</a> class to help
+assemble them (but still keep the final method body neat and readable). BodyBuilder's
+begin() and end() methods take care of open and close braces, as well as indentation inside
+a code block.
+</p>
+
<p>
When you implement logging in your own classes, you often invoke the
method <code>Log.isDebugEnabled()</code> multiple times ... but in the fabricated class,
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org