From b0972a57dde5d9a9685b70a5454eaa225a12464d Mon Sep 17 00:00:00 2001 From: Gary Russell Date: Tue, 17 May 2011 18:21:16 -0400 Subject: [PATCH] INT-1905 Set Handler Component Name, Even If Proxied --- .../config/ConsumerEndpointFactoryBean.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/spring-integration-core/src/main/java/org/springframework/integration/config/ConsumerEndpointFactoryBean.java b/spring-integration-core/src/main/java/org/springframework/integration/config/ConsumerEndpointFactoryBean.java index 7567c35ca3..8b6469c060 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/config/ConsumerEndpointFactoryBean.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/config/ConsumerEndpointFactoryBean.java @@ -15,6 +15,8 @@ */ package org.springframework.integration.config; +import org.springframework.aop.framework.Advised; +import org.springframework.aop.support.AopUtils; import org.springframework.beans.factory.BeanClassLoaderAware; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.BeanFactoryAware; @@ -107,8 +109,17 @@ public class ConsumerEndpointFactoryBean } public void afterPropertiesSet() throws Exception { - if (!this.beanName.startsWith("org.springframework") && this.handler instanceof IntegrationObjectSupport) { - ((IntegrationObjectSupport) this.handler).setComponentName(this.beanName); + if (!this.beanName.startsWith("org.springframework")) { + MessageHandler targetHandler = this.handler; + if (AopUtils.isAopProxy(targetHandler)) { + Object target = ((Advised) targetHandler).getTargetSource().getTarget(); + if (target instanceof MessageHandler) { + targetHandler = (MessageHandler) target; + } + } + if (targetHandler instanceof IntegrationObjectSupport) { + ((IntegrationObjectSupport) targetHandler).setComponentName(this.beanName); + } } this.initializeEndpoint(); }