Class TrapException
- All Implemented Interfaces:
InvocationHandler
InvocationHandler contract: the
exception is re-thrown unchanged when the method declares it (a subclass of a declared type passes as well),
replaced by an SQLException carrying it as the cause when the method declares SQLException, and
replaced by a RuntimeException carrying it as the cause otherwise. An Error is always re-thrown as
it is, including one carried by an InvocationTargetException.
The pool prepends this interceptor to the definitions parsed from jdbcInterceptors, so it heads the chain
of every connection that has an interceptor chain at all; a pool configured without an interceptor list has no
chain and therefore no trap. An undeclared checked exception reaching such an untrapped connection still respects
the proxy contract - the JDK proxy itself turns it into an
UndeclaredThrowableException - what the trap adds on top of that is the declared,
JDBC-shaped exception with the original preserved as its cause.
-
Field Summary
Fields inherited from class JdbcInterceptor
ABORT_VAL, CLOSE_VAL, EQUALS_VAL, GETCONNECTION_VAL, HASHCODE_VAL, ISCLOSED_VAL, ISVALID_VAL, ISWRAPPERFOR_VAL, properties, TOSTRING_VAL, UNWRAP_VAL -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGets invoked each time an operation onConnectionis invoked.booleanisDeclaredException(Method m, Class<?> clazz) Checks if the given exception class is declared in the throws clause of the specified method.voidreset(ConnectionPool parent, PooledConnection con) no-op for this interceptor. no state is stored.Methods inherited from class JdbcInterceptor
compare, compare, disconnected, getNext, getProperties, isUseEquals, poolClosed, poolStarted, setNext, setProperties, setUseEquals, unregisterMBean
-
Constructor Details
-
TrapException
public TrapException()Constructs a new TrapException interceptor.
-
-
Method Details
-
invoke
Description copied from class:JdbcInterceptorGets invoked each time an operation onConnectionis invoked.The base implementation passes the call to the
nextinterceptor in the chain. When there is no next interceptor, the call fails fast with aNullPointerException: a chain built by the pool always ends in theProxyConnectionterminal, so reaching this case means a chain was hand-built without a terminal link. Interceptors that do not answer a call themselves continue it withsuper.invoke(proxy, method, args).- Specified by:
invokein interfaceInvocationHandler- Overrides:
invokein classJdbcInterceptor- Throws:
Throwable
-
isDeclaredException
-
reset
no-op for this interceptor. no state is stored.- Specified by:
resetin classJdbcInterceptor- Parameters:
parent- - the connection pool owning the connectioncon- - the pooled connection
-