final Class clazz = connection.getClass();
Method cleanupMethod;
if (Proxy.isProxyClass(clazz))
{
TargetInvocationHandler handler =
(TargetInvocationHandler) Proxy.getInvocationHandler(connection);
// this is really an XA connection, bypass the java.lang.reflect.Proxy as it
// can't delegate to non-interfaced methods (like proprietary 'cleanup' one)
// TODO check if CGlib will manage to enhance the AMQ connection class,
// there are no final methods, but a number of private ones, though
connection = (Connection) handler.getTargetObject();
Class realConnectionClass = connection.getClass();
cleanupMethod = realConnectionClass.getMethod("cleanup", (Class[])null);
}
else
{