/*
* $Id: JBossProxyHandler.java 674 2006-10-06 12:15:59Z hengels $
* (c) Copyright 2004 con:cern development team.
*
* This file is part of con:cern (http://concern.org).
*
* con:cern is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1
* of the License, or (at your option) any later version.
*
* Please see COPYING for the complete licence.
*/
package org.concern.client.remote;
import org.jboss.jmx.adaptor.rmi.RMIAdaptor;
import javax.management.ObjectName;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.UndeclaredThrowableException;
import java.util.ArrayList;
/**
* Proxy to a remote controller session bean.
*/
class JBossProxyHandler
implements InvocationHandler
{
private RMIAdaptor server;
private ObjectName controllerName;
JBossProxyHandler(RMIAdaptor server, ObjectName controllerName) {
this.server = server;
this.controllerName = controllerName;
}
public Object invoke(Object proxy, Method method, Object[] args)
throws Throwable
{
String methodName = method.getName();
Class[] sigTypes = method.getParameterTypes();
ArrayList sigStrings = new ArrayList();
for (int s = 0; s < sigTypes.length; s ++)
sigStrings.add(sigTypes[s].getName());
String[] sig = new String[sigTypes.length];
sigStrings.toArray(sig);
Object value = null;
try {
value = server.invoke(controllerName, methodName, args, sig);
}
catch (UndeclaredThrowableException e) {
System.out.println("getUndeclaredThrowable: "+e.getUndeclaredThrowable());
throw e.getUndeclaredThrowable();
}
return value;
}
}
|