Removed TargetEndpoint.
This commit is contained in:
@@ -17,17 +17,13 @@
|
||||
package org.springframework.integration.adapter.event;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.context.ApplicationEvent;
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
import org.springframework.integration.bus.DefaultMessageBus;
|
||||
import org.springframework.integration.bus.MessageBus;
|
||||
import org.springframework.integration.channel.MessageChannel;
|
||||
import org.springframework.integration.dispatcher.DirectChannel;
|
||||
import org.springframework.integration.message.Message;
|
||||
import org.springframework.integration.message.StringMessage;
|
||||
|
||||
/**
|
||||
@@ -38,23 +34,29 @@ public class ApplicationEventTargetTests {
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testSendingEvent() throws InterruptedException {
|
||||
final CountDownLatch latch = new CountDownLatch(1);
|
||||
ApplicationEventPublisher publisher = new ApplicationEventPublisher() {
|
||||
public void publishEvent(ApplicationEvent event) {
|
||||
latch.countDown();
|
||||
}
|
||||
};
|
||||
MessageChannel channel = new DirectChannel();
|
||||
TestApplicationEventPublisher publisher = new TestApplicationEventPublisher();
|
||||
ApplicationEventTarget adapter = new ApplicationEventTarget();
|
||||
adapter.setApplicationEventPublisher(publisher);
|
||||
MessageBus bus = new DefaultMessageBus();
|
||||
bus.registerChannel("channel", channel);
|
||||
bus.registerTarget("adapter", adapter, channel, null);
|
||||
bus.start();
|
||||
assertEquals(1, latch.getCount());
|
||||
channel.send(new StringMessage("testing"));
|
||||
assertEquals(0, latch.getCount());
|
||||
bus.stop();
|
||||
assertNull(publisher.getLastEvent());
|
||||
Message<?> message = new StringMessage("testing");
|
||||
adapter.send(message);
|
||||
ApplicationEvent event = publisher.getLastEvent();
|
||||
assertEquals(MessagingEvent.class, event.getClass());
|
||||
assertEquals(message, ((MessagingEvent<?>) event).getMessage());
|
||||
}
|
||||
|
||||
|
||||
private static class TestApplicationEventPublisher implements ApplicationEventPublisher {
|
||||
|
||||
private volatile ApplicationEvent lastEvent;
|
||||
|
||||
public ApplicationEvent getLastEvent() {
|
||||
return this.lastEvent;
|
||||
}
|
||||
|
||||
public void publishEvent(ApplicationEvent event) {
|
||||
this.lastEvent = event;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -52,7 +52,6 @@ import org.springframework.integration.endpoint.EndpointRegistry;
|
||||
import org.springframework.integration.endpoint.HandlerEndpoint;
|
||||
import org.springframework.integration.endpoint.MessageEndpoint;
|
||||
import org.springframework.integration.endpoint.MessagingGateway;
|
||||
import org.springframework.integration.endpoint.TargetEndpoint;
|
||||
import org.springframework.integration.handler.MessageHandler;
|
||||
import org.springframework.integration.message.MessageSource;
|
||||
import org.springframework.integration.message.MessageTarget;
|
||||
@@ -266,13 +265,6 @@ public class DefaultMessageBus implements MessageBus, ApplicationContextAware, A
|
||||
this.registerEndpoint(endpoint);
|
||||
}
|
||||
|
||||
public void registerTarget(String name, MessageTarget target, Object input, Schedule schedule) {
|
||||
Assert.notNull(target, "'target' must not be null");
|
||||
TargetEndpoint endpoint = new TargetEndpoint(target);
|
||||
this.configureEndpoint(endpoint, name, input, schedule);
|
||||
this.registerEndpoint(endpoint);
|
||||
}
|
||||
|
||||
private void configureEndpoint(AbstractEndpoint endpoint, String name, Object input, Schedule schedule) {
|
||||
endpoint.setName(name);
|
||||
if (input instanceof MessageChannel) {
|
||||
|
||||
@@ -23,7 +23,6 @@ import org.springframework.integration.channel.MessageChannel;
|
||||
import org.springframework.integration.channel.factory.ChannelFactory;
|
||||
import org.springframework.integration.endpoint.EndpointRegistry;
|
||||
import org.springframework.integration.handler.MessageHandler;
|
||||
import org.springframework.integration.message.MessageTarget;
|
||||
import org.springframework.integration.scheduling.Schedule;
|
||||
|
||||
/**
|
||||
@@ -39,6 +38,4 @@ public interface MessageBus extends ChannelRegistry, EndpointRegistry, Lifecycle
|
||||
|
||||
void registerHandler(String name, MessageHandler handler, Object input, Schedule schedule);
|
||||
|
||||
void registerTarget(String name, MessageTarget target, Object input, Schedule schedule);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
/*
|
||||
* 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.
|
||||
* 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;
|
||||
|
||||
import org.springframework.integration.message.MessageTarget;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* Base class for {@link MessageEndpoint} implementations to which Messages may be sent.
|
||||
*
|
||||
* @author Mark Fisher
|
||||
*/
|
||||
public class TargetEndpoint extends AbstractEndpoint {
|
||||
|
||||
public TargetEndpoint() {
|
||||
}
|
||||
|
||||
public TargetEndpoint(MessageTarget target) {
|
||||
Assert.notNull(target, "target must not be null");
|
||||
this.setTarget(target);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user