use of com.tvd12.ezyfoxserver.support.reflect.EzyExceptionHandlerProxy in project ezyfox-server by youngmonkeys.
the class EzyExceptionHandlersImplementer method implement.
public Map<Class<?>, EzyUncaughtExceptionHandler> implement(Object exceptionHandler) {
Map<Class<?>, EzyUncaughtExceptionHandler> handlers = new HashMap<>();
EzyExceptionHandlerProxy proxy = new EzyExceptionHandlerProxy(exceptionHandler);
for (EzyExceptionHandlerMethod method : proxy.getExceptionHandlerMethods()) {
EzyExceptionHandlerImplementer implementer = newImplementer(proxy, method);
EzyUncaughtExceptionHandler handler = implementer.implement();
for (Class<?> exceptionClass : method.getExceptionClasses()) {
handlers.put(exceptionClass, handler);
}
}
return handlers;
}
use of com.tvd12.ezyfoxserver.support.reflect.EzyExceptionHandlerProxy in project ezyfox-server by youngmonkeys.
the class EzyExceptionHandlerImplementerTest method testFailedCase.
@Test(expectedExceptions = IllegalStateException.class)
public void testFailedCase() throws Exception {
EzyExceptionHandlerProxy handlerProxy = new EzyExceptionHandlerProxy(new ExceptionHandlerFail());
EzyExceptionHandlerMethod method = new EzyExceptionHandlerMethod(new EzyMethod(ExceptionHandlerFail.class.getDeclaredMethod("handle", Exception.class, int.class)));
new EzyExceptionHandlerImplementer(handlerProxy, method) {
@SuppressWarnings("rawtypes")
@Override
protected EzyUncaughtExceptionHandler doImplement() {
throw new IllegalStateException("test");
}
}.implement();
}
use of com.tvd12.ezyfoxserver.support.reflect.EzyExceptionHandlerProxy in project ezyfox-server by youngmonkeys.
the class EzyExceptionHandlerProxyTest method test.
@Test
public void test() {
EzyExceptionHandlerProxy proxy = new EzyExceptionHandlerProxy(new ExceptionHandlerEx());
System.out.println(proxy);
}
Aggregations