com.googlecode.catchexception.throwable.internal
Class AbstractThrowableProcessingInvocationHandler<E extends Throwable>

java.lang.Object
  extended by com.googlecode.catchexception.throwable.internal.AbstractThrowableProcessingInvocationHandler<E>
Type Parameters:
E - The type of the throwable that is caught and ,optionally, verified.
Direct Known Subclasses:
ThrowableProcessingInterceptor

 class AbstractThrowableProcessingInvocationHandler<E extends Throwable>
extends Object

This abstract method invocation interceptor

Since:
16.09.2011
Author:
rwoo

Field Summary
protected  boolean assertThrowable
          See AbstractThrowableProcessingInvocationHandler(Object, Class, boolean) .
protected  Class<E> clazz
          See AbstractThrowableProcessingInvocationHandler(Object, Class, boolean) .
protected  Object target
          See AbstractThrowableProcessingInvocationHandler(Object, Class, boolean) .
 
Constructor Summary
AbstractThrowableProcessingInvocationHandler(Object target, Class<E> clazz, boolean assertThrowable)
           
 
Method Summary
protected  Object afterInvocation(Object retval)
          Must be called by the subclass after the method invocation that has not thrown a throwable.
protected  Object afterInvocationThrowsThrowable(Throwable e, Method method)
          Must be called by the subclass after the intercepted method invocation that has thrown a throwable.
protected  void beforeInvocation()
          Must be called by the subclass before the intercepted method invocation.
(package private)  Object safeReturnValue(Class<?> type)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

clazz

protected Class<E extends Throwable> clazz
See AbstractThrowableProcessingInvocationHandler(Object, Class, boolean) .


target

protected Object target
See AbstractThrowableProcessingInvocationHandler(Object, Class, boolean) .


assertThrowable

protected boolean assertThrowable
See AbstractThrowableProcessingInvocationHandler(Object, Class, boolean) .

Constructor Detail

AbstractThrowableProcessingInvocationHandler

public AbstractThrowableProcessingInvocationHandler(Object target,
                                                    Class<E> clazz,
                                                    boolean assertThrowable)
Parameters:
target - The object all method calls are delegated to. Must not be null.
clazz - the type of the throwable that is to catch. Must not be null.
assertThrowable - True if the interceptor shall throw an ThrowableNotThrownAssertionError if the method has not thrown an throwable of the expected type.
Method Detail

beforeInvocation

protected void beforeInvocation()
Must be called by the subclass before the intercepted method invocation.


afterInvocation

protected Object afterInvocation(Object retval)
                          throws Error
Must be called by the subclass after the method invocation that has not thrown a throwable.

Parameters:
retval - The value returned by the intercepted method invocation.
Returns:
The value that shall be returned by the proxy.
Throws:
Error - (optionally) Thrown if the verification failed.

afterInvocationThrowsThrowable

protected Object afterInvocationThrowsThrowable(Throwable e,
                                                Method method)
                                         throws Error,
                                                Throwable
Must be called by the subclass after the intercepted method invocation that has thrown a throwable.

Parameters:
e - the throwable thrown by the intercepted method invocation.
method - the method that was proxied
Returns:
Always returns null.
Throws:
Error - Thrown if the verification failed.
Throwable - The given throwable. (Re-)thrown if the thrown throwable shall not be caught and verification is not required.

safeReturnValue

Object safeReturnValue(Class<?> type)
Parameters:
type - a type
Returns:
Returns a value of the given type


Copyright © 2015. All rights reserved.