FileDocCategorySizeDatePackage
InvocationHandlerUtil.javaAPI DocGlassfish v2 API4960Fri May 04 22:32:58 BST 2007com.sun.ejb.containers

InvocationHandlerUtil

public final class InvocationHandlerUtil extends Object

Fields Summary
Constructors Summary
InvocationHandlerUtil()

Methods Summary
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" :
                boolean result = false;
                if (args[0] != null) {
                    Object other = Proxy.isProxyClass(args[0].getClass()) ?
                            Proxy.getInvocationHandler(args[0]) : args[0];
                            result = handler.equals(other);
                }
                returnValue = new Boolean(result);
                break;
            case 'h" :
                returnValue = new Integer(handler.hashCode());
                break;
            case 't" :
                returnValue = handler.toString();
                break;
            default :
                throw new EJBException(method.getName());
        }

        return returnValue;
    
static booleanisDeclaredException(java.lang.Throwable t, java.lang.Class[] declaredExceptions)

        boolean declaredException = false;

        for(int i = 0; i < declaredExceptions.length; i++) {
            Class next = declaredExceptions[i];
            if( next.isAssignableFrom(t.getClass()) ) {
                declaredException = true;
                break;
            }
        }

        return declaredException;
    
static voidthrowLocalException(java.lang.Throwable t, java.lang.Class[] declaredExceptions)

        Throwable toThrow = t;

        if( (t instanceof java.lang.RuntimeException) ||
            (isDeclaredException(t, declaredExceptions)) ) {
            toThrow = t;
        } else {
            toThrow = new EJBException();
            toThrow.initCause(t);
        } 
        
        throw toThrow;

    
static voidthrowRemoteException(java.lang.Throwable t, java.lang.Class[] declaredExceptions)

        Throwable toThrow = t;

        if( (t instanceof java.lang.RuntimeException) ||
            (t instanceof java.rmi.RemoteException) ||
            (isDeclaredException(t, declaredExceptions)) ) {
            toThrow = t;
        } else {
            toThrow = new RemoteException("", t);
        }

        throw toThrow;