From 550a674850150ea7b27c5c796baecd50a500698f Mon Sep 17 00:00:00 2001 From: Mark Fisher Date: Wed, 16 Apr 2008 16:38:44 +0000 Subject: [PATCH] committing AbstractSourceAdapter manually (missed by plugin) --- .../adapter/AbstractSourceAdapter.java | 55 +++---------------- 1 file changed, 9 insertions(+), 46 deletions(-) diff --git a/spring-integration-core/src/main/java/org/springframework/integration/adapter/AbstractSourceAdapter.java b/spring-integration-core/src/main/java/org/springframework/integration/adapter/AbstractSourceAdapter.java index 10a77a18af..b1c9f6c52b 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/adapter/AbstractSourceAdapter.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/adapter/AbstractSourceAdapter.java @@ -16,36 +16,26 @@ package org.springframework.integration.adapter; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import org.springframework.beans.factory.InitializingBean; -import org.springframework.integration.ConfigurationException; import org.springframework.integration.channel.MessageChannel; import org.springframework.integration.message.Message; import org.springframework.util.Assert; /** - * A base class providing common behavior for source adapters. - * * @author Mark Fisher */ -public abstract class AbstractSourceAdapter implements SourceAdapter, InitializingBean { +public abstract class AbstractSourceAdapter implements SourceAdapter { - protected Log logger = LogFactory.getLog(this.getClass()); + private final MessageChannel channel; - private MessageChannel channel; - - private long sendTimeout = -1; - - private volatile boolean initialized = false; + private volatile long sendTimeout = -1; - public void setChannel(MessageChannel channel) { - Assert.notNull(channel, "'channel' must not be null"); + public AbstractSourceAdapter(MessageChannel channel) { + Assert.notNull(channel, "channel must not be null"); this.channel = channel; } + protected MessageChannel getChannel() { return this.channel; } @@ -54,38 +44,11 @@ public abstract class AbstractSourceAdapter implements SourceAdapter, Initial this.sendTimeout = sendTimeout; } - public final void afterPropertiesSet() { - if (this.channel == null) { - throw new ConfigurationException("'channel' is required"); - } - this.initialize(); - this.initialized = true; - } - - protected boolean isInitialized() { - return this.initialized; - } - - /** - * Subclasses may implement this to take advantage of the initialization callback. - */ - protected void initialize() { - } - - protected boolean sendToChannel(Message message) { - if (!this.initialized) { - this.afterPropertiesSet(); - } + protected boolean sendToChannel(Message message) { if (message == null) { - if (logger.isDebugEnabled()) { - logger.debug("adapter attempted to send a null object"); - } - return false; + throw new IllegalArgumentException("message must not be null"); } - if (this.sendTimeout < 0) { - return this.channel.send(message); - } - return this.channel.send(message, this.sendTimeout); + return (this.sendTimeout < 0) ? this.channel.send(message) : this.channel.send(message, this.sendTimeout); } }