KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > remoting > interceptor > TestInvocationHandler


1 /*
2  * JBoss, the OpenSource J2EE webOS
3  *
4  * Distributable under LGPL license.
5  * See terms of license at gnu.org.
6  */

7 package org.jboss.test.remoting.interceptor;
8
9 import javax.management.MBeanServer JavaDoc;
10 import org.jboss.logging.Logger;
11 import org.jboss.remoting.InvocationRequest;
12 import org.jboss.remoting.callback.InvokerCallbackHandler;
13 import org.jboss.remoting.ServerInvocationHandler;
14 import org.jboss.remoting.ServerInvoker;
15
16 /**
17  * @author <a HREF="mailto:tom@jboss.org">Tom Elrod</a>
18  */

19 public class TestInvocationHandler implements ServerInvocationHandler
20 {
21    private ServerInvoker invoker;
22
23    private static final Logger log = Logger.getLogger(TestInvocationHandler.class);
24
25
26    /**
27     * set the invoker that owns this handler
28     *
29     * @param invoker
30     */

31    public void setInvoker(ServerInvoker invoker)
32    {
33       this.invoker = invoker;
34    }
35
36    /**
37     * set the mbean server that the handler can reference
38     *
39     * @param server
40     */

41    public void setMBeanServer(MBeanServer JavaDoc server)
42    {
43    }
44
45    public Object JavaDoc invoke(InvocationRequest invocation)
46          throws Throwable JavaDoc
47    {
48       Object JavaDoc ret = null;
49       Object JavaDoc param = invocation.getParameter();
50       if(param instanceof org.jboss.test.remoting.interceptor.TestInvocation)
51       {
52          Object JavaDoc obj = ((org.jboss.test.remoting.interceptor.TestInvocation) param).getArgument();
53          if(obj instanceof TestTarget)
54          {
55             TestTarget testParamVal = (TestTarget) obj;
56             ret = new Boolean JavaDoc(new TestTarget().equals(testParamVal));
57          }
58       }
59       else
60       {
61          log.info("Don't recognize the parameter type, so just returning it.");
62          ret = param;
63       }
64       return ret;
65    }
66
67    /**
68     * Adds a callback handler that will listen for callbacks from
69     * the server invoker handler.
70     *
71     * @param callbackHandler
72     */

73    public void addListener(InvokerCallbackHandler callbackHandler)
74    {
75    }
76
77    /**
78     * Removes the callback handler that was listening for callbacks
79     * from the server invoker handler.
80     *
81     * @param callbackHandler
82     */

83    public void removeListener(InvokerCallbackHandler callbackHandler)
84    {
85    }
86 }
87
Popular Tags