private Object wrapExecutor(Object bean) { Method execute = ReflectionUtils.findMethod(bean.getClass(), "execute", Runnable.class); boolean methodFinal = Modifier.isFinal(execute.getModifiers()); boolean classFinal = Modifier.isFinal(bean.getClass().getModifiers()); boolean cglibProxy = !methodFinal && !classFinal; Executor executor = (Executor) bean; try { return createProxy(bean, cglibProxy, new ExecutorMethodInterceptor(executor, this.beanFactory)); } catch (AopConfigException ex) { if (cglibProxy) { if (log.isDebugEnabled()) { log.debug( "Exception occurred while trying to create a proxy, falling back to JDK proxy", ex); } return createProxy(bean, false, new ExecutorMethodInterceptor(executor, this.beanFactory)); } throw ex; } }
@Override public Object invoke(MethodInvocation invocation) throws Throwable { T executor = executor(this.beanFactory, this.delegate); Method methodOnTracedBean = getMethod(invocation, executor); if (methodOnTracedBean != null) { try { return methodOnTracedBean.invoke(executor, invocation.getArguments()); } catch (InvocationTargetException ex) { // gh-1092: throw the target exception (if present) Throwable cause = ex.getCause(); throw (cause != null) ? cause : ex; } } return invocation.proceed(); }
@Override public Object invoke(MethodInvocation invocation) throws Throwable { T executor = executor(this.beanFactory, this.delegate); Method methodOnTracedBean = getMethod(invocation, executor); if (methodOnTracedBean != null) { try { return methodOnTracedBean.invoke(executor, invocation.getArguments()); } catch (InvocationTargetException ex) { // gh-1092: throw the target exception (if present) Throwable cause = ex.getCause(); throw (cause != null) ? cause : ex; } } return invocation.proceed(); }
private Object wrapExecutor(Object bean) { Method execute = ReflectionUtils.findMethod(bean.getClass(), "execute", Runnable.class); boolean methodFinal = Modifier.isFinal(execute.getModifiers()); boolean classFinal = Modifier.isFinal(bean.getClass().getModifiers()); boolean cglibProxy = !methodFinal && !classFinal; Executor executor = (Executor) bean; try { return createProxy(bean, cglibProxy, new ExecutorMethodInterceptor(executor, this.beanFactory)); } catch (AopConfigException ex) { if (cglibProxy) { if (log.isDebugEnabled()) { log.debug( "Exception occurred while trying to create a proxy, falling back to JDK proxy", ex); } return createProxy(bean, false, new ExecutorMethodInterceptor(executor, this.beanFactory)); } throw ex; } }