FileDocCategorySizeDatePackage
ProxyClass.javaAPI DocGlassfish v2 API4884Fri May 04 22:25:58 BST 2007com.sun.enterprise.admin.util.proxy

ProxyClass

public class ProxyClass extends Object implements InvocationHandler
A proxy class

Fields Summary
private static InheritableThreadLocal
callStackHolder
private static Logger
_logger
private Object
delegate
private Interceptor
interceptor
Constructors Summary
public ProxyClass(Object handler, Interceptor interceptor)
Creates a new instance of Proxy


           
         
        delegate = handler;
        this.interceptor = interceptor;
    
Methods Summary
private static java.util.logging.LoggergetLogger()

        String loggerName = System.getProperty("com.sun.aas.admin.logger.name");
        if (loggerName == null) {
            loggerName = "global";
        }
        return Logger.getLogger(loggerName);
    
public java.lang.Objectinvoke(java.lang.Object proxy, java.lang.reflect.Method method, java.lang.Object[] args)

        Call call = new Call(method, args);
        CallStack callStack = (CallStack)callStackHolder.get();
        callStack.beginCall(call);
        try {
            interceptor.preInvoke(callStack);
        } catch (Throwable t) {
            _logger.log(Level.FINE, "core.interceptor_preinvoke_fail",
                    t.getMessage());
            _logger.log(Level.FINEST,
                    "core.interceptor_preinvoke_exception", t);
        }
        Object result = null;
        boolean success = true;
        Throwable failReason = null;
        try {
            result = method.invoke(delegate, args);
        } catch (InvocationTargetException ite) {
            success = false;
            failReason = ite.getTargetException();
            throw failReason;
        } catch (Throwable t) {
            success = false;
            failReason = t;
            throw failReason;
        } finally {
            if (!success) {
                call.setState(CallState.FAILED);
                call.setFailureReason(failReason);
            }
            call.setResult(result);
            
            if(!(call.getState().isFailed()))
                call.setState(CallState.SUCCESS);
            
            try {
                interceptor.postInvoke(callStack);
            } catch (Throwable t) {
                _logger.log(Level.FINE, "core.interceptor_postinvoke_fail",
                        t.getMessage());
                _logger.log(Level.FINEST,
                        "core.interceptor_postinvoke_exception", t);
            }
            callStack.endCall();
        }
        return result;