simplified demo main
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2009 the original author or authors.
|
||||
* Copyright 2002-2010 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.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2009 the original author or authors.
|
||||
* Copyright 2002-2010 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.
|
||||
@@ -16,11 +16,8 @@
|
||||
|
||||
package org.springframework.integration.samples.helloworld;
|
||||
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.support.AbstractApplicationContext;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.integration.channel.BeanFactoryChannelResolver;
|
||||
import org.springframework.integration.channel.ChannelResolver;
|
||||
import org.springframework.integration.channel.PollableChannel;
|
||||
import org.springframework.integration.core.MessageChannel;
|
||||
import org.springframework.integration.message.StringMessage;
|
||||
@@ -31,8 +28,7 @@ import org.springframework.integration.message.StringMessage;
|
||||
* low-level example, using Message Channels directly for both input and
|
||||
* output. Notice that the output channel has a queue sub-element. It is
|
||||
* therefore a PollableChannel and its consumers must invoke receive() as
|
||||
* demonstrated below. The {@link BeanFactoryChannelResolver} is used here
|
||||
* rather than performing a generic dependency lookup from the context.
|
||||
* demonstrated below.
|
||||
* <p>
|
||||
* View the configuration of the channels and the endpoint (a <service-activator/>
|
||||
* element) in 'helloWorldDemo.xml' within this same package.
|
||||
@@ -43,19 +39,11 @@ import org.springframework.integration.message.StringMessage;
|
||||
public class HelloWorldDemo {
|
||||
|
||||
public static void main(String[] args) {
|
||||
HelloWorldDemo demo = new HelloWorldDemo();
|
||||
AbstractApplicationContext applicationContext = new ClassPathXmlApplicationContext("helloWorldDemo.xml", HelloWorldDemo.class);
|
||||
demo.performDemo(applicationContext);
|
||||
applicationContext.stop();
|
||||
}
|
||||
|
||||
|
||||
public void performDemo(ApplicationContext applicationContext) {
|
||||
ChannelResolver channelResolver = new BeanFactoryChannelResolver(applicationContext);
|
||||
MessageChannel inputChannel = channelResolver.resolveChannelName("inputChannel");
|
||||
PollableChannel outputChannel = (PollableChannel) channelResolver.resolveChannelName("outputChannel");
|
||||
AbstractApplicationContext context = new ClassPathXmlApplicationContext("helloWorldDemo.xml", HelloWorldDemo.class);
|
||||
MessageChannel inputChannel = context.getBean("inputChannel", MessageChannel.class);
|
||||
PollableChannel outputChannel = context.getBean("outputChannel", PollableChannel.class);
|
||||
inputChannel.send(new StringMessage("World"));
|
||||
System.out.println("==> HelloWorldDemo: " + outputChannel.receive(0).getPayload());
|
||||
System.out.println("==> HelloWorldDemo: " + outputChannel.receive(0).getPayload());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user