INT-4524: Fix MailReceivingMessageSource BF usage
JIRA: https://jira.spring.io/browse/INT-4524
This commit is contained in:
committed by
Gary Russell
parent
8f639ad0d6
commit
e053e2ab4a
@@ -41,9 +41,6 @@ import java.util.concurrent.PriorityBlockingQueue;
|
|||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
|
||||||
import org.apache.commons.logging.LogFactory;
|
|
||||||
|
|
||||||
import org.springframework.context.Lifecycle;
|
import org.springframework.context.Lifecycle;
|
||||||
import org.springframework.integration.aggregator.ResequencingMessageGroupProcessor;
|
import org.springframework.integration.aggregator.ResequencingMessageGroupProcessor;
|
||||||
import org.springframework.integration.core.MessageSource;
|
import org.springframework.integration.core.MessageSource;
|
||||||
@@ -89,8 +86,6 @@ public class FileReadingMessageSource extends AbstractMessageSource<File>
|
|||||||
|
|
||||||
private static final int DEFAULT_INTERNAL_QUEUE_CAPACITY = 5;
|
private static final int DEFAULT_INTERNAL_QUEUE_CAPACITY = 5;
|
||||||
|
|
||||||
private static final Log logger = LogFactory.getLog(FileReadingMessageSource.class);
|
|
||||||
|
|
||||||
private final AtomicBoolean running = new AtomicBoolean();
|
private final AtomicBoolean running = new AtomicBoolean();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -20,15 +20,8 @@ import java.util.Arrays;
|
|||||||
import java.util.Queue;
|
import java.util.Queue;
|
||||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
|
||||||
import org.apache.commons.logging.LogFactory;
|
|
||||||
|
|
||||||
import org.springframework.beans.factory.BeanFactory;
|
|
||||||
import org.springframework.integration.core.MessageSource;
|
import org.springframework.integration.core.MessageSource;
|
||||||
import org.springframework.integration.endpoint.AbstractMessageSource;
|
import org.springframework.integration.endpoint.AbstractMessageSource;
|
||||||
import org.springframework.integration.support.DefaultMessageBuilderFactory;
|
|
||||||
import org.springframework.integration.support.MessageBuilderFactory;
|
|
||||||
import org.springframework.integration.support.utils.IntegrationUtils;
|
|
||||||
import org.springframework.messaging.Message;
|
import org.springframework.messaging.Message;
|
||||||
import org.springframework.messaging.MessagingException;
|
import org.springframework.messaging.MessagingException;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
@@ -46,60 +39,21 @@ import org.springframework.util.Assert;
|
|||||||
*/
|
*/
|
||||||
public class MailReceivingMessageSource extends AbstractMessageSource<Object> {
|
public class MailReceivingMessageSource extends AbstractMessageSource<Object> {
|
||||||
|
|
||||||
private final Log logger = LogFactory.getLog(this.getClass());
|
|
||||||
|
|
||||||
private final MailReceiver mailReceiver;
|
private final MailReceiver mailReceiver;
|
||||||
|
|
||||||
private final Queue<Object> mailQueue = new ConcurrentLinkedQueue<>();
|
private final Queue<Object> mailQueue = new ConcurrentLinkedQueue<>();
|
||||||
|
|
||||||
private BeanFactory beanFactory;
|
|
||||||
|
|
||||||
private MessageBuilderFactory messageBuilderFactory = new DefaultMessageBuilderFactory();
|
|
||||||
|
|
||||||
private boolean messageBuilderFactorySet;
|
|
||||||
|
|
||||||
private String beanName;
|
|
||||||
|
|
||||||
|
|
||||||
public MailReceivingMessageSource(MailReceiver mailReceiver) {
|
public MailReceivingMessageSource(MailReceiver mailReceiver) {
|
||||||
Assert.notNull(mailReceiver, "mailReceiver must not be null");
|
Assert.notNull(mailReceiver, "mailReceiver must not be null");
|
||||||
this.mailReceiver = mailReceiver;
|
this.mailReceiver = mailReceiver;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public final void setBeanFactory(BeanFactory beanFactory) {
|
|
||||||
this.beanFactory = beanFactory;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected BeanFactory getBeanFactory() {
|
|
||||||
return this.beanFactory;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected MessageBuilderFactory getMessageBuilderFactory() {
|
|
||||||
if (!this.messageBuilderFactorySet) {
|
|
||||||
if (this.beanFactory != null) {
|
|
||||||
this.messageBuilderFactory = IntegrationUtils.getMessageBuilderFactory(this.beanFactory);
|
|
||||||
}
|
|
||||||
this.messageBuilderFactorySet = true;
|
|
||||||
}
|
|
||||||
return this.messageBuilderFactory;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getComponentName() {
|
|
||||||
return this.beanName;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getComponentType() {
|
public String getComponentType() {
|
||||||
return "mail:inbound-channel-adapter";
|
return "mail:inbound-channel-adapter";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setBeanName(String name) {
|
|
||||||
this.beanName = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Object doReceive() {
|
protected Object doReceive() {
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user