INTSAMPLES-9 added XMPP sample
This commit is contained in:
@@ -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