01: /*
02: * JBoss, Home of Professional Open Source.
03: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
04: * as indicated by the @author tags. See the copyright.txt file in the
05: * distribution for a full listing of individual contributors.
06: *
07: * This is free software; you can redistribute it and/or modify it
08: * under the terms of the GNU Lesser General Public License as
09: * published by the Free Software Foundation; either version 2.1 of
10: * the License, or (at your option) any later version.
11: *
12: * This software is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15: * Lesser General Public License for more details.
16: *
17: * You should have received a copy of the GNU Lesser General Public
18: * License along with this software; if not, write to the Free
19: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21: */
22: package org.jboss.test.remoting.interceptor;
23:
24: import javax.management.MBeanServer;
25: import org.jboss.logging.Logger;
26: import org.jboss.remoting.InvocationRequest;
27: import org.jboss.remoting.callback.InvokerCallbackHandler;
28: import org.jboss.remoting.ServerInvocationHandler;
29: import org.jboss.remoting.ServerInvoker;
30:
31: /**
32: * @author <a href="mailto:tom@jboss.org">Tom Elrod</a>
33: */
34: public class TestInvocationHandler implements ServerInvocationHandler {
35: private ServerInvoker invoker;
36:
37: private static final Logger log = Logger
38: .getLogger(TestInvocationHandler.class);
39:
40: /**
41: * set the invoker that owns this handler
42: *
43: * @param invoker
44: */
45: public void setInvoker(ServerInvoker invoker) {
46: this .invoker = invoker;
47: }
48:
49: /**
50: * set the mbean server that the handler can reference
51: *
52: * @param server
53: */
54: public void setMBeanServer(MBeanServer server) {
55: }
56:
57: public Object invoke(InvocationRequest invocation) throws Throwable {
58: Object ret = null;
59: Object param = invocation.getParameter();
60: if (param instanceof org.jboss.test.remoting.interceptor.TestInvocation) {
61: Object obj = ((org.jboss.test.remoting.interceptor.TestInvocation) param)
62: .getArgument();
63: if (obj instanceof TestTarget) {
64: TestTarget testParamVal = (TestTarget) obj;
65: ret = new Boolean(new TestTarget().equals(testParamVal));
66: }
67: } else {
68: log
69: .info("Don't recognize the parameter type, so just returning it.");
70: ret = param;
71: }
72: return ret;
73: }
74:
75: /**
76: * Adds a callback handler that will listen for callbacks from
77: * the server invoker handler.
78: *
79: * @param callbackHandler
80: */
81: public void addListener(InvokerCallbackHandler callbackHandler) {
82: }
83:
84: /**
85: * Removes the callback handler that was listening for callbacks
86: * from the server invoker handler.
87: *
88: * @param callbackHandler
89: */
90: public void removeListener(InvokerCallbackHandler callbackHandler) {
91: }
92: }
|