Changes to make 'mvn clean test' succeed, add .springBean configuration where missing.

This commit is contained in:
Rossen Stoyanchev
2010-12-17 11:56:25 +00:00
parent f1357b0cf3
commit 434a9e678d
59 changed files with 363 additions and 51 deletions

View File

@@ -0,0 +1,76 @@
/*
* 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.
* 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.samples.xml;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;
import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.integration.MessageChannel;
import org.springframework.integration.message.GenericMessage;
/**
* This example demonstrates the processing of an order for books using
* several of the components provided by the Spring Integration Xml
* module for dealing with Xml payloads. This includes:
*
* <ul>
* <li>an XPath based implementation of the splitter pattern to split an
* order with multiple items into several order messages for separate
* processing.</li>
* <li>XPath expression namespace support to build an XPath expression to
* extract the isbn from each order item.</li>
* <li>an XPath router implementation to route messages according to the
* evaluation of an XPath expression which tests to see if the order item is in
* stock.</li>
* <li>an XSLT transformer implementation to transform the payload of the
* order message into a resupply message where the order item is found to be
* out of stock.</li>
* </ul>
*
* @author Jonas Partner
*/
public class BookOrderProcessingTestApp {
public static void main(String[] args) throws Exception {
AbstractApplicationContext applicationContext =
new ClassPathXmlApplicationContext("/META-INF/spring/integration/orderProcessingSample.xml",
BookOrderProcessingTestApp.class);
MessageChannel messageChannel = (MessageChannel) applicationContext.getBean("ordersChannel");
GenericMessage<Document> orderMessage =
createXmlMessageFromResource("META-INF/spring/integration/order.xml");
messageChannel.send(orderMessage);
applicationContext.close();
}
private static GenericMessage<Document> createXmlMessageFromResource(String path) throws Exception {
Resource orderRes = new ClassPathResource(path);
DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
builderFactory.setNamespaceAware(true);
DocumentBuilder builder = builderFactory.newDocumentBuilder();
Document orderDoc = builder.parse(orderRes.getInputStream());
return new GenericMessage<Document>(orderDoc);
}
}

View File

@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
<!-- Appenders -->
<appender name="console" class="org.apache.log4j.ConsoleAppender">
<param name="Target" value="System.out" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%-5p: %c - %m%n" />
</layout>
</appender>
<!-- Loggers -->
<logger name="org.springframework">
<level value="warn" />
</logger>
<logger name="org.springframework.integration.samples">
<level value="debug" />
</logger>
<!-- Root Logger -->
<root>
<priority value="warn" />
<appender-ref ref="console" />
</root>
</log4j:configuration>