diff --git a/spring-integration-core/src/main/java/org/springframework/integration/endpoint/AbstractMessageSource.java b/spring-integration-core/src/main/java/org/springframework/integration/endpoint/AbstractMessageSource.java index d409647dfa..2400172671 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/endpoint/AbstractMessageSource.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/endpoint/AbstractMessageSource.java @@ -20,9 +20,11 @@ import java.util.Collections; import java.util.HashMap; import java.util.Map; +import org.springframework.beans.factory.BeanNameAware; import org.springframework.expression.Expression; import org.springframework.integration.core.MessageSource; import org.springframework.integration.support.AbstractIntegrationMessageBuilder; +import org.springframework.integration.support.context.NamedComponent; import org.springframework.integration.util.AbstractExpressionEvaluator; import org.springframework.messaging.Message; import org.springframework.messaging.MessagingException; @@ -33,16 +35,28 @@ import org.springframework.util.CollectionUtils; * @author Oleg Zhurakousky * @since 2.0 */ -public abstract class AbstractMessageSource extends AbstractExpressionEvaluator implements MessageSource { +public abstract class AbstractMessageSource extends AbstractExpressionEvaluator implements MessageSource, + NamedComponent, BeanNameAware { private volatile Map headerExpressions = Collections.emptyMap(); + private volatile String beanName; public void setHeaderExpressions(Map headerExpressions) { this.headerExpressions = (headerExpressions != null) ? headerExpressions : Collections.emptyMap(); } + @Override + public void setBeanName(String name) { + this.beanName = name; + } + + @Override + public String getComponentName() { + return this.beanName; + } + @Override @SuppressWarnings("unchecked") public final Message receive() { diff --git a/spring-integration-core/src/main/java/org/springframework/integration/endpoint/ExpressionEvaluatingMessageSource.java b/spring-integration-core/src/main/java/org/springframework/integration/endpoint/ExpressionEvaluatingMessageSource.java index 47aeb7bde2..47e26b032e 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/endpoint/ExpressionEvaluatingMessageSource.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/endpoint/ExpressionEvaluatingMessageSource.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2010 the original author or authors. + * Copyright 2002-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,6 +21,7 @@ import org.springframework.util.Assert; /** * @author Mark Fisher + * @author Gary Russell * @since 2.0 */ public class ExpressionEvaluatingMessageSource extends AbstractMessageSource { @@ -36,6 +37,12 @@ public class ExpressionEvaluatingMessageSource extends AbstractMessageSource< this.expectedType = expectedType; } + @Override + public String getComponentType() { + return "inbound-channel-adapter"; + } + + @Override public T doReceive() { return this.evaluateExpression(this.expression, this.expectedType); } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/endpoint/MethodInvokingMessageSource.java b/spring-integration-core/src/main/java/org/springframework/integration/endpoint/MethodInvokingMessageSource.java index dacb3cb607..a757c7139d 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/endpoint/MethodInvokingMessageSource.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/endpoint/MethodInvokingMessageSource.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2010 the original author or authors. + * Copyright 2002-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,16 +19,17 @@ package org.springframework.integration.endpoint; import java.lang.reflect.Method; import org.springframework.beans.factory.InitializingBean; -import org.springframework.messaging.MessagingException; import org.springframework.integration.core.MessageSource; +import org.springframework.messaging.MessagingException; import org.springframework.util.Assert; import org.springframework.util.ReflectionUtils; /** * A {@link MessageSource} implementation that invokes a no-argument method so * that its return value may be sent to a channel. - * + * * @author Mark Fisher + * @author Gary Russell */ public class MethodInvokingMessageSource extends AbstractMessageSource implements InitializingBean { @@ -58,6 +59,12 @@ public class MethodInvokingMessageSource extends AbstractMessageSource i this.methodName = methodName; } + @Override + public String getComponentType() { + return "inbound-channel-adapter"; + } + + @Override public void afterPropertiesSet() { synchronized (this.initializationMonitor) { if (this.initialized) { diff --git a/spring-integration-core/src/main/java/org/springframework/integration/resource/ResourceRetrievingMessageSource.java b/spring-integration-core/src/main/java/org/springframework/integration/resource/ResourceRetrievingMessageSource.java index ffdd112285..87b3235195 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/resource/ResourceRetrievingMessageSource.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/resource/ResourceRetrievingMessageSource.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2011 the original author or authors. + * Copyright 2002-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,19 +25,20 @@ import org.springframework.context.ApplicationContextAware; import org.springframework.context.MessageSource; import org.springframework.core.io.Resource; import org.springframework.core.io.support.ResourcePatternResolver; -import org.springframework.messaging.MessagingException; import org.springframework.integration.endpoint.AbstractMessageSource; import org.springframework.integration.util.CollectionFilter; +import org.springframework.messaging.MessagingException; import org.springframework.util.Assert; import org.springframework.util.CollectionUtils; import org.springframework.util.ObjectUtils; /** - * Implementation of {@link MessageSource} based on {@link ResourcePatternResolver} which will + * Implementation of {@link MessageSource} based on {@link ResourcePatternResolver} which will * attempt to resolve {@link Resource}s based on the pattern specified. - * + * * @author Oleg Zhurakousky * @author Mark Fisher + * @author Gary Russell * @since 2.1 */ public class ResourceRetrievingMessageSource extends AbstractMessageSource implements ApplicationContextAware, InitializingBean { @@ -65,10 +66,18 @@ public class ResourceRetrievingMessageSource extends AbstractMessageSource this.attributeName = attributeName; } + @Override + public String getComponentType() { + return "jmx:attribute-polling-channel-adapter"; + } + /** * Retrieves the JMX attribute value. */ diff --git a/spring-integration-jmx/src/main/java/org/springframework/integration/jmx/MBeanTreePollingMessageSource.java b/spring-integration-jmx/src/main/java/org/springframework/integration/jmx/MBeanTreePollingMessageSource.java index 77f30792ac..c1279e66ac 100644 --- a/spring-integration-jmx/src/main/java/org/springframework/integration/jmx/MBeanTreePollingMessageSource.java +++ b/spring-integration-jmx/src/main/java/org/springframework/integration/jmx/MBeanTreePollingMessageSource.java @@ -34,6 +34,7 @@ import org.springframework.util.Assert; * A {@link MessageSource} implementation that retrieves a snapshot of a filtered subset of the MBean tree. * * @author Stuart Williams + * @author Gary Russell * @since 3.0 * */ @@ -54,6 +55,11 @@ public class MBeanTreePollingMessageSource extends AbstractMessageSource this.converter = converter; } + @Override + public String getComponentType() { + return "jmx:tree-polling-channel-adapter"; + } + /** * Provides the mapped tree object */ diff --git a/spring-integration-mail/src/main/java/org/springframework/integration/mail/MailReceivingMessageSource.java b/spring-integration-mail/src/main/java/org/springframework/integration/mail/MailReceivingMessageSource.java index 62f6822d73..9dd110e55b 100644 --- a/spring-integration-mail/src/main/java/org/springframework/integration/mail/MailReceivingMessageSource.java +++ b/spring-integration-mail/src/main/java/org/springframework/integration/mail/MailReceivingMessageSource.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,9 +25,11 @@ import org.apache.commons.logging.LogFactory; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.BeanFactoryAware; +import org.springframework.beans.factory.BeanNameAware; import org.springframework.integration.core.MessageSource; import org.springframework.integration.support.DefaultMessageBuilderFactory; import org.springframework.integration.support.MessageBuilderFactory; +import org.springframework.integration.support.context.NamedComponent; import org.springframework.integration.support.utils.IntegrationUtils; import org.springframework.messaging.Message; import org.springframework.messaging.MessagingException; @@ -44,7 +46,7 @@ import org.springframework.util.Assert; * @author Oleg Zhurakousky */ public class MailReceivingMessageSource implements MessageSource, - BeanFactoryAware { + BeanFactoryAware, BeanNameAware, NamedComponent { private final Log logger = LogFactory.getLog(this.getClass()); @@ -56,6 +58,8 @@ public class MailReceivingMessageSource implements MessageSource receive() { try { diff --git a/spring-integration-scripting/src/main/java/org/springframework/integration/scripting/ScriptExecutingMessageSource.java b/spring-integration-scripting/src/main/java/org/springframework/integration/scripting/ScriptExecutingMessageSource.java index 295ce57c7b..956793b105 100644 --- a/spring-integration-scripting/src/main/java/org/springframework/integration/scripting/ScriptExecutingMessageSource.java +++ b/spring-integration-scripting/src/main/java/org/springframework/integration/scripting/ScriptExecutingMessageSource.java @@ -1,5 +1,5 @@ /* - * Copyright 2013 the original author or authors. + * Copyright 2013-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,6 +24,7 @@ import org.springframework.integration.endpoint.AbstractMessageSource; * {@linkplain #scriptMessageProcessor} for polling endpoints. * * @author Artem Bilan + * @author Gary Russell * @since 3.0 */ class ScriptExecutingMessageSource extends AbstractMessageSource { @@ -34,6 +35,11 @@ class ScriptExecutingMessageSource extends AbstractMessageSource { this.scriptMessageProcessor = scriptMessageProcessor; } + @Override + public String getComponentType() { + return "inbound-channel-adapter"; + } + @Override protected Object doReceive() { return scriptMessageProcessor.processMessage(null);