FileDocCategorySizeDatePackage
InvocationHandlerUtil.javaAPI DocGlassfish v2 API3819Fri May 04 22:33:00 BST 2007com.sun.ejb.containers.util

InvocationHandlerUtil

public final class InvocationHandlerUtil extends Object

Fields Summary
Constructors Summary
InvocationHandlerUtil()

Methods Summary
public static java.lang.ThrowablehandleInvocationException(java.lang.Throwable invException)


        Throwable toThrow = invException;
        
        if (invException instanceof java.lang.RuntimeException) {
            toThrow = invException;
        } else if (invException instanceof Exception) {
            toThrow = invException;
        } else {
            toThrow = new EJBException(invException.getMessage());
        }

        return toThrow;
    
public static java.lang.ObjectinvokeJavaObjectMethod(java.lang.reflect.InvocationHandler handler, java.lang.reflect.Method method, java.lang.Object[] args)


        Object returnValue = null;

        // Can only be one of : 
        //     boolean java.lang.Object.equals(Object)
        //     int     java.lang.Object.hashCode()
        //     String  java.lang.Object.toString()
        //
        // Optimize by comparing as few characters as possible.

        switch( method.getName().charAt(0) ) {
            case 'e" :
                Object other = Proxy.isProxyClass(args[0].getClass()) ?
                    Proxy.getInvocationHandler(args[0]) : args[0];
                returnValue = new Boolean(handler.equals(other));
                break;
            case 'h" :
                returnValue = new Integer(handler.hashCode());
                break;
            case 't" :
                returnValue = handler.toString();
                break;
            default :
                throw new EJBException(method.getName());
        }

        return returnValue;