KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > 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.remoting.interceptor;
8
9 import org.jboss.logging.Logger;
10 import org.jboss.remoting.InvocationRequest;
11 import org.jboss.remoting.InvokerCallbackHandler;
12 import org.jboss.remoting.ServerInvocationHandler;
13 import org.jboss.remoting.ServerInvoker;
14
15 import javax.management.MBeanServer JavaDoc;
16
17 /**
18  * @author <a HREF="mailto:tom@jboss.org">Tom Elrod</a>
19  */

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

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

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

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

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