Renamed DefaultMessageEndpoint to GenericMessageEndpoint
This commit is contained in:
@@ -41,7 +41,7 @@ import org.springframework.integration.message.Message;
|
||||
*
|
||||
* @author Mark Fisher
|
||||
*/
|
||||
public class DefaultMessageEndpoint {
|
||||
public class GenericMessageEndpoint {
|
||||
|
||||
private MessageSource source;
|
||||
|
||||
@@ -60,27 +60,48 @@ public class DefaultMessageEndpoint {
|
||||
private Object lifecycleMonitor = new Object();
|
||||
|
||||
|
||||
public DefaultMessageEndpoint(MessageSource source) {
|
||||
/**
|
||||
* Create an endpoint to consume messages from the given source.
|
||||
*/
|
||||
public GenericMessageEndpoint(MessageSource source) {
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the target to which this endpoint can send messages.
|
||||
*/
|
||||
public void setTarget(MessageTarget target) {
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a handler to be invoked for each consumed message.
|
||||
*/
|
||||
public void setHandler(MessageHandler handler) {
|
||||
this.handler = handler;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the consumer type to use for this endpoint's source.
|
||||
* @see ConsumerType
|
||||
*/
|
||||
public void setConsumerType(ConsumerType consumerType) {
|
||||
this.consumerType = consumerType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the channel resolver strategy to use when a message
|
||||
* provides a '<i>replyChannelName</i>'.
|
||||
*/
|
||||
public void setChannelResolver(ChannelResolver channelResolver) {
|
||||
this.channelResolver = channelResolver;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create a consumer based upon the specified consumer type.
|
||||
*/
|
||||
protected AbstractConsumer createDefaultConsumer() {
|
||||
MessageHandler handlerAdapter = new MessageHandlerAdapter();
|
||||
if (this.consumerType.equals(ConsumerType.EVENT_DRIVEN)) {
|
||||
@@ -98,6 +119,9 @@ public class DefaultMessageEndpoint {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Start the consumer.
|
||||
*/
|
||||
public final void start() {
|
||||
synchronized (this.lifecycleMonitor) {
|
||||
if (this.source != null && this.consumer == null) {
|
||||
@@ -108,6 +132,9 @@ public class DefaultMessageEndpoint {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop the consumer.
|
||||
*/
|
||||
public final void stop() {
|
||||
synchronized (this.lifecycleMonitor) {
|
||||
if (this.running) {
|
||||
@@ -119,6 +146,9 @@ public class DefaultMessageEndpoint {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether this endpoint is running (and hence its consumer).
|
||||
*/
|
||||
public final boolean isRunning() {
|
||||
synchronized (this.lifecycleMonitor) {
|
||||
return this.running;
|
||||
@@ -138,7 +168,7 @@ public class DefaultMessageEndpoint {
|
||||
MessageTarget replyTarget = resolveReplyTarget(message);
|
||||
if (replyTarget == null) {
|
||||
throw new MessageHandlingException("Unable to determine reply target for message. "
|
||||
+ "Provide a 'replyChannelName' in the message header or a 'defaultReplyChannel' "
|
||||
+ "Provide a 'replyChannelName' in the message header or a 'target' "
|
||||
+ "on the message endpoint.");
|
||||
}
|
||||
replyTarget.send(replyMessage);
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright 2002-2007 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.endpoint;
|
||||
|
||||
/**
|
||||
* Base interface for message endpoints.
|
||||
*
|
||||
* @author Mark Fisher
|
||||
*/
|
||||
public interface MessageEndpoint {
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user