From 1ca740ab8bcf5361fe479c0a656563026921b642 Mon Sep 17 00:00:00 2001 From: Jonas Partner Date: Wed, 29 Oct 2008 15:08:26 +0000 Subject: [PATCH] simplified so Runnable is wrapped not proxied --- .../RunnableProxyingMethodInterceptor.java | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/executor/RunnableProxyingMethodInterceptor.java b/org.springframework.integration/src/main/java/org/springframework/integration/executor/RunnableProxyingMethodInterceptor.java index 4a9f384cbc..ffe652f532 100644 --- a/org.springframework.integration/src/main/java/org/springframework/integration/executor/RunnableProxyingMethodInterceptor.java +++ b/org.springframework.integration/src/main/java/org/springframework/integration/executor/RunnableProxyingMethodInterceptor.java @@ -18,7 +18,6 @@ package org.springframework.integration.executor; import org.aopalliance.intercept.MethodInterceptor; import org.aopalliance.intercept.MethodInvocation; -import org.springframework.aop.framework.ProxyFactory; import org.springframework.core.task.TaskExecutor; import org.springframework.integration.util.ErrorHandler; @@ -40,28 +39,28 @@ public class RunnableProxyingMethodInterceptor implements MethodInterceptor { public Object invoke(MethodInvocation invocation) throws Throwable { Runnable runnable = (Runnable) invocation.getArguments()[0]; - ProxyFactory factory = new ProxyFactory(runnable); - factory.addAdvice(new ErrorHandlingAdvice(errorHandler)); - invocation.getArguments()[0] = factory.getProxy(); + invocation.getArguments()[0] = new ErrorHandlingRunnabelWrapper(runnable, errorHandler); return invocation.proceed(); } - private static class ErrorHandlingAdvice implements MethodInterceptor { + private static class ErrorHandlingRunnabelWrapper implements Runnable { private final ErrorHandler errorHandler; - public ErrorHandlingAdvice(ErrorHandler errorHandler) { + private final Runnable runnableTarget; + + public ErrorHandlingRunnabelWrapper(Runnable runnableTarget, ErrorHandler errorHandler) { + this.runnableTarget = runnableTarget; this.errorHandler = errorHandler; } - public Object invoke(MethodInvocation invocation) throws Throwable { + public void run() { try { - invocation.proceed(); + runnableTarget.run(); } catch (Throwable t) { errorHandler.handle(t); } - return null; } }