Date: 2004-06-04T13:21:01
Editor: SteveGibson <[EMAIL PROTECTED]>
Wiki: Jakarta HiveMind Wiki
Page: Examples
URL: http://wiki.apache.org/jakarta-hivemind/Examples
no comment
Change Log:
------------------------------------------------------------------------------
@@ -3,40 +3,43 @@
* How to fetch java.sql.Connection using hivemind service.
* More interceptor docs?
-Steve Gibson:
+----
+SteveGibson :
The cool thing about HiveMind is that using services is no more complex than
the simple calculator example.
(Oh wow, I just realized the example is a whole calculator now, not just an
Adder!)
Configuration schema examples are something that would probably be more
beneficial.
-As for the interceptor - here is an ugly example of an interceptor for the
Divider (off the top of my head:
-
+As for the interceptor - here is an ugly example of an interceptor for the
Divider (off the top of my head):
+{{{
public class DividerInterceptor extends AbstractServiceInterceptorFactory
{
- protected void addServiceMethodImplementation(
+ protected void addServiceMethodImplementation(
ClassFab classFab,
String methodName,
Class returnType,
Class[] parameterTypes,
- Class[] exceptionTypes)
- {
- if (methodName.equals("divide"))
- {
- BodyBuilder builder = new BodyBuilder();
+ Class[] exceptionTypes
+ )
+ {
+ if (methodName.equals("divide"))
+ {
+ BodyBuilder builder = new BodyBuilder();
- builder.begin();
- builder.addln("if ($1 == 0)");
- builder.addln("{");
- builder.addln("throw new ArithmeticException(\"Division by zero\");");
- builder.addln("}");
- builder.addln("return ($r) _inner." + methodName + "($$);" );
- builder.end();
- classFab.addMethod(Modifier.PUBLIC,
- methodName,
- returnType,
- parameterTypes,
- exceptionTypes,
- builder.toString()
- );
+ builder.begin();
+ builder.addln("if ($1 == 0)");
+ builder.addln("{");
+ builder.addln("throw new ArithmeticException(\"Division by
zero\");");
+ builder.addln("}");
+ builder.addln("return ($r) _inner." + methodName + "($$);" );
+ builder.end();
+ classFab.addMethod(Modifier.PUBLIC,
+ methodName,
+ returnType,
+ parameterTypes,
+ exceptionTypes,
+ builder.toString()
+ );
}
- }
+ }
}
+}}}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]