Migrated the stream-based adapters from the "adapters" module to "org.springframework.integration.stream" (INT-375).

This commit is contained in:
Mark Fisher
2008-09-17 20:32:47 +00:00
parent 5676667c06
commit 9f2b0af8c3
28 changed files with 151 additions and 81 deletions

View File

@@ -255,35 +255,6 @@
</xsd:complexType>
</xsd:element>
<xsd:element name="console-source">
<xsd:complexType>
<xsd:annotation>
<xsd:documentation>
Configures a source that reads from stdin (System.in).
</xsd:documentation>
</xsd:annotation>
<xsd:attribute name="id" type="xsd:string"/>
<xsd:attribute name="charset" type="xsd:string"/>
</xsd:complexType>
</xsd:element>
<xsd:element name="stdout-channel-adapter" type="consoleOutboundChannelAdapterType"/>
<xsd:element name="stderr-channel-adapter" type="consoleOutboundChannelAdapterType"/>
<xsd:complexType name="consoleOutboundChannelAdapterType">
<xsd:annotation>
<xsd:documentation>
Configures an outbound Channel Adapter that writes to stdout (System.out)
or to stderr (System.err) depending on the element name.
</xsd:documentation>
</xsd:annotation>
<xsd:attribute name="id" type="xsd:string"/>
<xsd:attribute name="channel" type="xsd:string"/>
<xsd:attribute name="charset" type="xsd:string"/>
<xsd:attribute name="append-newline" type="xsd:boolean" default="false"/>
</xsd:complexType>
<xsd:complexType name="gatewayType">
<xsd:annotation>
<xsd:documentation>

View File

@@ -1,4 +1,3 @@
console-source=org.springframework.integration.adapter.stream.config.ConsoleSourceParser
file-source=org.springframework.integration.adapter.file.config.FileSourceParser
file-target=org.springframework.integration.adapter.file.config.FileTargetParser
ftp-source=org.springframework.integration.adapter.ftp.config.FtpSourceParser
@@ -11,6 +10,4 @@ mail-target=org.springframework.integration.adapter.mail.config.MailTargetParser
polling-mail-source=org.springframework.integration.adapter.mail.config.PollingMailSourceParser
imap-idle-mail-source=org.springframework.integration.adapter.mail.config.SubscribableImapIdleMailSourceParser
rmi-gateway=org.springframework.integration.adapter.rmi.config.RmiGatewayParser
rmi-handler=org.springframework.integration.adapter.rmi.config.RmiHandlerParser
stderr-channel-adapter=org.springframework.integration.adapter.stream.config.ConsoleTargetParser
stdout-channel-adapter=org.springframework.integration.adapter.stream.config.ConsoleTargetParser
rmi-handler=org.springframework.integration.adapter.rmi.config.RmiHandlerParser

View File

@@ -19,5 +19,6 @@
<classpathentry combineaccessrules="false" kind="src" path="/org.springframework.integration.adapter"/>
<classpathentry combineaccessrules="false" kind="src" path="/org.springframework.integration.ws"/>
<classpathentry combineaccessrules="false" kind="src" path="/org.springframework.integration.quartz"/>
<classpathentry combineaccessrules="false" kind="src" path="/org.springframework.integration.stream"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>

View File

@@ -3,12 +3,15 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:stream="http://www.springframework.org/schema/integration/stream"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/integration
http://www.springframework.org/schema/integration/spring-integration-1.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd">
http://www.springframework.org/schema/integration/stream
http://www.springframework.org/schema/integration/stream/spring-integration-stream-1.0.xsd">
<message-bus/>
<annotation-driven/>
@@ -30,6 +33,6 @@
<channel id="preparedDrinks"/>
<stdout-channel-adapter id="deliveries"/>
<stream:stdout-channel-adapter id="deliveries"/>
</beans:beans>

View File

