|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.emarsys.ecommon.exceptions.handling.ExceptionHandlingProxy
public class ExceptionHandlingProxy
An ExceptionHandlingProxy
creates dynamic Proxy
s
that serve two purposes:
ExceptionHandling
mechanismException
s on the its method calls
transparently according to their annotation configuration
If an Exception
occurs during a method call on a proxy
it will look for a ExceptionHandler
registered with the
ExceptionScenario
described
NOTE: the whole pluggable exception handling (PEH) module is highly experimental and still under heavy development, don't use it in production code unless you know what you're doing!
ExceptionHandling
,
TODO what about methods with more than one exception?
- specify a common super class for all declared
exceptions as handled exception type and dispatch
the handling behavior it in the handler class according
to the concrete exception type to be handled
- maybe create something like a ChainedExceptionHandler
implementing a chain-of-responsibility
TODO not fully tested
Constructor Summary | |
---|---|
protected |
ExceptionHandlingProxy(java.lang.Object target)
|
Method Summary | ||
---|---|---|
protected java.lang.Object |
doInvoke(java.lang.Object invokee,
java.lang.reflect.Method method,
java.lang.Object[] args)
|
|
static ExceptionHandling |
getExceptionHandling(java.lang.Object obj)
|
|
static
|
getInstance(java.lang.Object target,
java.lang.Class<P> type)
|
|
protected ExceptionScenario<?,?> |
getScenario(java.lang.Object invokee,
java.lang.reflect.Method method)
Note: HandleExceptions s annotations are inherited so
so we don't query method.getDeclaringClass() but pass the actual
object being invoked. |
|
protected
|
handle(ExceptionScenario<H,I> scenario,
java.lang.Throwable th)
|
|
java.lang.Object |
invoke(java.lang.Object proxy,
java.lang.reflect.Method method,
java.lang.Object[] args)
Dispatches calls between target and handling
and delegates the actual invocation to
doInvoke(Object, Method, Object[]) . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
protected ExceptionHandlingProxy(java.lang.Object target)
target
- Method Detail |
---|
public static <P> P getInstance(java.lang.Object target, java.lang.Class<P> type)
E
- P
- target
- type
-
public static ExceptionHandling getExceptionHandling(java.lang.Object obj)
obj
-
public java.lang.Object invoke(java.lang.Object proxy, java.lang.reflect.Method method, java.lang.Object[] args) throws java.lang.Throwable
target
and handling
and delegates the actual invocation to
doInvoke(Object, Method, Object[])
.
invoke
in interface java.lang.reflect.InvocationHandler
java.lang.Throwable
InvocationHandler.invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])
protected java.lang.Object doInvoke(java.lang.Object invokee, java.lang.reflect.Method method, java.lang.Object[] args) throws java.lang.Throwable
proxy
- method
- args
-
java.lang.Throwable
protected ExceptionScenario<?,?> getScenario(java.lang.Object invokee, java.lang.reflect.Method method)
HandleExceptions
s annotations are inherited so
so we don't query method.getDeclaringClass() but pass the actual
object being invoked.
method
-
ExceptionScenario
instance described by
the HandleExceptions
annotation on the passed method of
the passed invokee object's Class
or if not present on the
invokee's Class
itself or null
if neither
the method nor the class level annotation is present.protected <H extends java.lang.Exception,I extends java.lang.Exception> void handle(ExceptionScenario<H,I> scenario, java.lang.Throwable th) throws java.lang.Throwable
H
- I
- scenario
- th
-
java.lang.Throwable
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |