static <T> DecoratedInvoker<T> newInvoker(T target, T decorator, Class<?> expectedType, Invoker<T> invoker, DecoratorInvocationHandler<T> decoratorInvocationHandler) { return new DecoratedInvoker<T>(target, decorator, expectedType, invoker, decoratorInvocationHandler); }
/** * Ignores any {@link RuntimeException} which comes from the preceding decorator. * @return the DecoratedResultInvoker ignoring exceptions. */ public DecoratedInvoker<T> ignoringDecoratorExceptions() { return ignoringDecoratorExceptionsOfType(RuntimeException.class); }
/** * Ignores any exception of the {@code exceptionClass} type which comes from the preceding decorator. * @param exceptionClass the exception to ignore - usually a checked exception of decorator method * @return the DecoratedResultInvoker ignoring given exception type. */ public DecoratedInvoker<T> ignoringDecoratorExceptionsOfType(Class<?> exceptionClass) { RuntimeExceptionShield runtimeExceptionShield = new RuntimeExceptionShield(decorator, exceptionClass); @SuppressWarnings("unchecked") T exceptionSafeDecorator = (T) Proxy.newProxyInstance(decorator.getClass().getClassLoader(),// new Class[] { expectedType }, runtimeExceptionShield); decoratorInvocationHandler.setDecorator(exceptionSafeDecorator); return newInvoker(target, exceptionSafeDecorator, expectedType, invoker, decoratorInvocationHandler); }
return newInvoker(target, decorator, expectedType, invoker, decoratorInvocationHandler);
T field = (T) Proxy.newProxyInstance(decorator.getClass().getClassLoader(), array(expectedType), handler); set(field); return DecoratedInvoker.newInvoker(target, decorator, expectedType, this, handler);
T field = (T) Proxy.newProxyInstance(decorator.getClass().getClassLoader(), array(expectedType), handler); set(field); return DecoratedInvoker.newInvoker(target, decorator, expectedType, this, handler);