@@ -2,11 +2,13 @@
<beans:beans xmlns="http://www.springframework.org/schema/integration"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:stream="http://www.springframework.org/schema/integration/stream"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/integration
http://www.springframework.org/schema/integration/spring-integration-1.0.xsd">
http://www.springframework.org/schema/integration/spring-integration-1.0.xsd
http://www.springframework.org/schema/integration/stream
http://www.springframework.org/schema/integration/stream/spring-integration-stream-1.0.xsd">
<message-bus/>
@@ -31,7 +33,7 @@
<channel id="preparedDrinks"/>
<aggregator input-channel="preparedDrinks" ref="waiter" method="prepareDelivery" output-channel="deliveries"/>
<stdout-channel-adapter id="deliveries"/>
<stream:stdout-channel-adapter id="deliveries"/>
<beans:bean id="orderSplitter" class="org.springframework.integration.samples.cafe.xml.OrderSplitter"/>

View File

@@ -2,10 +2,13 @@
<beans:beans xmlns="http://www.springframework.org/schema/integration"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:stream="http://www.springframework.org/schema/integration/stream"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/integration
http://www.springframework.org/schema/integration/spring-integration-1.0.xsd">
http://www.springframework.org/schema/integration/spring-integration-1.0.xsd
http://www.springframework.org/schema/integration/stream
http://www.springframework.org/schema/integration/stream/spring-integration-stream-1.0.xsd">
<message-bus/>
@@ -15,6 +18,6 @@
<beans:bean class="org.springframework.integration.samples.quote.QuoteService"/>
<stdout-channel-adapter id="quotes" append-newline="true"/>
<stream:stdout-channel-adapter id="quotes" append-newline="true"/>
</beans:beans>

View File

@@ -2,10 +2,13 @@
<beans:beans xmlns="http://www.springframework.org/schema/integration"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:stream="http://www.springframework.org/schema/integration/stream"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/integration
http://www.springframework.org/schema/integration/spring-integration-ws-1.0.xsd">
http://www.springframework.org/schema/integration/spring-integration-ws-1.0.xsd
http://www.springframework.org/schema/integration/stream
http://www.springframework.org/schema/integration/stream/spring-integration-stream-1.0.xsd">
<message-bus/>
@@ -19,6 +22,6 @@
uri="http://www.w3schools.com/webservices/tempconvert.asmx"/>
<!-- The response from the service is logged to the console. -->
<stdout-channel-adapter id="celsiusChannel"/>
<stream:stdout-channel-adapter id="celsiusChannel"/>
</beans:beans>

View File

@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src/main/java"/>
<classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
<classpathentry kind="src" path="src/main/resources"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="var" path="IVY_CACHE/org.apache.commons/com.springsource.org.apache.commons.logging/1.1.1/com.springsource.org.apache.commons.logging-1.1.1.jar" sourcepath="/IVY_CACHE/org.apache.commons/com.springsource.org.apache.commons.logging/1.1.1/com.springsource.org.apache.commons.logging-sources-1.1.1.jar"/>
<classpathentry kind="var" path="IVY_CACHE/org.junit/com.springsource.org.junit/4.4.0/com.springsource.org.junit-4.4.0.jar" sourcepath="/IVY_CACHE/org.junit/com.springsource.org.junit/4.4.0/com.springsource.org.junit-sources-4.4.0.jar"/>
<classpathentry kind="var" path="IVY_CACHE/org.springframework/org.springframework.beans/2.5.5.A/org.springframework.beans-2.5.5.A.jar" sourcepath="/IVY_CACHE/org.springframework/org.springframework.beans/2.5.5.A/org.springframework.beans-sources-2.5.5.A.jar"/>
<classpathentry kind="var" path="IVY_CACHE/org.springframework/org.springframework.context/2.5.5.A/org.springframework.context-2.5.5.A.jar" sourcepath="/IVY_CACHE/org.springframework/org.springframework.context/2.5.5.A/org.springframework.context-sources-2.5.5.A.jar"/>
<classpathentry kind="var" path="IVY_CACHE/org.springframework/org.springframework.core/2.5.5.A/org.springframework.core-2.5.5.A.jar" sourcepath="/IVY_CACHE/org.springframework/org.springframework.core/2.5.5.A/org.springframework.core-sources-2.5.5.A.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/org.springframework.integration"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.integration.adapter.stream;
package org.springframework.integration.stream;
import java.io.BufferedInputStream;
import java.io.IOException;

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.integration.adapter.stream;
package org.springframework.integration.stream;
import java.io.BufferedOutputStream;
import java.io.IOException;

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.integration.adapter.stream;
package org.springframework.integration.stream;
import java.io.BufferedReader;
import java.io.IOException;

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.integration.adapter.stream;
package org.springframework.integration.stream;
import java.io.BufferedWriter;
import java.io.IOException;

