diff --git a/basic/xmpp/.classpath b/basic/xmpp/.classpath new file mode 100644 index 000000000..caf88e109 --- /dev/null +++ b/basic/xmpp/.classpath @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/basic/xmpp/.gitignore b/basic/xmpp/.gitignore new file mode 100644 index 000000000..ea8c4bf7f --- /dev/null +++ b/basic/xmpp/.gitignore @@ -0,0 +1 @@ +/target diff --git a/basic/xmpp/.project b/basic/xmpp/.project new file mode 100644 index 000000000..236c11eb2 --- /dev/null +++ b/basic/xmpp/.project @@ -0,0 +1,23 @@ + + + xmpp + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.maven.ide.eclipse.maven2Builder + + + + + + org.eclipse.jdt.core.javanature + org.maven.ide.eclipse.maven2Nature + + diff --git a/basic/xmpp/.settings/com.springsource.sts.config.flow.prefs b/basic/xmpp/.settings/com.springsource.sts.config.flow.prefs new file mode 100644 index 000000000..852d436ee --- /dev/null +++ b/basic/xmpp/.settings/com.springsource.sts.config.flow.prefs @@ -0,0 +1,4 @@ +#Thu Nov 18 15:00:06 EST 2010 +//com.springsource.sts.config.flow.coordinates\:http\://www.springframework.org/schema/integration\:/xmpp/src/test/resources/META-INF/spring/integration/ReceiveInstantMessageSample-context.xml=\n\n\n\n\n\n +//com.springsource.sts.config.flow.coordinates\:http\://www.springframework.org/schema/integration\:/xmpp/src/test/resources/META-INF/spring/integration/SendInstantMessageSample-context.xml=\n\n\n\n\n\n\n\n\n\n\n\n\n\n +eclipse.preferences.version=1 diff --git a/basic/xmpp/.settings/org.eclipse.jdt.core.prefs b/basic/xmpp/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..1dcd7116d --- /dev/null +++ b/basic/xmpp/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,13 @@ +#Thu Nov 18 14:13:06 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/xmpp/.settings/org.maven.ide.eclipse.prefs b/basic/xmpp/.settings/org.maven.ide.eclipse.prefs new file mode 100644 index 000000000..c13dfde33 --- /dev/null +++ b/basic/xmpp/.settings/org.maven.ide.eclipse.prefs @@ -0,0 +1,9 @@ +#Thu Nov 18 14:12:37 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/xmpp/pom.xml b/basic/xmpp/pom.xml new file mode 100644 index 000000000..b6556439a --- /dev/null +++ b/basic/xmpp/pom.xml @@ -0,0 +1,63 @@ + + 4.0.0 + org.springframework.integration.samples + xmpp + 2.0.0 + XMPP Demo + jar + + 2.0.0.BUILD-SNAPSHOT + 1.2.16 + 4.7 + + + + org.springframework.integration + spring-integration-xmpp + ${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/xmpp/readme.txt b/basic/xmpp/readme.txt new file mode 100644 index 000000000..1bb210c12 --- /dev/null +++ b/basic/xmpp/readme.txt @@ -0,0 +1,21 @@ +This example was prepared for testing with GoogleTalk and +demonstrates the following aspects of the XMPP support available with Spring Integration: +1. XMPP Inbound Channel Adapter - receive instant messages. +2. XMPP Outboud Channel Adapter - send instant messages. + +In order to run this sample you need to provide correct values in xmpp.properties. +Everything there was already preset. The only 3 properties you need to provide values for are: + + - user.login + - user.password + - send.to.user + +You'll also need to test it with your friend or have two Google accounts setup + + To test SendInstantMessageSample.java, first log on to the account identified via 'send.to.user' property + and make sure that that account is in your buddy list. Then run the demo. + + To test ReceiveInstantMessageSample.java, first log on to the account identified via 'send.to.user' property. + Then run the demo. When demo class is started you'll see on GoggleTalk that your buddy (ReceiveInstantMessageSample.java) + has just signed on. Now you can send a message from GoogleTalk and see it appear ion the console. + \ No newline at end of file diff --git a/basic/xmpp/src/test/java/org/springframework/integration/samples/xmpp/ReceiveInstantMessageSample.java b/basic/xmpp/src/test/java/org/springframework/integration/samples/xmpp/ReceiveInstantMessageSample.java new file mode 100644 index 000000000..e627cc264 --- /dev/null +++ b/basic/xmpp/src/test/java/org/springframework/integration/samples/xmpp/ReceiveInstantMessageSample.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.xmpp; + +import org.junit.Test; + +import org.springframework.context.support.ClassPathXmlApplicationContext; + +/** + * @author Oleg Zhurakousky + * + */ +public class ReceiveInstantMessageSample { + + @Test + public void runDemo() throws Exception{ + new ClassPathXmlApplicationContext("META-INF/spring/integration/ReceiveInstantMessageSample-context.xml"); + + Thread.sleep(20000*10); + } +} diff --git a/basic/xmpp/src/test/java/org/springframework/integration/samples/xmpp/SendInstantMessageSample.java b/basic/xmpp/src/test/java/org/springframework/integration/samples/xmpp/SendInstantMessageSample.java new file mode 100644 index 000000000..0b2b6689e --- /dev/null +++ b/basic/xmpp/src/test/java/org/springframework/integration/samples/xmpp/SendInstantMessageSample.java @@ -0,0 +1,40 @@ +/* + * 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.xmpp; + +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 SendInstantMessageSample { + + @Test + public void runDemo() throws Exception{ + ApplicationContext context = new ClassPathXmlApplicationContext("META-INF/spring/integration/SendInstantMessageSample-context.xml"); + + MessageChannel toUserChannel = context.getBean("toUserChannel", MessageChannel.class); + Message message = new GenericMessage("Hello from Spring Integration XMPP"); + toUserChannel.send(message); + } +} diff --git a/basic/xmpp/src/test/resources/META-INF/spring/integration/ReceiveInstantMessageSample-context.xml b/basic/xmpp/src/test/resources/META-INF/spring/integration/ReceiveInstantMessageSample-context.xml new file mode 100644 index 000000000..e7a6f3d51 --- /dev/null +++ b/basic/xmpp/src/test/resources/META-INF/spring/integration/ReceiveInstantMessageSample-context.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/basic/xmpp/src/test/resources/META-INF/spring/integration/SendInstantMessageSample-context.xml b/basic/xmpp/src/test/resources/META-INF/spring/integration/SendInstantMessageSample-context.xml new file mode 100644 index 000000000..088f23210 --- /dev/null +++ b/basic/xmpp/src/test/resources/META-INF/spring/integration/SendInstantMessageSample-context.xml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + diff --git a/basic/xmpp/src/test/resources/log4j.properties b/basic/xmpp/src/test/resources/log4j.properties new file mode 100644 index 000000000..24eb71bbc --- /dev/null +++ b/basic/xmpp/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/xmpp/src/test/resources/xmpp.properties b/basic/xmpp/src/test/resources/xmpp.properties new file mode 100644 index 000000000..f76bf8af9 --- /dev/null +++ b/basic/xmpp/src/test/resources/xmpp.properties @@ -0,0 +1,8 @@ +user.login=user@gmail.com +user.password=password +user.host=talk.google.com +user.service=gmail.com +user.resource=resource +user.port=5222 + +send.to.user=another.user@gmail.com \ No newline at end of file