INT-3372 Add NamedComponent to Remaining MsgSrcs

JIRA: https://jira.spring.io/browse/INT-3372
This commit is contained in:
Gary Russell
2014-04-15 18:36:32 -04:00
committed by Artem Bilan
parent c4a7d22a35
commit 17c6f8a350
8 changed files with 85 additions and 12 deletions

View File

@@ -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<javax.mail.Message>,
BeanFactoryAware {
BeanFactoryAware, BeanNameAware, NamedComponent {
private final Log logger = LogFactory.getLog(this.getClass());
@@ -56,6 +58,8 @@ public class MailReceivingMessageSource implements MessageSource<javax.mail.Mess
private volatile MessageBuilderFactory messageBuilderFactory = new DefaultMessageBuilderFactory();
private volatile String beanName;
public MailReceivingMessageSource(MailReceiver mailReceiver) {
Assert.notNull(mailReceiver, "mailReceiver must not be null");
@@ -76,6 +80,21 @@ public class MailReceivingMessageSource implements MessageSource<javax.mail.Mess
return messageBuilderFactory;
}
@Override
public String getComponentName() {
return this.beanName;
}
@Override
public String getComponentType() {
return "mail:inbound-channel-adapter";
}
@Override
public void setBeanName(String name) {
this.beanName = name;
}
@Override
public Message<javax.mail.Message> receive() {
try {