View File

@@ -14,44 +14,33 @@
* limitations under the License.
*/
package org.springframework.integration.adapter.stream.config;
package org.springframework.integration.stream.config;
import org.w3c.dom.Element;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser;
import org.springframework.integration.adapter.stream.CharacterStreamSource;
import org.springframework.beans.factory.support.BeanDefinitionReaderUtils;
import org.springframework.beans.factory.xml.ParserContext;
import org.springframework.integration.config.AbstractInboundChannelAdapterParser;
import org.springframework.integration.stream.CharacterStreamSource;
import org.springframework.util.StringUtils;
/**
* Parser for the &lt;console-source&gt; element.
* Parser for the &lt;stdin-channel-adapter&gt; element.
*
* @author Mark Fisher
*/
public class ConsoleSourceParser extends AbstractSingleBeanDefinitionParser {
public class ConsoleSourceParser extends AbstractInboundChannelAdapterParser {
@Override
protected Class<?> getBeanClass(Element element) {
return CharacterStreamSource.class;
}
@Override
protected boolean shouldGenerateId() {
return false;
}
@Override
protected boolean shouldGenerateIdAsFallback() {
return true;
}
@Override
protected void doParse(Element element, BeanDefinitionBuilder builder) {
protected String parseSource(Element element, ParserContext parserContext) {
BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(CharacterStreamSource.class);
builder.setFactoryMethod("stdin");
String charsetName = element.getAttribute("charset");
if (StringUtils.hasText(charsetName)) {
builder.addConstructorArgValue(charsetName);
}
return BeanDefinitionReaderUtils.registerWithGeneratedName(builder.getBeanDefinition(), parserContext.getRegistry());
}
}

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.integration.adapter.stream.config;
package org.springframework.integration.stream.config;
import org.w3c.dom.Element;
@@ -26,8 +26,8 @@ import org.springframework.beans.factory.support.BeanDefinitionReaderUtils;
import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser;
import org.springframework.beans.factory.xml.ParserContext;
import org.springframework.integration.ConfigurationException;
import org.springframework.integration.adapter.stream.CharacterStreamTarget;
import org.springframework.integration.channel.DirectChannel;
import org.springframework.integration.stream.CharacterStreamTarget;
import org.springframework.util.StringUtils;
/**

View File

@@ -0,0 +1,32 @@
/*
* 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.stream.config;
import org.springframework.beans.factory.xml.NamespaceHandlerSupport;
/**
* @author Mark Fisher
*/
public class StreamNamespaceHandler extends NamespaceHandlerSupport {
public void init() {
this.registerBeanDefinitionParser("stdin-channel-adapter", new ConsoleSourceParser());
this.registerBeanDefinitionParser("stdout-channel-adapter", new ConsoleTargetParser());
this.registerBeanDefinitionParser("stderr-channel-adapter", new ConsoleTargetParser());
}
}

View File

@@ -0,0 +1,53 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns="http://www.springframework.org/schema/integration/stream"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:tool="http://www.springframework.org/schema/tool"
xmlns:integration="http://www.springframework.org/schema/integration"
targetNamespace="http://www.springframework.org/schema/integration/stream"
elementFormDefault="qualified"
attributeFormDefault="unqualified">
<xsd:import namespace="http://www.springframework.org/schema/beans"/>
<xsd:import namespace="http://www.springframework.org/schema/tool"/>
<xsd:import namespace="http://www.springframework.org/schema/integration"/>
<xsd:annotation>
<xsd:documentation><![CDATA[
Defines the configuration elements for Spring Integration Stream-based Channel Adapters.
]]></xsd:documentation>
</xsd:annotation>
<xsd:element name="stdin-channel-adapter">
<xsd:annotation>
<xsd:documentation>
Configures a source that reads from stdin (System.in).
</xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="integration:poller" minOccurs="0" maxOccurs="1"/>
</xsd:sequence>
<xsd:attribute name="id" type="xsd:string"/>
<xsd:attribute name="charset" type="xsd:string"/>
</xsd:complexType>
</xsd:element>
<xsd:element name="stdout-channel-adapter" type="consoleOutboundChannelAdapterType"/>
<xsd:element name="stderr-channel-adapter" type="consoleOutboundChannelAdapterType"/>
<xsd:complexType name="consoleOutboundChannelAdapterType">
<xsd:annotation>
<xsd:documentation>
Configures an outbound Channel Adapter that writes to stdout (System.out)
or to stderr (System.err) depending on the element name.
</xsd:documentation>
</xsd:annotation>
<xsd:attribute name="id" type="xsd:string"/>
<xsd:attribute name="channel" type="xsd:string"/>
<xsd:attribute name="charset" type="xsd:string"/>
<xsd:attribute name="append-newline" type="xsd:boolean" default="false"/>
</xsd:complexType>
</xsd:schema>

View File

@@ -0,0 +1 @@
http\://www.springframework.org/schema/integration/stream=org.springframework.integration.stream.config.StreamNamespaceHandler

View File

@@ -0,0 +1 @@
http\://www.springframework.org/schema/integration/stream/spring-integration-stream-1.0.xsd=org/springframework/integration/stream/config/spring-integration-stream-1.0.xsd

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.integration.adapter.stream;
package org.springframework.integration.stream;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.integration.adapter.stream;
package org.springframework.integration.stream;
import static org.junit.Assert.assertEquals;

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.integration.adapter.stream;
package org.springframework.integration.stream;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.integration.adapter.stream;
package org.springframework.integration.stream;
import static org.junit.Assert.assertEquals;

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.integration.adapter.stream.config;
package org.springframework.integration.stream.config;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
@@ -33,8 +33,8 @@ import org.springframework.beans.DirectFieldAccessor;
import org.springframework.beans.factory.BeanCreationException;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.integration.ConfigurationException;
import org.springframework.integration.adapter.stream.CharacterStreamSource;
import org.springframework.integration.message.Message;
import org.springframework.integration.stream.CharacterStreamSource;
/**
* @author Mark Fisher

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.integration.adapter.stream.config;
package org.springframework.integration.stream.config;
import static org.junit.Assert.assertEquals;
@@ -33,8 +33,8 @@ import org.springframework.beans.DirectFieldAccessor;
import org.springframework.beans.factory.BeanCreationException;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.integration.ConfigurationException;
import org.springframework.integration.adapter.stream.CharacterStreamTarget;
import org.springframework.integration.message.StringMessage;
import org.springframework.integration.stream.CharacterStreamTarget;
/**
* @author Mark Fisher

View File

@@ -7,8 +7,8 @@
http://www.springframework.org/schema/integration
http://www.springframework.org/schema/integration/spring-integration-1.0.xsd">
<console-source id="sourceWithDefaultCharset"/>
<stdin-channel-adapter id="sourceWithDefaultCharset"/>
<console-source id="sourceWithProvidedCharset" charset="UTF-8"/>
<stdin-channel-adapter id="sourceWithProvidedCharset" charset="UTF-8"/>
</beans:beans>

View File

@@ -7,6 +7,6 @@
http://www.springframework.org/schema/integration
http://www.springframework.org/schema/integration/spring-integration-1.0.xsd">
<console-source id="sourceWithInvalidCharset" charset="invalid-charset-name"/>
<stdin-channel-adapter id="sourceWithInvalidCharset" charset="invalid-charset-name"/>
</beans:beans>