Split MessageSource types into 2 sub-interfaces: PollableSource and SubscribableSource. The MessageChannel hierarchy has also been revised accordingly. DirectChannel and PublishSubscribeChannel are now SubscribableSources, while the other queue-based channels are PollableSources. The PollableChannel interface extends BlockingSource which in turn is an extension of PollableSource that adds timeout-aware methods.
This commit is contained in:
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.integration.adapter.file;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@@ -24,24 +23,21 @@ import java.util.Map;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.integration.message.GenericMessage;
|
||||
import org.springframework.integration.message.Message;
|
||||
import org.springframework.integration.message.MessageBuilder;
|
||||
import org.springframework.integration.message.MessageCreator;
|
||||
import org.springframework.integration.message.MessageDeliveryAware;
|
||||
import org.springframework.integration.message.MessagingException;
|
||||
import org.springframework.integration.message.MessageSource;
|
||||
import org.springframework.integration.message.PollableSource;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Base class for implementing a Source that creates messages from files in a
|
||||
* directory, either local or remote.
|
||||
* Base class for implementing a PollableSource that creates messages
|
||||
* from files in a directory, either local or remote.
|
||||
*
|
||||
* @author Marius Bogoevici
|
||||
* @author iwein
|
||||
* @author Iwein Fuld
|
||||
*/
|
||||
public abstract class AbstractDirectorySource<T> implements MessageSource<T>, MessageDeliveryAware {
|
||||
public abstract class AbstractDirectorySource<T> implements PollableSource<T>, MessageDeliveryAware {
|
||||
|
||||
public final static String FILE_INFO_PROPERTY = "file.info";
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ import java.util.Map;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.integration.ConfigurationException;
|
||||
import org.springframework.integration.message.Message;
|
||||
@@ -31,7 +32,6 @@ import org.springframework.integration.message.MessageBuilder;
|
||||
import org.springframework.integration.message.MessageCreator;
|
||||
import org.springframework.integration.message.MessageDeliveryAware;
|
||||
import org.springframework.integration.message.MessagingException;
|
||||
import org.springframework.integration.message.MessageSource;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
@@ -41,7 +41,7 @@ import org.springframework.util.StringUtils;
|
||||
* @author Mark Fisher
|
||||
* @author Marius Bogoevici
|
||||
*/
|
||||
public class FileSource extends AbstractDirectorySource<File> implements MessageSource<File>, MessageDeliveryAware {
|
||||
public class FileSource extends AbstractDirectorySource<File> implements MessageDeliveryAware {
|
||||
|
||||
private final Log logger = LogFactory.getLog(this.getClass());
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ import javax.jms.Destination;
|
||||
|
||||
import org.springframework.integration.message.GenericMessage;
|
||||
import org.springframework.integration.message.Message;
|
||||
import org.springframework.integration.message.MessageSource;
|
||||
import org.springframework.integration.message.PollableSource;
|
||||
import org.springframework.jms.core.JmsTemplate;
|
||||
|
||||
/**
|
||||
@@ -32,7 +32,7 @@ import org.springframework.jms.core.JmsTemplate;
|
||||
*
|
||||
* @author Mark Fisher
|
||||
*/
|
||||
public class JmsSource extends AbstractJmsTemplateBasedAdapter implements MessageSource<Object> {
|
||||
public class JmsSource extends AbstractJmsTemplateBasedAdapter implements PollableSource<Object> {
|
||||
|
||||
public JmsSource(JmsTemplate jmsTemplate) {
|
||||
super(jmsTemplate);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2007 the original author or authors.
|
||||
* Copyright 2002-2008 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.
|
||||
@@ -27,6 +27,7 @@ import javax.mail.internet.MimeMessage;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.beans.factory.DisposableBean;
|
||||
import org.springframework.context.Lifecycle;
|
||||
import org.springframework.integration.adapter.mail.monitor.DefaultLocalMailMessageStore;
|
||||
@@ -34,20 +35,19 @@ import org.springframework.integration.adapter.mail.monitor.LocalMailMessageStor
|
||||
import org.springframework.integration.adapter.mail.monitor.MailTransportUtils;
|
||||
import org.springframework.integration.adapter.mail.monitor.MonitoringStrategy;
|
||||
import org.springframework.integration.message.Message;
|
||||
import org.springframework.integration.message.MessageSource;
|
||||
import org.springframework.integration.message.PollableSource;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* {@link MessageSource} implementation which delegates to a
|
||||
* {@link MonitoringStrategy} to poll a mailbox Each poll of the mailbox may
|
||||
* {@link MonitoringStrategy} to poll a mailbox. Each poll of the mailbox may
|
||||
* return more than one message which will then be stored locally using the
|
||||
* provided {@link LocalMailMessageStore}
|
||||
* @author Jonas Partner
|
||||
*
|
||||
* @author Jonas Partner
|
||||
*/
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public class PollingMailSource implements MessageSource, DisposableBean, Lifecycle {
|
||||
public class PollingMailSource implements PollableSource, DisposableBean, Lifecycle {
|
||||
|
||||
private final Log logger = LogFactory.getLog(this.getClass());
|
||||
|
||||
|
||||
@@ -23,14 +23,14 @@ import java.io.InputStream;
|
||||
import org.springframework.integration.message.GenericMessage;
|
||||
import org.springframework.integration.message.Message;
|
||||
import org.springframework.integration.message.MessagingException;
|
||||
import org.springframework.integration.message.MessageSource;
|
||||
import org.springframework.integration.message.PollableSource;
|
||||
|
||||
/**
|
||||
* A pollable source for receiving bytes from an {@link InputStream}.
|
||||
*
|
||||
* @author Mark Fisher
|
||||
*/
|
||||
public class ByteStreamSource implements MessageSource<byte[]> {
|
||||
public class ByteStreamSource implements PollableSource<byte[]> {
|
||||
|
||||
private BufferedInputStream stream;
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ import java.io.UnsupportedEncodingException;
|
||||
|
||||
import org.springframework.integration.ConfigurationException;
|
||||
import org.springframework.integration.message.MessagingException;
|
||||
import org.springframework.integration.message.MessageSource;
|
||||
import org.springframework.integration.message.PollableSource;
|
||||
import org.springframework.integration.message.StringMessage;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
@@ -33,7 +33,7 @@ import org.springframework.util.Assert;
|
||||
*
|
||||
* @author Mark Fisher
|
||||
*/
|
||||
public class CharacterStreamSource implements MessageSource<String> {
|
||||
public class CharacterStreamSource implements PollableSource<String> {
|
||||
|
||||
private final BufferedReader reader;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user