INTSAMPLES-9 added XMPP sample
This commit is contained in:
8
basic/xmpp/.classpath
Normal file
8
basic/xmpp/.classpath
Normal 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/xmpp/.gitignore
vendored
Normal file
1
basic/xmpp/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/target
|
||||
23
basic/xmpp/.project
Normal file
23
basic/xmpp/.project
Normal file
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>xmpp</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>
|
||||
@@ -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=<?xml version\="1.0" encoding\="UTF-8"?>\n<graph>\n<element clazz\="LoggingChannelAdapterModelElement" type\="logging-channel-adapter">\n<structure end\="1333" endstart\="1333" start\="1285" startend\="1333"/>\n<bounds height\="112" width\="116" x\="19" y\="17"/>\n</element>\n</graph>
|
||||
//com.springsource.sts.config.flow.coordinates\:http\://www.springframework.org/schema/integration\:/xmpp/src/test/resources/META-INF/spring/integration/SendInstantMessageSample-context.xml=<?xml version\="1.0" encoding\="UTF-8"?>\n<graph>\n<element clazz\="ChannelModelElement" type\="channel">\n<structure end\="1232" endstart\="1232" start\="1199" startend\="1232"/>\n<bounds height\="112" width\="116" x\="19" y\="17"/>\n</element>\n<element clazz\="HeaderEnricherModelElement" type\="header-enricher">\n<structure end\="1406" endstart\="1379" start\="1242" startend\="1325"/>\n<bounds height\="112" width\="116" x\="155" y\="17"/>\n</element>\n<element clazz\="ChannelModelElement" type\="channel">\n<structure end\="1446" endstart\="1446" start\="1417" startend\="1446"/>\n<bounds height\="112" width\="116" x\="291" y\="17"/>\n</element>\n</graph>
|
||||
eclipse.preferences.version=1
|
||||
13
basic/xmpp/.settings/org.eclipse.jdt.core.prefs
Normal file
13
basic/xmpp/.settings/org.eclipse.jdt.core.prefs
Normal file
@@ -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
|
||||
9
basic/xmpp/.settings/org.maven.ide.eclipse.prefs
Normal file
9
basic/xmpp/.settings/org.maven.ide.eclipse.prefs
Normal file
@@ -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
|
||||
63
basic/xmpp/pom.xml
Normal file
63
basic/xmpp/pom.xml
Normal 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>xmpp</artifactId>
|
||||
<version>2.0.0</version>
|
||||
<name>XMPP Demo</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-xmpp</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/xmpp/readme.txt
Normal file
21
basic/xmpp/readme.txt
Normal file
@@ -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.
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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<String> message = new GenericMessage<String>("Hello from Spring Integration XMPP");
|
||||
toUserChannel.send(message);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
|
||||
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-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/xmpp http://www.springframework.org/schema/integration/xmpp/spring-integration-xmpp-2.0.xsd"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xmlns:int="http://www.springframework.org/schema/integration"
|
||||
xmlns:int-xmpp="http://www.springframework.org/schema/integration/xmpp">
|
||||
|
||||
<context:property-placeholder location="classpath:xmpp.properties"/>
|
||||
|
||||
<int-xmpp:xmpp-connection id="googleTalkConnection"
|
||||
user="${user.login}"
|
||||
password="${user.password}"
|
||||
host="${user.host}"
|
||||
service-name="${user.service}"
|
||||
port="${user.port}"/>
|
||||
|
||||
<int-xmpp:inbound-channel-adapter channel="imOutChannel" xmpp-connection="googleTalkConnection"/>
|
||||
|
||||
<int:logging-channel-adapter id="imOutChannel"/>
|
||||
|
||||
</beans>
|
||||
@@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
|
||||
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-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/xmpp http://www.springframework.org/schema/integration/xmpp/spring-integration-xmpp-2.0.xsd"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xmlns:int="http://www.springframework.org/schema/integration"
|
||||
xmlns:int-xmpp="http://www.springframework.org/schema/integration/xmpp">
|
||||
|
||||
<context:property-placeholder location="classpath:xmpp.properties"/>
|
||||
|
||||
<int-xmpp:xmpp-connection id="googleTalkConnection"
|
||||
user="${user.login}"
|
||||
password="${user.password}"
|
||||
host="${user.host}"
|
||||
service-name="${user.service}"
|
||||
port="${user.port}"/>
|
||||
|
||||
<int:channel id="toUserChannel"/>
|
||||
|
||||
<int-xmpp:header-enricher input-channel="toUserChannel" output-channel="imChannel">
|
||||
<int-xmpp:chat-to value="${send.to.user}"/>
|
||||
</int-xmpp:header-enricher>
|
||||
|
||||
<int:channel id="imChannel"/>
|
||||
|
||||
<int-xmpp:outbound-channel-adapter channel="imChannel" xmpp-connection="googleTalkConnection"/>
|
||||
|
||||
</beans>
|
||||
8
basic/xmpp/src/test/resources/log4j.properties
Normal file
8
basic/xmpp/src/test/resources/log4j.properties
Normal file
@@ -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
|
||||
8
basic/xmpp/src/test/resources/xmpp.properties
Normal file
8
basic/xmpp/src/test/resources/xmpp.properties
Normal file
@@ -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
|
||||
Reference in New Issue
Block a user