INTSAMPLES-11 added FEED sample

This commit is contained in:
Oleg Zhurakousky
2010-11-18 11:33:44 -05:00
parent 8544307d06
commit c5fabc21ca
11 changed files with 218 additions and 0 deletions

8
basic/feed/.classpath Normal file
View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>

1
basic/feed/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/target

23
basic/feed/.project Normal file
View File

@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>feed</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.maven.ide.eclipse.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.maven.ide.eclipse.maven2Nature</nature>
</natures>
</projectDescription>

View File

@@ -0,0 +1,3 @@
#Thu Nov 18 11:26:44 EST 2010
//com.springsource.sts.config.flow.coordinates\:http\://www.springframework.org/schema/integration\:/feed/src/test/resources/META-INF/spring/integration/FeedInboundChannelAdapterSample-context.xml=<?xml version\="1.0" encoding\="UTF-8"?>\n<graph>\n<element clazz\="ChannelModelElement" type\="channel">\n<structure end\="1026" endstart\="1012" start\="965" startend\="995"/>\n<bounds height\="112" width\="116" x\="19" y\="17"/>\n</element>\n</graph>
eclipse.preferences.version=1

View File

@@ -0,0 +1,13 @@
#Thu Nov 18 11:17:08 EST 2010
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.source=1.6

View File

@@ -0,0 +1,9 @@
#Thu Nov 18 11:16:31 EST 2010
activeProfiles=
eclipse.preferences.version=1
fullBuildGoals=process-test-resources
includeModules=false
resolveWorkspaceProjects=true
resourceFilterGoals=process-resources resources\:testResources
skipCompilerPlugin=true
version=1

63
basic/feed/pom.xml Normal file
View File

@@ -0,0 +1,63 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.springframework.integration.samples</groupId>
<artifactId>feed</artifactId>
<version>2.0.0</version>
<name>Feed Demo (RSS/ATOM)</name>
<packaging>jar</packaging>
<properties>
<spring.integration.version>2.0.0.BUILD-SNAPSHOT</spring.integration.version>
<log4j.version>1.2.16</log4j.version>
<junit.version>4.7</junit.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-feed</artifactId>
<version>${spring.integration.version}</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>${log4j.version}</version>
</dependency>
<!-- test-scoped dependencies -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
<compilerArgument>-Xlint:all</compilerArgument>
<showWarnings>true</showWarnings>
<showDeprecation>false</showDeprecation>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>repository.springframework.maven.release</id>
<name>Spring Framework Maven Release Repository</name>
<url>http://maven.springframework.org/release</url>
</repository>
<repository>
<id>repository.springframework.maven.milestone</id>
<name>Spring Framework Maven Milestone Repository</name>
<url>http://maven.springframework.org/milestone</url>
</repository>
<repository>
<id>repository.springframework.maven.snapshot</id>
<name>Spring Framework Maven Snapshot Repository</name>
<url>http://maven.springframework.org/snapshot</url>
</repository>
</repositories>
</project>

21
basic/feed/readme.txt Normal file
View File

@@ -0,0 +1,21 @@
This example demonstrates the following aspects of the FEED (RSS/ATOM) support available with Spring Integration:
1. FEED Inbound Channel Adapter (receives news feeds)
#### INBOUND CHANNEL ADAPTER ####
To run INBOUND CHANNEL ADAPTER sample execute FeedInboundChannelAdapterSample test and you'll receive the feed entries for the
given URL. Feel free to plug in your own URL
The output should look similar to this:
=====
Thu Nov 18 01:28:54 EST 2010 - Rangel awaits House sanctions
Thu Nov 18 05:43:11 EST 2010 - Tweet lands woman in China labor camp
Thu Nov 18 06:13:24 EST 2010 - Bird flu is back in Hong Kong
Thu Nov 18 07:09:17 EST 2010 - Computer worm called 'game changer'
Thu Nov 18 08:00:11 EST 2010 - Murkowski declares victory in Alaska
Thu Nov 18 08:50:04 EST 2010 - Family awaits hanging verdict for mom
Thu Nov 18 09:14:20 EST 2010 - Suspect bag on Germany-bound plane
Thu Nov 18 09:47:15 EST 2010 - Zakaria: How serious is this deficit?
Thu Nov 18 09:51:15 EST 2010 - Two former Madoff employees arrested
Thu Nov 18 11:15:22 EST 2010 - WikiLeaks founder wanted in rape case
=====

View File

@@ -0,0 +1,50 @@
/*
* 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.feed;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.integration.Message;
import org.springframework.integration.core.PollableChannel;
import com.sun.syndication.feed.synd.SyndEntry;
/**
* @author Oleg Zhurakousky
*
*/
public class FeedInboundChannelAdapterSample {
@SuppressWarnings("unchecked")
@Test
public void runDemo(){
ApplicationContext ac =
new ClassPathXmlApplicationContext("META-INF/spring/integration/FeedInboundChannelAdapterSample-context.xml");
PollableChannel feedChannel = ac.getBean("feedChannel", PollableChannel.class);
for (int i = 0; i < 10; i++) {
Message<SyndEntry> message = (Message<SyndEntry>) feedChannel.receive(1000);
if (message != null){
SyndEntry entry = message.getPayload();
System.out.println(entry.getPublishedDate() + " - " + entry.getTitle());
}
else {
break;
}
}
}
}

View File

@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:int="http://www.springframework.org/schema/integration"
xmlns:int-feed="http://www.springframework.org/schema/integration/feed"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration-2.0.xsd
http://www.springframework.org/schema/integration/feed http://www.springframework.org/schema/integration/feed/spring-integration-feed-2.0.xsd">
<int-feed:inbound-channel-adapter id="feedAdapter"
channel="feedChannel"
auto-startup="true"
url="http://rss.cnn.com/rss/cnn_topstories.rss">
<int:poller fixed-rate="10000" max-messages-per-poll="100" />
</int-feed:inbound-channel-adapter>
<int:channel id="feedChannel">
<int:queue/>
</int:channel>
</beans>

View File

@@ -0,0 +1,8 @@
log4j.rootCategory=WARN, stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %t %c{2}:%L - %m%n
log4j.category.org.springframework=WARN
log4j.category.org.springframework.integration=INFO