diff --git a/basic/twitter/.classpath b/basic/twitter/.classpath new file mode 100644 index 00000000..caf88e10 --- /dev/null +++ b/basic/twitter/.classpath @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/basic/twitter/.gitignore b/basic/twitter/.gitignore new file mode 100644 index 00000000..ea8c4bf7 --- /dev/null +++ b/basic/twitter/.gitignore @@ -0,0 +1 @@ +/target diff --git a/basic/twitter/.project b/basic/twitter/.project new file mode 100644 index 00000000..4f56b149 --- /dev/null +++ b/basic/twitter/.project @@ -0,0 +1,29 @@ + + + twitter + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.maven.ide.eclipse.maven2Builder + + + + + org.springframework.ide.eclipse.core.springbuilder + + + + + + org.springframework.ide.eclipse.core.springnature + org.eclipse.jdt.core.javanature + org.maven.ide.eclipse.maven2Nature + + diff --git a/basic/twitter/.settings/com.springsource.sts.config.flow.prefs b/basic/twitter/.settings/com.springsource.sts.config.flow.prefs new file mode 100644 index 00000000..d5aacd07 --- /dev/null +++ b/basic/twitter/.settings/com.springsource.sts.config.flow.prefs @@ -0,0 +1,5 @@ +#Thu Nov 18 13:53:30 EST 2010 +//com.springsource.sts.config.flow.coordinates\:http\://www.springframework.org/schema/integration\:/twitter/src/test/resources/META-INF/spring/integration/TwitterSearch-context.xml=\n\n\n\n\n\n\n\n\n\n\n\n\n\n +//com.springsource.sts.config.flow.coordinates\:http\://www.springframework.org/schema/integration\:/twitter/src/test/resources/META-INF/spring/integration/TwitterSendUpdates-context.xml=\n\n\n\n\n\n +//com.springsource.sts.config.flow.coordinates\:http\://www.springframework.org/schema/integration\:/twitter/src/test/resources/META-INF/spring/integration/TwitterTimelineUpdates-context.xml=\n\n\n\n\n\n\n\n\n\n\n\n\n\n +eclipse.preferences.version=1 diff --git a/basic/twitter/.settings/org.eclipse.jdt.core.prefs b/basic/twitter/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000..6a214727 --- /dev/null +++ b/basic/twitter/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,13 @@ +#Thu Nov 18 11:41:09 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 diff --git a/basic/twitter/.settings/org.maven.ide.eclipse.prefs b/basic/twitter/.settings/org.maven.ide.eclipse.prefs new file mode 100644 index 00000000..8d8a0f73 --- /dev/null +++ b/basic/twitter/.settings/org.maven.ide.eclipse.prefs @@ -0,0 +1,9 @@ +#Thu Nov 18 11:39:52 EST 2010 +activeProfiles= +eclipse.preferences.version=1 +fullBuildGoals=process-test-resources +includeModules=false +resolveWorkspaceProjects=true +resourceFilterGoals=process-resources resources\:testResources +skipCompilerPlugin=true +version=1 diff --git a/basic/twitter/.springBeans b/basic/twitter/.springBeans new file mode 100644 index 00000000..22795bb1 --- /dev/null +++ b/basic/twitter/.springBeans @@ -0,0 +1,14 @@ + + + 1 + + + + + + + src/test/resources/META-INF/spring/integration/TwitterTimelineUpdates-context.xml + + + + diff --git a/basic/twitter/pom.xml b/basic/twitter/pom.xml new file mode 100644 index 00000000..7f77a313 --- /dev/null +++ b/basic/twitter/pom.xml @@ -0,0 +1,63 @@ + + 4.0.0 + org.springframework.integration.samples + twitter + 2.0.0 + Twitter Demo + jar + + 2.0.0.BUILD-SNAPSHOT + 1.2.16 + 4.7 + + + + org.springframework.integration + spring-integration-twitter + ${spring.integration.version} + + + log4j + log4j + ${log4j.version} + + + + junit + junit + ${junit.version} + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.5 + 1.5 + -Xlint:all + true + false + + + + + + + repository.springframework.maven.release + Spring Framework Maven Release Repository + http://maven.springframework.org/release + + + repository.springframework.maven.milestone + Spring Framework Maven Milestone Repository + http://maven.springframework.org/milestone + + + repository.springframework.maven.snapshot + Spring Framework Maven Snapshot Repository + http://maven.springframework.org/snapshot + + + \ No newline at end of file diff --git a/basic/twitter/readme.txt b/basic/twitter/readme.txt new file mode 100644 index 00000000..f809c8ce --- /dev/null +++ b/basic/twitter/readme.txt @@ -0,0 +1,36 @@ +This example demonstrates the following aspects of the Twitter support available with Spring Integration: +1. Twitter Inbound Channel Adapter - allows you to receive HOME status updates +2. Twitter Inbound Search Channel Adapter - allows you to receive HOME status updates +3. Twitter Outboud Channel Adapter - allows send status updates + +In order to run this sample you need to configure OAuth and set the values in the OAuth properties. +================ +To use OAuth authentication/authorization with Twitter you must create new Application on Twitter Developers site. +Follow the directions below to create a new application and obtain consumer keys and access token: + + - Go to http://dev.twitter.com/ + - Click on 'Register an app' link and fill out all required fields on the form provided; + - Set 'Application Type' to 'Client' and depending on the nature of your application select + 'Default Access Type' as 'Read & Write' or 'Read-only' and Submit the form. + - If everything is successful you'll be presented with the 'Consumer Key' and 'Consumer Secret'. + - Copy both values in the safe place. + + On the same page you should see 'My Access Token' button on the side bar (right). + - Click on it and you'll be presented with two more values: 'Access Token' and 'Access Token Secret'. + Copy these values in a safe place as well. + +When done fill out oauth.properties file so it looks similar to this. + +twitter.oauth.consumerKey=4XzBPabcJQxyBzzzH3TrRQ +twitter.oauth.consumerSecret=ab2piKdMfPu8bVa3ab6DAIvIWEVZyMDL0RSEN2I8 +twitter.oauth.accessToken=21691649-4XYZY5iJEOfz2A9qCFd9SjBRGb3HLmIm4HNE6AMv4 +twitter.oauth.accessTokenSecret=AbRxUAvyNCtqQtvxFK8w5ZMtMj20KFhB6oEfTA0 + +NOTE: the above values are not real ;) +======================= + +Now you ready to execute samples. Just run each sample and look for the output produced by the +inbound adapters (TwitterSearchSample.java and TwitterTimelineUpdateSample.java) + +The outbound adapter sample (TwitterSendUpdatesSample.java) will not produce any output. +Instead within seconds you should see your tweet. diff --git a/basic/twitter/src/test/java/org/springframework/integration/samples/twitter/TwitterSearchSample.java b/basic/twitter/src/test/java/org/springframework/integration/samples/twitter/TwitterSearchSample.java new file mode 100644 index 00000000..18dc5744 --- /dev/null +++ b/basic/twitter/src/test/java/org/springframework/integration/samples/twitter/TwitterSearchSample.java @@ -0,0 +1,34 @@ +/* + * 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.samples.twitter; + +import org.junit.Test; + +import org.springframework.context.support.ClassPathXmlApplicationContext; + +/** + * @author Oleg Zhurakousky + * + */ +public class TwitterSearchSample { + + @Test + public void runDemo() throws Exception{ + new ClassPathXmlApplicationContext("META-INF/spring/integration/TwitterSearch-context.xml"); + + Thread.sleep(20000); + } +} diff --git a/basic/twitter/src/test/java/org/springframework/integration/samples/twitter/TwitterSendUpdatesSample.java b/basic/twitter/src/test/java/org/springframework/integration/samples/twitter/TwitterSendUpdatesSample.java new file mode 100644 index 00000000..a6ad58cf --- /dev/null +++ b/basic/twitter/src/test/java/org/springframework/integration/samples/twitter/TwitterSendUpdatesSample.java @@ -0,0 +1,41 @@ +/* + * 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.samples.twitter; + +import org.junit.Test; + +import org.springframework.context.ApplicationContext; +import org.springframework.context.support.ClassPathXmlApplicationContext; +import org.springframework.integration.Message; +import org.springframework.integration.MessageChannel; +import org.springframework.integration.message.GenericMessage; + +/** + * @author Oleg Zhurakousky + * + */ +public class TwitterSendUpdatesSample { + + @Test + public void runDemo() throws Exception{ + ApplicationContext context = + new ClassPathXmlApplicationContext("META-INF/spring/integration/TwitterSendUpdates-context.xml"); + + MessageChannel twitterOutChannel = context.getBean("twitterOut", MessageChannel.class); + Message twitterUpdate = new GenericMessage("Testing new Twitter samples for #springintegration"); + twitterOutChannel.send(twitterUpdate); + } +} diff --git a/basic/twitter/src/test/java/org/springframework/integration/samples/twitter/TwitterTimelineUpdatesSample.java b/basic/twitter/src/test/java/org/springframework/integration/samples/twitter/TwitterTimelineUpdatesSample.java new file mode 100644 index 00000000..72085adb --- /dev/null +++ b/basic/twitter/src/test/java/org/springframework/integration/samples/twitter/TwitterTimelineUpdatesSample.java @@ -0,0 +1,34 @@ +/* + * 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.samples.twitter; + +import org.junit.Test; + +import org.springframework.context.support.ClassPathXmlApplicationContext; + +/** + * @author Oleg Zhurakousky + * + */ +public class TwitterTimelineUpdatesSample { + + @Test + public void runDemo() throws Exception{ + new ClassPathXmlApplicationContext("META-INF/spring/integration/TwitterTimelineUpdates-context.xml"); + + Thread.sleep(20000); + } +} diff --git a/basic/twitter/src/test/resources/META-INF/spring/integration/TwitterSearch-context.xml b/basic/twitter/src/test/resources/META-INF/spring/integration/TwitterSearch-context.xml new file mode 100644 index 00000000..be6fcf9f --- /dev/null +++ b/basic/twitter/src/test/resources/META-INF/spring/integration/TwitterSearch-context.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/basic/twitter/src/test/resources/META-INF/spring/integration/TwitterSendUpdates-context.xml b/basic/twitter/src/test/resources/META-INF/spring/integration/TwitterSendUpdates-context.xml new file mode 100644 index 00000000..7da627da --- /dev/null +++ b/basic/twitter/src/test/resources/META-INF/spring/integration/TwitterSendUpdates-context.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/basic/twitter/src/test/resources/META-INF/spring/integration/TwitterTimelineUpdates-context.xml b/basic/twitter/src/test/resources/META-INF/spring/integration/TwitterTimelineUpdates-context.xml new file mode 100644 index 00000000..d6e402cd --- /dev/null +++ b/basic/twitter/src/test/resources/META-INF/spring/integration/TwitterTimelineUpdates-context.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/basic/twitter/src/test/resources/log4j.properties b/basic/twitter/src/test/resources/log4j.properties new file mode 100644 index 00000000..24eb71bb --- /dev/null +++ b/basic/twitter/src/test/resources/log4j.properties @@ -0,0 +1,8 @@ +log4j.rootCategory=INFO, 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 diff --git a/basic/twitter/src/test/resources/oauth.properties b/basic/twitter/src/test/resources/oauth.properties new file mode 100644 index 00000000..717d6909 --- /dev/null +++ b/basic/twitter/src/test/resources/oauth.properties @@ -0,0 +1,4 @@ +twitter.oauth.consumerKey= +twitter.oauth.consumerSecret= +twitter.oauth.accessToken= +twitter.oauth.accessTokenSecret= \ No newline at end of file