01: /*
02: * $Id: JBossProxyHandler.java 674 2006-10-06 12:15:59Z hengels $
03: * (c) Copyright 2004 con:cern development team.
04: *
05: * This file is part of con:cern (http://concern.org).
06: *
07: * con:cern is free software; you can redistribute it and/or modify
08: * it under the terms of the GNU Lesser General Public License
09: * as published by the Free Software Foundation; either version 2.1
10: * of the License, or (at your option) any later version.
11: *
12: * Please see COPYING for the complete licence.
13: */
14: package org.concern.client.remote;
15:
16: import org.jboss.jmx.adaptor.rmi.RMIAdaptor;
17:
18: import javax.management.ObjectName;
19: import java.lang.reflect.InvocationHandler;
20: import java.lang.reflect.Method;
21: import java.lang.reflect.UndeclaredThrowableException;
22: import java.util.ArrayList;
23:
24: /**
25: * Proxy to a remote controller session bean.
26: */
27: class JBossProxyHandler implements InvocationHandler {
28: private RMIAdaptor server;
29: private ObjectName controllerName;
30:
31: JBossProxyHandler(RMIAdaptor server, ObjectName controllerName) {
32: this .server = server;
33: this .controllerName = controllerName;
34: }
35:
36: public Object invoke(Object proxy, Method method, Object[] args)
37: throws Throwable {
38: String methodName = method.getName();
39: Class[] sigTypes = method.getParameterTypes();
40: ArrayList sigStrings = new ArrayList();
41: for (int s = 0; s < sigTypes.length; s++)
42: sigStrings.add(sigTypes[s].getName());
43: String[] sig = new String[sigTypes.length];
44: sigStrings.toArray(sig);
45: Object value = null;
46: try {
47: value = server
48: .invoke(controllerName, methodName, args, sig);
49: } catch (UndeclaredThrowableException e) {
50: System.out.println("getUndeclaredThrowable: "
51: + e.getUndeclaredThrowable());
52: throw e.getUndeclaredThrowable();
53: }
54: return value;
55: }
56: }
|