moved spaces to tabs for the xmpp package
This commit is contained in:
@@ -1,98 +1,98 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.springframework.integration</groupId>
|
||||
<artifactId>spring-integration-parent</artifactId>
|
||||
<version>2.0.0.BUILD-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>spring-integration-xmpp</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<name>Spring Integration XMPP Support</name>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>jivesoftware</groupId>
|
||||
<artifactId>smack</artifactId>
|
||||
<version>3.1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>jivesoftware</groupId>
|
||||
<artifactId>smackx</artifactId>
|
||||
<version>3.1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.activation</groupId>
|
||||
<artifactId>activation</artifactId>
|
||||
<version>1.1.1</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cglib</groupId>
|
||||
<artifactId>cglib-nodep</artifactId>
|
||||
<version>${cglib.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.easymock</groupId>
|
||||
<artifactId>easymock</artifactId>
|
||||
<version>${org.easymock.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.easymock</groupId>
|
||||
<artifactId>easymockclassextension</artifactId>
|
||||
<version>${org.easymock.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>${junit.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-context-support</artifactId>
|
||||
<version>${org.springframework.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-test</artifactId>
|
||||
<version>${org.springframework.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.integration</groupId>
|
||||
<artifactId>spring-integration-stream</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.integration</groupId>
|
||||
<artifactId>spring-integration-core</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-lang</groupId>
|
||||
<artifactId>commons-lang</artifactId>
|
||||
<version>2.5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>1.4</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>com.springsource.bundlor</groupId>
|
||||
<artifactId>com.springsource.bundlor.maven</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.springframework.integration</groupId>
|
||||
<artifactId>spring-integration-parent</artifactId>
|
||||
<version>2.0.0.BUILD-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>spring-integration-xmpp</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<name>Spring Integration XMPP Support</name>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>jivesoftware</groupId>
|
||||
<artifactId>smack</artifactId>
|
||||
<version>3.1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>jivesoftware</groupId>
|
||||
<artifactId>smackx</artifactId>
|
||||
<version>3.1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.activation</groupId>
|
||||
<artifactId>activation</artifactId>
|
||||
<version>1.1.1</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cglib</groupId>
|
||||
<artifactId>cglib-nodep</artifactId>
|
||||
<version>${cglib.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.easymock</groupId>
|
||||
<artifactId>easymock</artifactId>
|
||||
<version>${org.easymock.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.easymock</groupId>
|
||||
<artifactId>easymockclassextension</artifactId>
|
||||
<version>${org.easymock.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>${junit.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-context-support</artifactId>
|
||||
<version>${org.springframework.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-test</artifactId>
|
||||
<version>${org.springframework.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.integration</groupId>
|
||||
<artifactId>spring-integration-stream</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.integration</groupId>
|
||||
<artifactId>spring-integration-core</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-lang</groupId>
|
||||
<artifactId>commons-lang</artifactId>
|
||||
<version>2.5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>1.4</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>com.springsource.bundlor</groupId>
|
||||
<artifactId>com.springsource.bundlor.maven</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
|
||||
@@ -33,173 +33,172 @@ import org.springframework.util.StringUtils;
|
||||
* @since 2.0
|
||||
*/
|
||||
public class XmppConnectionFactory extends AbstractFactoryBean<XMPPConnection> {
|
||||
// TODO provide a default subscription mode for this class: Roster.setSubscriptionMode(Roster.SubscriptionMode)
|
||||
private static final Log logger = LogFactory.getLog(XmppConnectionFactory.class);
|
||||
// TODO provide a default subscription mode for this class: Roster.setSubscriptionMode(Roster.SubscriptionMode)
|
||||
private static final Log logger = LogFactory.getLog(XmppConnectionFactory.class);
|
||||
|
||||
private volatile String user;
|
||||
private volatile String user;
|
||||
|
||||
private volatile String password;
|
||||
private volatile String password;
|
||||
|
||||
private volatile String host;
|
||||
private volatile String host;
|
||||
|
||||
private volatile String serviceName;
|
||||
private volatile String serviceName;
|
||||
|
||||
private volatile String resource;
|
||||
private volatile String resource;
|
||||
|
||||
private volatile String saslMechanismSupported;
|
||||
private volatile String saslMechanismSupported;
|
||||
|
||||
private volatile int saslMechanismSupportedIndex;
|
||||
private volatile int saslMechanismSupportedIndex;
|
||||
|
||||
private volatile int port;
|
||||
private volatile int port;
|
||||
|
||||
private volatile String subscriptionMode;
|
||||
private volatile String subscriptionMode;
|
||||
|
||||
|
||||
private volatile boolean debug = false;
|
||||
private volatile boolean debug = false;
|
||||
|
||||
public XmppConnectionFactory() {
|
||||
}
|
||||
public XmppConnectionFactory() {
|
||||
}
|
||||
|
||||
public XmppConnectionFactory(String user, String password, String host, String serviceName, String resource, String saslMechanismSupported, int saslMechanismSupportedIndex, int port) {
|
||||
this.user = user;
|
||||
this.password = password;
|
||||
this.host = host;
|
||||
this.serviceName = serviceName;
|
||||
this.resource = resource;
|
||||
this.saslMechanismSupported = saslMechanismSupported;
|
||||
this.saslMechanismSupportedIndex = saslMechanismSupportedIndex;
|
||||
this.port = port;
|
||||
}
|
||||
public XmppConnectionFactory(String user, String password, String host, String serviceName, String resource, String saslMechanismSupported, int saslMechanismSupportedIndex, int port) {
|
||||
this.user = user;
|
||||
this.password = password;
|
||||
this.host = host;
|
||||
this.serviceName = serviceName;
|
||||
this.resource = resource;
|
||||
this.saslMechanismSupported = saslMechanismSupported;
|
||||
this.saslMechanismSupportedIndex = saslMechanismSupportedIndex;
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
public String getUser() {
|
||||
return user;
|
||||
}
|
||||
public String getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
public void setUser(String user) {
|
||||
this.user = user;
|
||||
}
|
||||
public void setUser(String user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public String getHost() {
|
||||
return host;
|
||||
}
|
||||
public String getHost() {
|
||||
return host;
|
||||
}
|
||||
|
||||
public void setHost(String host) {
|
||||
this.host = host;
|
||||
}
|
||||
public void setHost(String host) {
|
||||
this.host = host;
|
||||
}
|
||||
|
||||
public String getServiceName() {
|
||||
return serviceName;
|
||||
}
|
||||
public String getServiceName() {
|
||||
return serviceName;
|
||||
}
|
||||
|
||||
public void setServiceName(String serviceName) {
|
||||
this.serviceName = serviceName;
|
||||
}
|
||||
public void setServiceName(String serviceName) {
|
||||
this.serviceName = serviceName;
|
||||
}
|
||||
|
||||
public String getResource() {
|
||||
return resource;
|
||||
}
|
||||
public String getResource() {
|
||||
return resource;
|
||||
}
|
||||
|
||||
public void setResource(String resource) {
|
||||
this.resource = resource;
|
||||
}
|
||||
public void setResource(String resource) {
|
||||
this.resource = resource;
|
||||
}
|
||||
|
||||
public String getSaslMechanismSupported() {
|
||||
return saslMechanismSupported;
|
||||
}
|
||||
public String getSaslMechanismSupported() {
|
||||
return saslMechanismSupported;
|
||||
}
|
||||
|
||||
public void setSaslMechanismSupported(String saslMechanismSupported) {
|
||||
this.saslMechanismSupported = saslMechanismSupported;
|
||||
}
|
||||
public void setSaslMechanismSupported(String saslMechanismSupported) {
|
||||
this.saslMechanismSupported = saslMechanismSupported;
|
||||
}
|
||||
|
||||
public int getSaslMechanismSupportedIndex() {
|
||||
return saslMechanismSupportedIndex;
|
||||
}
|
||||
public int getSaslMechanismSupportedIndex() {
|
||||
return saslMechanismSupportedIndex;
|
||||
}
|
||||
|
||||
public void setSaslMechanismSupportedIndex(int saslMechanismSupportedIndex) {
|
||||
this.saslMechanismSupportedIndex = saslMechanismSupportedIndex;
|
||||
}
|
||||
public void setSaslMechanismSupportedIndex(int saslMechanismSupportedIndex) {
|
||||
this.saslMechanismSupportedIndex = saslMechanismSupportedIndex;
|
||||
}
|
||||
|
||||
public int getPort() {
|
||||
return port;
|
||||
}
|
||||
public int getPort() {
|
||||
return port;
|
||||
}
|
||||
|
||||
public void setPort(int port) {
|
||||
this.port = port;
|
||||
}
|
||||
public void setPort(int port) {
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
public boolean isDebug() {
|
||||
return debug;
|
||||
}
|
||||
public boolean isDebug() {
|
||||
return debug;
|
||||
}
|
||||
|
||||
public void setDebug(boolean debug) {
|
||||
XMPPConnection.DEBUG_ENABLED = debug;
|
||||
this.debug = debug;
|
||||
}
|
||||
public void setDebug(boolean debug) {
|
||||
XMPPConnection.DEBUG_ENABLED = debug;
|
||||
this.debug = debug;
|
||||
}
|
||||
|
||||
|
||||
public void setSubscriptionMode(final String subscriptionMode) {
|
||||
this.subscriptionMode = subscriptionMode;
|
||||
}
|
||||
public void setSubscriptionMode(final String subscriptionMode) {
|
||||
this.subscriptionMode = subscriptionMode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?extends XMPPConnection> getObjectType() {
|
||||
return XMPPConnection.class;
|
||||
}
|
||||
@Override
|
||||
public Class<? extends XMPPConnection> getObjectType() {
|
||||
return XMPPConnection.class;
|
||||
}
|
||||
|
||||
private XMPPConnection configureAndConnect(String usr, String pw, String host, int port, String serviceName, String resource, String saslMechanismSupported, int saslMechanismSupportedIndex) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug(String.format("usr=%s, pw=%s, host=%s, port=%s, serviceName=%s, resource=%s, saslMechanismSupported=%s, saslMechanismSupportedIndex=%s", usr, pw, host, port, serviceName,
|
||||
resource, saslMechanismSupported, saslMechanismSupportedIndex));
|
||||
}
|
||||
private XMPPConnection configureAndConnect(String usr, String pw, String host, int port, String serviceName, String resource, String saslMechanismSupported, int saslMechanismSupportedIndex) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug(String.format("usr=%s, pw=%s, host=%s, port=%s, serviceName=%s, resource=%s, saslMechanismSupported=%s, saslMechanismSupportedIndex=%s", usr, pw, host, port, serviceName,
|
||||
resource, saslMechanismSupported, saslMechanismSupportedIndex));
|
||||
}
|
||||
|
||||
XMPPConnection.DEBUG_ENABLED = false; // default
|
||||
XMPPConnection.DEBUG_ENABLED = false; // default
|
||||
|
||||
ConnectionConfiguration connectionConfiguration = new ConnectionConfiguration(host, port, serviceName);
|
||||
XMPPConnection connection = new XMPPConnection(connectionConfiguration);
|
||||
ConnectionConfiguration connectionConfiguration = new ConnectionConfiguration(host, port, serviceName);
|
||||
XMPPConnection connection = new XMPPConnection(connectionConfiguration);
|
||||
|
||||
try {
|
||||
connection.connect();
|
||||
try {
|
||||
connection.connect();
|
||||
|
||||
// You have to put this code before you login
|
||||
if (StringUtils.hasText(saslMechanismSupported)) {
|
||||
SASLAuthentication.supportSASLMechanism(saslMechanismSupported, saslMechanismSupportedIndex);
|
||||
}
|
||||
// You have to put this code before you login
|
||||
if (StringUtils.hasText(saslMechanismSupported)) {
|
||||
SASLAuthentication.supportSASLMechanism(saslMechanismSupported, saslMechanismSupportedIndex);
|
||||
}
|
||||
|
||||
// You have to specify the resoure (e.g. "@host.com") at the end
|
||||
if (StringUtils.hasText(resource)) {
|
||||
connection.login(usr, pw, resource);
|
||||
} else {
|
||||
connection.login(usr, pw);
|
||||
}
|
||||
// You have to specify the resoure (e.g. "@host.com") at the end
|
||||
if (StringUtils.hasText(resource)) {
|
||||
connection.login(usr, pw, resource);
|
||||
} else {
|
||||
connection.login(usr, pw);
|
||||
}
|
||||
|
||||
if( StringUtils.hasText( this.subscriptionMode)) {
|
||||
Roster.SubscriptionMode subscriptionMode = Roster.SubscriptionMode.valueOf( this.subscriptionMode) ;
|
||||
connection.getRoster().setSubscriptionMode( subscriptionMode );
|
||||
}
|
||||
if (StringUtils.hasText(this.subscriptionMode)) {
|
||||
Roster.SubscriptionMode subscriptionMode = Roster.SubscriptionMode.valueOf(this.subscriptionMode);
|
||||
connection.getRoster().setSubscriptionMode(subscriptionMode);
|
||||
}
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("authenticated? " + connection.isAuthenticated());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.warn("failed to establish XMPP connnection", e);
|
||||
}
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("authenticated? " + connection.isAuthenticated());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.warn("failed to establish XMPP connnection", e);
|
||||
}
|
||||
|
||||
return connection;
|
||||
}
|
||||
return connection;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
protected XMPPConnection createInstance() throws Exception {
|
||||
return this.configureAndConnect(this.getUser(), this.getPassword(), this.getHost(), this.getPort(), this.getServiceName(), this.getResource(), this.getSaslMechanismSupported(),
|
||||
this.getSaslMechanismSupportedIndex());
|
||||
}
|
||||
@Override
|
||||
protected XMPPConnection createInstance() throws Exception {
|
||||
return this.configureAndConnect(this.getUser(), this.getPassword(), this.getHost(), this.getPort(), this.getServiceName(), this.getResource(), this.getSaslMechanismSupported(),
|
||||
this.getSaslMechanismSupportedIndex());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,30 +19,29 @@ import org.springframework.integration.MessageHeaders;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* Used as keys for {@link org.springframework.integration.Message} objects
|
||||
* that handle XMPP events.
|
||||
* that handle XMPP events.
|
||||
*
|
||||
* @author Mario Gray
|
||||
* @author Josh Long
|
||||
* @since 2.0
|
||||
*/
|
||||
public class XmppHeaders {
|
||||
private static final String PREFIX = MessageHeaders.PREFIX + "xmpp_";
|
||||
public static final String CHAT = PREFIX + "chat_key";
|
||||
public static final String CHAT_TO_USER = PREFIX + "chat_to_user";
|
||||
public static final String CHAT_THREAD_ID = PREFIX + "thread_id";
|
||||
public static final String TYPE = PREFIX + "type";
|
||||
private static final String PREFIX = MessageHeaders.PREFIX + "xmpp_";
|
||||
public static final String CHAT = PREFIX + "chat_key";
|
||||
public static final String CHAT_TO_USER = PREFIX + "chat_to_user";
|
||||
public static final String CHAT_THREAD_ID = PREFIX + "thread_id";
|
||||
public static final String TYPE = PREFIX + "type";
|
||||
// public static final String ROSTER_CHANGE_TYPE = PREFIX + "roster_change_type";
|
||||
public static final String PRESENCE = PREFIX + "presence";
|
||||
public static final String PRESENCE = PREFIX + "presence";
|
||||
// public static final String ROSTER = PREFIX + "roster";
|
||||
|
||||
public static final String PRESENCE_LANGUAGE = PRESENCE + "language" ;
|
||||
public static final String PRESENCE_PRIORITY = PRESENCE + "priority" ;
|
||||
public static final String PRESENCE_MODE = PRESENCE + "mode" ;
|
||||
public static final String PRESENCE_TYPE = PRESENCE + "type" ;
|
||||
public static final String PRESENCE_STATUS = PRESENCE + "status" ;
|
||||
public static final String PRESENCE_FROM = PRESENCE+ "from";
|
||||
public static final String PRESENCE_LANGUAGE = PRESENCE + "language";
|
||||
public static final String PRESENCE_PRIORITY = PRESENCE + "priority";
|
||||
public static final String PRESENCE_MODE = PRESENCE + "mode";
|
||||
public static final String PRESENCE_TYPE = PRESENCE + "type";
|
||||
public static final String PRESENCE_STATUS = PRESENCE + "status";
|
||||
public static final String PRESENCE_FROM = PRESENCE + "from";
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -17,18 +17,17 @@
|
||||
package org.springframework.integration.xmpp.config;
|
||||
|
||||
import org.jivesoftware.smack.packet.Presence;
|
||||
import org.springframework.integration.config.xml.HeaderEnricherParserSupport;
|
||||
import org.springframework.integration.xmpp.XmppHeaders;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import org.springframework.beans.factory.support.AbstractBeanDefinition;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser;
|
||||
import org.springframework.beans.factory.xml.NamespaceHandlerSupport;
|
||||
import org.springframework.beans.factory.xml.ParserContext;
|
||||
import org.springframework.integration.config.xml.AbstractOutboundChannelAdapterParser;
|
||||
import org.springframework.integration.config.xml.HeaderEnricherParserSupport;
|
||||
import org.springframework.integration.config.xml.IntegrationNamespaceUtils;
|
||||
import org.springframework.integration.xmpp.XmppHeaders;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
/**
|
||||
* This class parses the schema for XMPP support.
|
||||
@@ -41,25 +40,25 @@ public class XmppNamespaceHandler extends NamespaceHandlerSupport {
|
||||
|
||||
private static final String PACKAGE_NAME = "org.springframework.integration.xmpp";
|
||||
|
||||
private static String[] attributes = new String[] {
|
||||
"user", "password", "host", "service-name", "resource",
|
||||
"sasl-mechanism-supported", "sasl-mechanism-supported-index", "port", "subscription-mode"
|
||||
private static String[] attributes = new String[]{
|
||||
"user", "password", "host", "service-name", "resource",
|
||||
"sasl-mechanism-supported", "sasl-mechanism-supported-index", "port", "subscription-mode"
|
||||
};
|
||||
|
||||
|
||||
public void init() {
|
||||
// connection
|
||||
registerBeanDefinitionParser("xmpp-connection", new XmppConnectionParser());
|
||||
// connection
|
||||
registerBeanDefinitionParser("xmpp-connection", new XmppConnectionParser());
|
||||
|
||||
// send/receive messages
|
||||
registerBeanDefinitionParser("message-inbound-channel-adapter", new XmppMessageInboundEndpointParser());
|
||||
registerBeanDefinitionParser("message-outbound-channel-adapter", new XmppMessageOutboundEndpointParser());
|
||||
// send/receive messages
|
||||
registerBeanDefinitionParser("message-inbound-channel-adapter", new XmppMessageInboundEndpointParser());
|
||||
registerBeanDefinitionParser("message-outbound-channel-adapter", new XmppMessageOutboundEndpointParser());
|
||||
|
||||
// presence
|
||||
registerBeanDefinitionParser("roster-event-inbound-channel-adapter", new XmppRosterEventInboundEndpointParser());
|
||||
registerBeanDefinitionParser("roster-event-outbound-channel-adapter", new XmppRosterEventOutboundEndpointParser());
|
||||
// presence
|
||||
registerBeanDefinitionParser("roster-event-inbound-channel-adapter", new XmppRosterEventInboundEndpointParser());
|
||||
registerBeanDefinitionParser("roster-event-outbound-channel-adapter", new XmppRosterEventOutboundEndpointParser());
|
||||
|
||||
registerBeanDefinitionParser("header-enricher", new XmppHeaderEnricherParser());
|
||||
registerBeanDefinitionParser("header-enricher", new XmppHeaderEnricherParser());
|
||||
}
|
||||
|
||||
|
||||
@@ -67,8 +66,7 @@ public class XmppNamespaceHandler extends NamespaceHandlerSupport {
|
||||
String ref = element.getAttribute("xmpp-connection");
|
||||
if (StringUtils.hasText(ref)) {
|
||||
builder.addPropertyReference("xmppConnection", ref);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
for (String attribute : attributes) {
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, attribute);
|
||||
}
|
||||
@@ -76,7 +74,8 @@ public class XmppNamespaceHandler extends NamespaceHandlerSupport {
|
||||
}
|
||||
|
||||
|
||||
// connection management
|
||||
// connection management
|
||||
|
||||
private static class XmppConnectionParser extends AbstractSingleBeanDefinitionParser {
|
||||
|
||||
@Override
|
||||
@@ -95,7 +94,8 @@ public class XmppNamespaceHandler extends NamespaceHandlerSupport {
|
||||
}
|
||||
}
|
||||
|
||||
// messages
|
||||
// messages
|
||||
|
||||
private static class XmppMessageOutboundEndpointParser extends AbstractOutboundChannelAdapterParser {
|
||||
|
||||
@Override
|
||||
@@ -126,18 +126,18 @@ public class XmppNamespaceHandler extends NamespaceHandlerSupport {
|
||||
}
|
||||
}
|
||||
|
||||
private static class XmppRosterEventOutboundEndpointParser extends AbstractOutboundChannelAdapterParser {
|
||||
private static class XmppRosterEventOutboundEndpointParser extends AbstractOutboundChannelAdapterParser {
|
||||
|
||||
@Override
|
||||
protected AbstractBeanDefinition parseConsumer(Element element, ParserContext parserContext) {
|
||||
BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(
|
||||
PACKAGE_NAME + ".presence.XmppRosterEventMessageSendingHandler");
|
||||
configureXMPPConnection(element, builder, parserContext);
|
||||
return builder.getBeanDefinition();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
protected AbstractBeanDefinition parseConsumer(Element element, ParserContext parserContext) {
|
||||
BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(
|
||||
PACKAGE_NAME + ".presence.XmppRosterEventMessageSendingHandler");
|
||||
configureXMPPConnection(element, builder, parserContext);
|
||||
return builder.getBeanDefinition();
|
||||
}
|
||||
}
|
||||
|
||||
private static class XmppRosterEventInboundEndpointParser extends AbstractSingleBeanDefinitionParser {
|
||||
private static class XmppRosterEventInboundEndpointParser extends AbstractSingleBeanDefinitionParser {
|
||||
|
||||
@Override
|
||||
protected String getBeanClassName(Element element) {
|
||||
@@ -156,21 +156,21 @@ public class XmppNamespaceHandler extends NamespaceHandlerSupport {
|
||||
}
|
||||
}
|
||||
|
||||
private static class XmppHeaderEnricherParser extends HeaderEnricherParserSupport {
|
||||
private static class XmppHeaderEnricherParser extends HeaderEnricherParserSupport {
|
||||
|
||||
public XmppHeaderEnricherParser() {
|
||||
public XmppHeaderEnricherParser() {
|
||||
|
||||
// chat headers
|
||||
this.addElementToHeaderMapping("message-to", XmppHeaders.CHAT_TO_USER);
|
||||
this.addElementToHeaderMapping("message-thread-id", XmppHeaders.CHAT_THREAD_ID);
|
||||
// chat headers
|
||||
this.addElementToHeaderMapping("message-to", XmppHeaders.CHAT_TO_USER);
|
||||
this.addElementToHeaderMapping("message-thread-id", XmppHeaders.CHAT_THREAD_ID);
|
||||
|
||||
// presence headers
|
||||
this.addElementToHeaderMapping("presence-mode", XmppHeaders.PRESENCE_MODE, Presence.Mode.class);
|
||||
this.addElementToHeaderMapping("presence-type" , XmppHeaders.PRESENCE_TYPE, Presence.Type.class );
|
||||
this.addElementToHeaderMapping("presence-from", XmppHeaders.PRESENCE_FROM);
|
||||
this.addElementToHeaderMapping("presence-status" , XmppHeaders.PRESENCE_STATUS);
|
||||
this.addElementToHeaderMapping("presence-priority" , XmppHeaders.PRESENCE_PRIORITY, Integer.class);
|
||||
}
|
||||
}
|
||||
// presence headers
|
||||
this.addElementToHeaderMapping("presence-mode", XmppHeaders.PRESENCE_MODE, Presence.Mode.class);
|
||||
this.addElementToHeaderMapping("presence-type", XmppHeaders.PRESENCE_TYPE, Presence.Type.class);
|
||||
this.addElementToHeaderMapping("presence-from", XmppHeaders.PRESENCE_FROM);
|
||||
this.addElementToHeaderMapping("presence-status", XmppHeaders.PRESENCE_STATUS);
|
||||
this.addElementToHeaderMapping("presence-priority", XmppHeaders.PRESENCE_PRIORITY, Integer.class);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ import org.springframework.integration.xmpp.XmppHeaders;
|
||||
* {@link org.springframework.integration.xmpp.XmppHeaders#TYPE}. Both of these
|
||||
* pieces of metadata can be obtained directly from the payload, if required.
|
||||
* They are here as a convenience.
|
||||
* <p>
|
||||
* <p/>
|
||||
* <strong>Note</strong>: the {@link org.jivesoftware.smack.ChatManager}
|
||||
* maintains a Map<String, Chat> for threads and users, where the threadID
|
||||
* ({@link String}) is the key or the userID {@link String} is the key. This
|
||||
@@ -56,10 +56,9 @@ import org.springframework.integration.xmpp.XmppHeaders;
|
||||
* key/values as references are dereferenced. Take care to enable this garbage
|
||||
* collection, taking what you need from the payload and the headers and
|
||||
* discarding as soon as possible.
|
||||
*
|
||||
*
|
||||
* @author Josh Long
|
||||
* @author Mark Fisher
|
||||
*
|
||||
* @see ChatManager the ChatManager class that
|
||||
* keeps watch over all Chats between the client and any other
|
||||
* participants.
|
||||
@@ -81,25 +80,24 @@ public class XmppMessageDrivenEndpoint extends AbstractEndpoint implements Lifec
|
||||
private volatile boolean extractPayload = true;
|
||||
|
||||
|
||||
/**
|
||||
* This will be injected or configured via a <em>xmpp-connection-factory</em> element.
|
||||
*
|
||||
* @param xmppConnection the connection
|
||||
*/
|
||||
/**
|
||||
* This will be injected or configured via a <em>xmpp-connection-factory</em> element.
|
||||
*
|
||||
* @param xmppConnection the connection
|
||||
*/
|
||||
public void setXmppConnection(final XMPPConnection xmppConnection) {
|
||||
this.xmppConnection = xmppConnection;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param requestChannel the channel on which the inbound message should be sent
|
||||
*/
|
||||
/**
|
||||
* @param requestChannel the channel on which the inbound message should be sent
|
||||
*/
|
||||
public void setRequestChannel(final MessageChannel requestChannel) {
|
||||
this.messagingTemplate.setDefaultChannel(requestChannel);
|
||||
this.requestChannel = requestChannel;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Specify whether the text message body should be extracted when mapping to a
|
||||
* Spring Integration Message payload. Otherwise, the full XMPP Message will be
|
||||
|
||||
@@ -87,8 +87,7 @@ public class XmppMessageSendingMessageHandler implements MessageHandler, Lifecyc
|
||||
Chat chat = null;
|
||||
if (!StringUtils.hasText(thread)) {
|
||||
chat = xmppConnection.getChatManager().createChat(userId, null);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
chat = xmppConnection.getChatManager().getThreadChat(thread);
|
||||
if (chat == null) {
|
||||
chat = xmppConnection.getChatManager().createChat(userId, thread, null);
|
||||
|
||||
@@ -17,16 +17,13 @@ package org.springframework.integration.xmpp.presence;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.jivesoftware.smack.packet.Presence;
|
||||
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.integration.MessageHeaders;
|
||||
import org.springframework.integration.core.MessageBuilder;
|
||||
import org.springframework.integration.mapping.InboundMessageMapper;
|
||||
import org.springframework.integration.mapping.OutboundMessageMapper;
|
||||
import org.springframework.integration.xmpp.XmppHeaders;
|
||||
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
|
||||
@@ -38,113 +35,113 @@ import org.springframework.util.StringUtils;
|
||||
* @since 2.0
|
||||
*/
|
||||
public class XmppPresenceMessageMapper implements OutboundMessageMapper<Presence>,
|
||||
InboundMessageMapper<Presence> {
|
||||
|
||||
private static final Log logger = LogFactory.getLog(XmppPresenceMessageMapper.class);
|
||||
InboundMessageMapper<Presence> {
|
||||
|
||||
/**
|
||||
* Returns a {@link org.springframework.integration.Message} with payload {@link org.jivesoftware.smack.packet.Presence}
|
||||
*
|
||||
* @param presence the presence object that can be used to present the priority, status, mode, and type of a given roster entry. This will be decomposed into a series of headers, as well as a payload
|
||||
* @return the Message
|
||||
* @throws Exception thrown if conversion should fail
|
||||
*/
|
||||
public Message<?> toMessage(Presence presence) throws Exception {
|
||||
MessageBuilder<?> presenceMessageBuilder = MessageBuilder.withPayload(presence);
|
||||
presenceMessageBuilder.setHeader(XmppHeaders.PRESENCE_PRIORITY, presence.getPriority());
|
||||
presenceMessageBuilder.setHeader(XmppHeaders.PRESENCE_STATUS, presence.getStatus());
|
||||
presenceMessageBuilder.setHeader(XmppHeaders.PRESENCE_MODE, presence.getMode());
|
||||
presenceMessageBuilder.setHeader(XmppHeaders.PRESENCE_TYPE, presence.getType());
|
||||
presenceMessageBuilder.setHeader(XmppHeaders.PRESENCE_FROM, presence.getFrom());
|
||||
private static final Log logger = LogFactory.getLog(XmppPresenceMessageMapper.class);
|
||||
|
||||
return presenceMessageBuilder.build();
|
||||
}
|
||||
/**
|
||||
* Returns a {@link org.springframework.integration.Message} with payload {@link org.jivesoftware.smack.packet.Presence}
|
||||
*
|
||||
* @param presence the presence object that can be used to present the priority, status, mode, and type of a given roster entry. This will be decomposed into a series of headers, as well as a payload
|
||||
* @return the Message
|
||||
* @throws Exception thrown if conversion should fail
|
||||
*/
|
||||
public Message<?> toMessage(Presence presence) throws Exception {
|
||||
MessageBuilder<?> presenceMessageBuilder = MessageBuilder.withPayload(presence);
|
||||
presenceMessageBuilder.setHeader(XmppHeaders.PRESENCE_PRIORITY, presence.getPriority());
|
||||
presenceMessageBuilder.setHeader(XmppHeaders.PRESENCE_STATUS, presence.getStatus());
|
||||
presenceMessageBuilder.setHeader(XmppHeaders.PRESENCE_MODE, presence.getMode());
|
||||
presenceMessageBuilder.setHeader(XmppHeaders.PRESENCE_TYPE, presence.getType());
|
||||
presenceMessageBuilder.setHeader(XmppHeaders.PRESENCE_FROM, presence.getFrom());
|
||||
|
||||
/**
|
||||
* Builds a {@link org.jivesoftware.smack.packet.Presence} object from the inbound Message headers, if possible.
|
||||
*
|
||||
* @param message the Message whose headers and payload willl b
|
||||
* @return the presence object as constructed from the {@link org.springframework.integration.Message} object
|
||||
* @throws Exception if there is a problem
|
||||
*/
|
||||
public Presence fromMessage(Message<?> message) throws Exception {
|
||||
MessageHeaders messageHeaders = message.getHeaders();
|
||||
return presenceMessageBuilder.build();
|
||||
}
|
||||
|
||||
Integer priority = (Integer) messageHeaders.get(XmppHeaders.PRESENCE_PRIORITY);
|
||||
String status = (String) messageHeaders.get(XmppHeaders.PRESENCE_STATUS);
|
||||
String language = (String) messageHeaders.get(XmppHeaders.PRESENCE_LANGUAGE);
|
||||
String from = (String) messageHeaders.get(XmppHeaders.PRESENCE_FROM);
|
||||
/**
|
||||
* Builds a {@link org.jivesoftware.smack.packet.Presence} object from the inbound Message headers, if possible.
|
||||
*
|
||||
* @param message the Message whose headers and payload willl b
|
||||
* @return the presence object as constructed from the {@link org.springframework.integration.Message} object
|
||||
* @throws Exception if there is a problem
|
||||
*/
|
||||
public Presence fromMessage(Message<?> message) throws Exception {
|
||||
MessageHeaders messageHeaders = message.getHeaders();
|
||||
|
||||
// trickery afoot
|
||||
Object modeObj = messageHeaders.get(XmppHeaders.PRESENCE_MODE);
|
||||
Presence.Mode mode = null;
|
||||
Integer priority = (Integer) messageHeaders.get(XmppHeaders.PRESENCE_PRIORITY);
|
||||
String status = (String) messageHeaders.get(XmppHeaders.PRESENCE_STATUS);
|
||||
String language = (String) messageHeaders.get(XmppHeaders.PRESENCE_LANGUAGE);
|
||||
String from = (String) messageHeaders.get(XmppHeaders.PRESENCE_FROM);
|
||||
|
||||
Object typeObj = messageHeaders.get(XmppHeaders.PRESENCE_TYPE);
|
||||
Presence.Type type = null;
|
||||
// trickery afoot
|
||||
Object modeObj = messageHeaders.get(XmppHeaders.PRESENCE_MODE);
|
||||
Presence.Mode mode = null;
|
||||
|
||||
if (typeObj instanceof String) {
|
||||
try {
|
||||
type = Presence.Type.valueOf((String) typeObj);
|
||||
} catch (Throwable th) {
|
||||
logger.debug("couldn't convert type header into an object of type Presence.Type");
|
||||
}
|
||||
} else if (modeObj instanceof Presence.Type) {
|
||||
type = (Presence.Type) typeObj;
|
||||
}
|
||||
Object typeObj = messageHeaders.get(XmppHeaders.PRESENCE_TYPE);
|
||||
Presence.Type type = null;
|
||||
|
||||
if (modeObj instanceof String) {
|
||||
try {
|
||||
mode = Presence.Mode.valueOf((String) modeObj);
|
||||
} catch (Throwable th) {
|
||||
logger.debug("couldn't convert mode header into an object of type Presence.Mode ");
|
||||
}
|
||||
} else if (modeObj instanceof Presence.Mode) {
|
||||
mode = (Presence.Mode) modeObj;
|
||||
}
|
||||
if (typeObj instanceof String) {
|
||||
try {
|
||||
type = Presence.Type.valueOf((String) typeObj);
|
||||
} catch (Throwable th) {
|
||||
logger.debug("couldn't convert type header into an object of type Presence.Type");
|
||||
}
|
||||
} else if (modeObj instanceof Presence.Type) {
|
||||
type = (Presence.Type) typeObj;
|
||||
}
|
||||
|
||||
Object payload = message.getPayload();
|
||||
if (modeObj instanceof String) {
|
||||
try {
|
||||
mode = Presence.Mode.valueOf((String) modeObj);
|
||||
} catch (Throwable th) {
|
||||
logger.debug("couldn't convert mode header into an object of type Presence.Mode ");
|
||||
}
|
||||
} else if (modeObj instanceof Presence.Mode) {
|
||||
mode = (Presence.Mode) modeObj;
|
||||
}
|
||||
|
||||
if (null != payload) {
|
||||
if (payload instanceof Presence) {
|
||||
return (Presence) payload;
|
||||
}
|
||||
Object payload = message.getPayload();
|
||||
|
||||
if (payload instanceof Presence.Type) {
|
||||
type = (Presence.Type) payload;
|
||||
}
|
||||
}
|
||||
if (null != payload) {
|
||||
if (payload instanceof Presence) {
|
||||
return (Presence) payload;
|
||||
}
|
||||
|
||||
return this.factoryPresence(from, status, priority, type, mode, language);
|
||||
}
|
||||
if (payload instanceof Presence.Type) {
|
||||
type = (Presence.Type) payload;
|
||||
}
|
||||
}
|
||||
|
||||
private Presence factoryPresence(String from, String status, Integer priority,
|
||||
Presence.Type type, Presence.Mode mode, String language) {
|
||||
if (null == type) {
|
||||
type = Presence.Type.available;
|
||||
}
|
||||
return this.factoryPresence(from, status, priority, type, mode, language);
|
||||
}
|
||||
|
||||
Presence presence = new Presence(type);
|
||||
private Presence factoryPresence(String from, String status, Integer priority,
|
||||
Presence.Type type, Presence.Mode mode, String language) {
|
||||
if (null == type) {
|
||||
type = Presence.Type.available;
|
||||
}
|
||||
|
||||
if (null != priority) {
|
||||
presence.setPriority(priority);
|
||||
}
|
||||
Presence presence = new Presence(type);
|
||||
|
||||
if (StringUtils.hasText(status)) {
|
||||
presence.setStatus(status);
|
||||
}
|
||||
if (null != priority) {
|
||||
presence.setPriority(priority);
|
||||
}
|
||||
|
||||
if (StringUtils.hasText(from)) {
|
||||
presence.setFrom(from);
|
||||
}
|
||||
if (StringUtils.hasText(status)) {
|
||||
presence.setStatus(status);
|
||||
}
|
||||
|
||||
if (null != mode) {
|
||||
presence.setMode(mode);
|
||||
}
|
||||
if (StringUtils.hasText(from)) {
|
||||
presence.setFrom(from);
|
||||
}
|
||||
|
||||
if (StringUtils.hasText(language)) {
|
||||
presence.setLanguage(language);
|
||||
}
|
||||
if (null != mode) {
|
||||
presence.setMode(mode);
|
||||
}
|
||||
|
||||
return presence;
|
||||
}
|
||||
if (StringUtils.hasText(language)) {
|
||||
presence.setLanguage(language);
|
||||
}
|
||||
|
||||
return presence;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,13 +20,10 @@ import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang.builder.ToStringBuilder;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.jivesoftware.smack.RosterListener;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.packet.Presence;
|
||||
|
||||
import org.springframework.context.Lifecycle;
|
||||
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.integration.core.MessageChannel;
|
||||
import org.springframework.integration.core.MessagingTemplate;
|
||||
@@ -46,99 +43,99 @@ import java.util.Collection;
|
||||
*/
|
||||
public class XmppRosterEventMessageDrivenEndpoint extends AbstractEndpoint implements Lifecycle {
|
||||
|
||||
private static final Log logger = LogFactory.getLog(XmppRosterEventMessageDrivenEndpoint.class);
|
||||
private static final Log logger = LogFactory.getLog(XmppRosterEventMessageDrivenEndpoint.class);
|
||||
|
||||
|
||||
private volatile MessageChannel requestChannel;
|
||||
private volatile MessageChannel requestChannel;
|
||||
|
||||
private volatile XMPPConnection xmppConnection;
|
||||
private volatile XMPPConnection xmppConnection;
|
||||
|
||||
private InboundMessageMapper<Presence> messageMapper;
|
||||
private InboundMessageMapper<Presence> messageMapper;
|
||||
|
||||
private final MessagingTemplate messagingTemplate = new MessagingTemplate();
|
||||
private final MessagingTemplate messagingTemplate = new MessagingTemplate();
|
||||
|
||||
|
||||
/**
|
||||
* This will be injected or configured via a <em>xmpp-connection-factory</em> element.
|
||||
*
|
||||
* @param xmppConnection the connection
|
||||
*/
|
||||
public void setXmppConnection(final XMPPConnection xmppConnection) {
|
||||
this.xmppConnection = xmppConnection;
|
||||
}
|
||||
/**
|
||||
* This will be injected or configured via a <em>xmpp-connection-factory</em> element.
|
||||
*
|
||||
* @param xmppConnection the connection
|
||||
*/
|
||||
public void setXmppConnection(final XMPPConnection xmppConnection) {
|
||||
this.xmppConnection = xmppConnection;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param requestChannel the channel on which the inbound message should be sent
|
||||
*/
|
||||
public void setRequestChannel(final MessageChannel requestChannel) {
|
||||
this.messagingTemplate.setDefaultChannel(requestChannel);
|
||||
this.requestChannel = requestChannel;
|
||||
}
|
||||
/**
|
||||
* @param requestChannel the channel on which the inbound message should be sent
|
||||
*/
|
||||
public void setRequestChannel(final MessageChannel requestChannel) {
|
||||
this.messagingTemplate.setDefaultChannel(requestChannel);
|
||||
this.requestChannel = requestChannel;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doStart() {
|
||||
logger.debug("start: " + xmppConnection.isConnected() + ":" +
|
||||
xmppConnection.isAuthenticated());
|
||||
}
|
||||
@Override
|
||||
protected void doStart() {
|
||||
logger.debug("start: " + xmppConnection.isConnected() + ":" +
|
||||
xmppConnection.isAuthenticated());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doStop() {
|
||||
if (this.xmppConnection.isConnected()) {
|
||||
logger.debug("shutting down " + XmppRosterEventMessageDrivenEndpoint.class.getName() +
|
||||
".");
|
||||
this.xmppConnection.disconnect();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
protected void doStop() {
|
||||
if (this.xmppConnection.isConnected()) {
|
||||
logger.debug("shutting down " + XmppRosterEventMessageDrivenEndpoint.class.getName() +
|
||||
".");
|
||||
this.xmppConnection.disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onInit() throws Exception {
|
||||
if (null == this.messageMapper) {
|
||||
this.messageMapper = new XmppPresenceMessageMapper();
|
||||
}
|
||||
@Override
|
||||
protected void onInit() throws Exception {
|
||||
if (null == this.messageMapper) {
|
||||
this.messageMapper = new XmppPresenceMessageMapper();
|
||||
}
|
||||
|
||||
this.messagingTemplate.afterPropertiesSet();
|
||||
this.xmppConnection.getRoster().addRosterListener(new EventForwardingRosterListener());
|
||||
}
|
||||
this.messagingTemplate.afterPropertiesSet();
|
||||
this.xmppConnection.getRoster().addRosterListener(new EventForwardingRosterListener());
|
||||
}
|
||||
|
||||
/**
|
||||
* Called whenever an event happesn related to the {@link org.jivesoftware.smack.Roster}
|
||||
*
|
||||
* @param presence the {@link org.jivesoftware.smack.packet.Presence} object representing the new state (optional)
|
||||
*/
|
||||
protected void forwardRosterEventMessage(Presence presence) {
|
||||
try {
|
||||
Message<?> msg = this.messageMapper.toMessage(presence);
|
||||
messagingTemplate.send(requestChannel, msg);
|
||||
}
|
||||
catch (Exception e) {
|
||||
logger.error("Failed to map packet to message ", e);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Called whenever an event happesn related to the {@link org.jivesoftware.smack.Roster}
|
||||
*
|
||||
* @param presence the {@link org.jivesoftware.smack.packet.Presence} object representing the new state (optional)
|
||||
*/
|
||||
protected void forwardRosterEventMessage(Presence presence) {
|
||||
try {
|
||||
Message<?> msg = this.messageMapper.toMessage(presence);
|
||||
messagingTemplate.send(requestChannel, msg);
|
||||
}
|
||||
catch (Exception e) {
|
||||
logger.error("Failed to map packet to message ", e);
|
||||
}
|
||||
}
|
||||
|
||||
public void setMessageMapper(InboundMessageMapper<Presence> messageMapper) {
|
||||
this.messageMapper = messageMapper;
|
||||
}
|
||||
public void setMessageMapper(InboundMessageMapper<Presence> messageMapper) {
|
||||
this.messageMapper = messageMapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* Subscribes to a given {@link org.jivesoftware.smack.Roster}s events and forwards them to components on the bus.
|
||||
*/
|
||||
class EventForwardingRosterListener implements RosterListener {
|
||||
public void entriesAdded(final Collection<String> entries) {
|
||||
logger.debug("entries added: " + StringUtils.join(entries.iterator(), ","));
|
||||
}
|
||||
/**
|
||||
* Subscribes to a given {@link org.jivesoftware.smack.Roster}s events and forwards them to components on the bus.
|
||||
*/
|
||||
class EventForwardingRosterListener implements RosterListener {
|
||||
public void entriesAdded(final Collection<String> entries) {
|
||||
logger.debug("entries added: " + StringUtils.join(entries.iterator(), ","));
|
||||
}
|
||||
|
||||
public void entriesUpdated(final Collection<String> entries) {
|
||||
logger.debug("entries updated: " + StringUtils.join(entries.iterator(), ","));
|
||||
}
|
||||
public void entriesUpdated(final Collection<String> entries) {
|
||||
logger.debug("entries updated: " + StringUtils.join(entries.iterator(), ","));
|
||||
}
|
||||
|
||||
public void entriesDeleted(final Collection<String> entries) {
|
||||
logger.debug("entries deleted: " + StringUtils.join(entries.iterator(), ","));
|
||||
}
|
||||
public void entriesDeleted(final Collection<String> entries) {
|
||||
logger.debug("entries deleted: " + StringUtils.join(entries.iterator(), ","));
|
||||
}
|
||||
|
||||
public void presenceChanged(final Presence presence) {
|
||||
logger.debug("presence changed: " + ToStringBuilder.reflectionToString(presence));
|
||||
forwardRosterEventMessage(presence);
|
||||
}
|
||||
}
|
||||
|
||||
public void presenceChanged(final Presence presence) {
|
||||
logger.debug("presence changed: " + ToStringBuilder.reflectionToString(presence));
|
||||
forwardRosterEventMessage(presence);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -15,12 +15,12 @@ import org.springframework.integration.mapping.OutboundMessageMapper;
|
||||
/**
|
||||
* This class will facilitate publishing updated presence values for a given connection. This change happens on the
|
||||
* {@link org.jivesoftware.smack.Roster#setSubscriptionMode(org.jivesoftware.smack.Roster.SubscriptionMode)} property.
|
||||
*
|
||||
*
|
||||
* @author Josh Long
|
||||
* @see org.jivesoftware.smack.packet.Presence.Mode the mode (i.e.:
|
||||
* {@link org.jivesoftware.smack.packet.Presence.Mode#away})
|
||||
* {@link org.jivesoftware.smack.packet.Presence.Mode#away})
|
||||
* @see org.jivesoftware.smack.packet.Presence.Type the type (i.e.:
|
||||
* {@link org.jivesoftware.smack.packet.Presence.Type#available} )
|
||||
* {@link org.jivesoftware.smack.packet.Presence.Type#available} )
|
||||
* @since 2.0
|
||||
*/
|
||||
public class XmppRosterEventMessageSendingHandler implements MessageHandler, Lifecycle {
|
||||
@@ -74,6 +74,7 @@ public class XmppRosterEventMessageSendingHandler implements MessageHandler, Lif
|
||||
/**
|
||||
* the MessageMapper is responsible for converting outbound Messages into status updates of type
|
||||
* {@link org.jivesoftware.smack.packet.Presence}
|
||||
*
|
||||
* @param messageMapper mapper for the message into a {@link Presence} instance
|
||||
*/
|
||||
public void setMessageMapper(OutboundMessageMapper<Presence> messageMapper) {
|
||||
|
||||
@@ -15,203 +15,202 @@
|
||||
~ limitations under the License.
|
||||
-->
|
||||
<xsd:schema xmlns="http://www.springframework.org/schema/integration/xmpp"
|
||||
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
||||
xmlns:beans="http://www.springframework.org/schema/beans"
|
||||
xmlns:tool="http://www.springframework.org/schema/tool"
|
||||
xmlns:integration="http://www.springframework.org/schema/integration"
|
||||
targetNamespace="http://www.springframework.org/schema/integration/xmpp"
|
||||
elementFormDefault="qualified"
|
||||
attributeFormDefault="unqualified">
|
||||
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
||||
xmlns:beans="http://www.springframework.org/schema/beans"
|
||||
xmlns:tool="http://www.springframework.org/schema/tool"
|
||||
xmlns:integration="http://www.springframework.org/schema/integration"
|
||||
targetNamespace="http://www.springframework.org/schema/integration/xmpp"
|
||||
elementFormDefault="qualified"
|
||||
attributeFormDefault="unqualified">
|
||||
|
||||
<xsd:import namespace="http://www.springframework.org/schema/beans"/>
|
||||
<xsd:import namespace="http://www.springframework.org/schema/beans"/>
|
||||
<xsd:import namespace="http://www.springframework.org/schema/tool"/>
|
||||
<xsd:import namespace="http://www.springframework.org/schema/integration"
|
||||
schemaLocation="http://www.springframework.org/schema/integration/spring-integration-2.0.xsd"/>
|
||||
schemaLocation="http://www.springframework.org/schema/integration/spring-integration-2.0.xsd"/>
|
||||
|
||||
<xsd:element name="xmpp-connection">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
Configures an XMPP connection that can in turn be referenced by other components
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="id" type="xsd:string"/>
|
||||
<xsd:attribute name="user" type="xsd:string" use="required"/>
|
||||
<xsd:attribute name="password" type="xsd:string" use="required"/>
|
||||
<xsd:attribute name="host" type="xsd:string" use="required"/>
|
||||
<xsd:attribute name="service-name" type="xsd:string"/>
|
||||
<xsd:attribute name="resource" type="xsd:string"/>
|
||||
<xsd:attribute name="sasl-mechanism-supported" type="xsd:string"/>
|
||||
<xsd:attribute name="sasl-mechanism-supported-index" type="xsd:string"/>
|
||||
<xsd:attribute name="port" type="xsd:string" />
|
||||
<xsd:attribute name="subscription-mode" default="accept_all" >
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
<xsd:element name="xmpp-connection">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
Configures an XMPP connection that can in turn be referenced by other components
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="id" type="xsd:string"/>
|
||||
<xsd:attribute name="user" type="xsd:string" use="required"/>
|
||||
<xsd:attribute name="password" type="xsd:string" use="required"/>
|
||||
<xsd:attribute name="host" type="xsd:string" use="required"/>
|
||||
<xsd:attribute name="service-name" type="xsd:string"/>
|
||||
<xsd:attribute name="resource" type="xsd:string"/>
|
||||
<xsd:attribute name="sasl-mechanism-supported" type="xsd:string"/>
|
||||
<xsd:attribute name="sasl-mechanism-supported-index" type="xsd:string"/>
|
||||
<xsd:attribute name="port" type="xsd:string"/>
|
||||
<xsd:attribute name="subscription-mode" default="accept_all">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
The subscription mode for the XMPP connection. Dictates the policy for handling inbound messages from entries not already on the roster.
|
||||
Values can be "accept_all," "manual," or "reject_all."
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:simpleType>
|
||||
<xsd:restriction base="xsd:NMTOKEN">
|
||||
<xsd:enumeration value="accept_all"/>
|
||||
<xsd:enumeration value="manual"/>
|
||||
<xsd:enumeration value="reject_all"/>
|
||||
</xsd:restriction>
|
||||
</xsd:simpleType>
|
||||
</xsd:attribute>
|
||||
</xsd:annotation>
|
||||
<xsd:simpleType>
|
||||
<xsd:restriction base="xsd:NMTOKEN">
|
||||
<xsd:enumeration value="accept_all"/>
|
||||
<xsd:enumeration value="manual"/>
|
||||
<xsd:enumeration value="reject_all"/>
|
||||
</xsd:restriction>
|
||||
</xsd:simpleType>
|
||||
</xsd:attribute>
|
||||
|
||||
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
|
||||
<xsd:element name="roster-event-outbound-channel-adapter">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
Configures an endpoint that will publish an updated {@link org.jivesoftware.smack.packet.Presence} state on your {@link XMPPConnection } object.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="id" type="xsd:string"/>
|
||||
<xsd:attribute name="channel" use="required" type="xsd:string">
|
||||
<xsd:annotation>
|
||||
<xsd:appinfo>
|
||||
<tool:annotation kind="ref">
|
||||
<tool:expected-type type="org.springframework.integration.core.MessageChannel"/>
|
||||
</tool:annotation>
|
||||
</xsd:appinfo>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="xmpp-connection" type="xsd:string" use="required" >
|
||||
<xsd:annotation>
|
||||
<xsd:appinfo>
|
||||
<tool:annotation kind="ref">
|
||||
<tool:expected-type type="org.jivesoftware.smack.XMPPConnection"/>
|
||||
</tool:annotation>
|
||||
</xsd:appinfo>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="roster-event-outbound-channel-adapter">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
Configures an endpoint that will publish an updated {@link org.jivesoftware.smack.packet.Presence} state on your {@link XMPPConnection } object.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="id" type="xsd:string"/>
|
||||
<xsd:attribute name="channel" use="required" type="xsd:string">
|
||||
<xsd:annotation>
|
||||
<xsd:appinfo>
|
||||
<tool:annotation kind="ref">
|
||||
<tool:expected-type type="org.springframework.integration.core.MessageChannel"/>
|
||||
</tool:annotation>
|
||||
</xsd:appinfo>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="xmpp-connection" type="xsd:string" use="required">
|
||||
<xsd:annotation>
|
||||
<xsd:appinfo>
|
||||
<tool:annotation kind="ref">
|
||||
<tool:expected-type type="org.jivesoftware.smack.XMPPConnection"/>
|
||||
</tool:annotation>
|
||||
</xsd:appinfo>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
|
||||
<xsd:element name="roster-event-inbound-channel-adapter">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
Configures an endpoint that will forward roster based events (entry managment and presence state changes) to components in the bus.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="id" type="xsd:string"/>
|
||||
<xsd:attribute name="channel" use="required" type="xsd:string">
|
||||
<xsd:annotation>
|
||||
<xsd:appinfo>
|
||||
<tool:annotation kind="ref">
|
||||
<tool:expected-type type="org.springframework.integration.core.MessageChannel"/>
|
||||
</tool:annotation>
|
||||
</xsd:appinfo>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="xmpp-connection" type="xsd:string" use="required" >
|
||||
<xsd:annotation>
|
||||
<xsd:appinfo>
|
||||
<tool:annotation kind="ref">
|
||||
<tool:expected-type type="org.jivesoftware.smack.XMPPConnection"/>
|
||||
</tool:annotation>
|
||||
</xsd:appinfo>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="roster-event-inbound-channel-adapter">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
Configures an endpoint that will forward roster based events (entry managment and presence state changes) to components in the bus.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="id" type="xsd:string"/>
|
||||
<xsd:attribute name="channel" use="required" type="xsd:string">
|
||||
<xsd:annotation>
|
||||
<xsd:appinfo>
|
||||
<tool:annotation kind="ref">
|
||||
<tool:expected-type type="org.springframework.integration.core.MessageChannel"/>
|
||||
</tool:annotation>
|
||||
</xsd:appinfo>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="xmpp-connection" type="xsd:string" use="required">
|
||||
<xsd:annotation>
|
||||
<xsd:appinfo>
|
||||
<tool:annotation kind="ref">
|
||||
<tool:expected-type type="org.jivesoftware.smack.XMPPConnection"/>
|
||||
</tool:annotation>
|
||||
</xsd:appinfo>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
|
||||
<xsd:element name="message-inbound-channel-adapter">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
Configures an endpoint that will receive messages sent to a given account and then forward those messages to components in the bus.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="id" type="xsd:string"/>
|
||||
<xsd:attribute name="channel" use="required" type="xsd:string">
|
||||
<xsd:annotation>
|
||||
<xsd:appinfo>
|
||||
<tool:annotation kind="ref">
|
||||
<tool:expected-type type="org.springframework.integration.core.MessageChannel"/>
|
||||
</tool:annotation>
|
||||
</xsd:appinfo>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="xmpp-connection" type="xsd:string" use="required" >
|
||||
<xsd:annotation>
|
||||
<xsd:appinfo>
|
||||
<tool:annotation kind="ref">
|
||||
<tool:expected-type type="org.jivesoftware.smack.XMPPConnection"/>
|
||||
</tool:annotation>
|
||||
</xsd:appinfo>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="message-inbound-channel-adapter">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
Configures an endpoint that will receive messages sent to a given account and then forward those messages to components in the bus.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="id" type="xsd:string"/>
|
||||
<xsd:attribute name="channel" use="required" type="xsd:string">
|
||||
<xsd:annotation>
|
||||
<xsd:appinfo>
|
||||
<tool:annotation kind="ref">
|
||||
<tool:expected-type type="org.springframework.integration.core.MessageChannel"/>
|
||||
</tool:annotation>
|
||||
</xsd:appinfo>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="xmpp-connection" type="xsd:string" use="required">
|
||||
<xsd:annotation>
|
||||
<xsd:appinfo>
|
||||
<tool:annotation kind="ref">
|
||||
<tool:expected-type type="org.jivesoftware.smack.XMPPConnection"/>
|
||||
</tool:annotation>
|
||||
</xsd:appinfo>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
|
||||
<xsd:element name="message-outbound-channel-adapter">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
Component that sends messages to an entry in the roster on behalf of components in the bus.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="id" type="xsd:string"/>
|
||||
<xsd:attribute name="channel" use="required" type="xsd:string">
|
||||
<xsd:annotation>
|
||||
<xsd:appinfo>
|
||||
<tool:annotation kind="ref">
|
||||
<tool:expected-type type="org.springframework.integration.core.MessageChannel"/>
|
||||
</tool:annotation>
|
||||
</xsd:appinfo>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="xmpp-connection" type="xsd:string" use="required" >
|
||||
<xsd:annotation>
|
||||
<xsd:appinfo>
|
||||
<tool:annotation kind="ref">
|
||||
<tool:expected-type type="org.jivesoftware.smack.XMPPConnection"/>
|
||||
</tool:annotation>
|
||||
</xsd:appinfo>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="message-outbound-channel-adapter">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
Component that sends messages to an entry in the roster on behalf of components in the bus.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="id" type="xsd:string"/>
|
||||
<xsd:attribute name="channel" use="required" type="xsd:string">
|
||||
<xsd:annotation>
|
||||
<xsd:appinfo>
|
||||
<tool:annotation kind="ref">
|
||||
<tool:expected-type type="org.springframework.integration.core.MessageChannel"/>
|
||||
</tool:annotation>
|
||||
</xsd:appinfo>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="xmpp-connection" type="xsd:string" use="required">
|
||||
<xsd:annotation>
|
||||
<xsd:appinfo>
|
||||
<tool:annotation kind="ref">
|
||||
<tool:expected-type type="org.jivesoftware.smack.XMPPConnection"/>
|
||||
</tool:annotation>
|
||||
</xsd:appinfo>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
|
||||
<xsd:element name="header-enricher">
|
||||
<xsd:complexType>
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
Defines a Transformer for adding XMPP headers.
|
||||
Defines a Transformer for adding XMPP headers.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:complexContent>
|
||||
<xsd:extension base="transformerType">
|
||||
<xsd:choice minOccurs="1" maxOccurs="unbounded">
|
||||
|
||||
|
||||
|
||||
<xsd:element name="message-to" type="headerType"/>
|
||||
<xsd:element name="message-thread-id" type="headerType"/>
|
||||
<xsd:element name="presence-from" type="headerType"/>
|
||||
<xsd:element name="presence-mode" type="headerType"/>
|
||||
<xsd:element name="presence-type" type="headerType"/>
|
||||
<xsd:element name="presence-status" type="headerType"/>
|
||||
<xsd:element name="presence-priority" type="headerType"/>
|
||||
<xsd:element name="message-thread-id" type="headerType"/>
|
||||
<xsd:element name="presence-from" type="headerType"/>
|
||||
<xsd:element name="presence-mode" type="headerType"/>
|
||||
<xsd:element name="presence-type" type="headerType"/>
|
||||
<xsd:element name="presence-status" type="headerType"/>
|
||||
<xsd:element name="presence-priority" type="headerType"/>
|
||||
</xsd:choice>
|
||||
<xsd:attribute name="default-overwrite">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
Specify the default boolean value for whether to overwrite existing header values. This will only take effect for
|
||||
sub-elements that do not provide their own 'overwrite' attribute. If the 'default-overwrite' attribute is not
|
||||
provided, then the specified header values will NOT overwrite any existing ones with the same header names.
|
||||
Specify the default boolean value for whether to overwrite existing header values. This will only take effect for
|
||||
sub-elements that do not provide their own 'overwrite' attribute. If the 'default-overwrite' attribute is not
|
||||
provided, then the specified header values will NOT overwrite any existing ones with the same header names.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:simpleType>
|
||||
<xsd:union memberTypes="xsd:boolean xsd:string"/>
|
||||
</xsd:simpleType>
|
||||
</xsd:simpleType>
|
||||
</xsd:attribute>
|
||||
</xsd:extension>
|
||||
</xsd:complexContent>
|
||||
@@ -219,13 +218,13 @@ Component that sends messages to an entry in the roster on behalf of components
|
||||
</xsd:element>
|
||||
|
||||
<xsd:complexType name="headerType">
|
||||
<xsd:attribute name="value" type="xsd:string" />
|
||||
<xsd:attribute name="ref" type="xsd:string" />
|
||||
<xsd:attribute name="expression" type="xsd:string" />
|
||||
<xsd:attribute name="value" type="xsd:string"/>
|
||||
<xsd:attribute name="ref" type="xsd:string"/>
|
||||
<xsd:attribute name="expression" type="xsd:string"/>
|
||||
<xsd:attribute name="overwrite">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
Boolean value to indicate whether this header value should overwrite an existing header value for the same name.
|
||||
Boolean value to indicate whether this header value should overwrite an existing header value for the same name.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:simpleType>
|
||||
|
||||
@@ -19,11 +19,8 @@ package org.springframework.integration.xmpp.config;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.integration.MessageDeliveryException;
|
||||
import org.springframework.integration.MessageHandlingException;
|
||||
@@ -32,8 +29,6 @@ import org.springframework.integration.channel.DirectChannel;
|
||||
import org.springframework.integration.core.MessageBuilder;
|
||||
import org.springframework.integration.core.MessageHandler;
|
||||
import org.springframework.integration.core.MessagingTemplate;
|
||||
import org.springframework.integration.mapping.*;
|
||||
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
@@ -47,26 +42,26 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
public class XmppHeaderEnricherParserTests {
|
||||
|
||||
|
||||
private static final Log logger = LogFactory.getLog(XmppHeaderEnricherParserTests.class);
|
||||
private static final Log logger = LogFactory.getLog(XmppHeaderEnricherParserTests.class);
|
||||
|
||||
@Value("#{input}")
|
||||
private DirectChannel input;
|
||||
@Value("#{input}")
|
||||
private DirectChannel input;
|
||||
|
||||
@Value("#{output}")
|
||||
private DirectChannel output;
|
||||
@Value("#{output}")
|
||||
private DirectChannel output;
|
||||
|
||||
@Test
|
||||
public void to() {
|
||||
MessagingTemplate messagingTemplate = new MessagingTemplate();
|
||||
output.subscribe(new MessageHandler() {
|
||||
public void handleMessage(Message<?> message)
|
||||
throws MessageRejectedException, MessageHandlingException,
|
||||
MessageDeliveryException {
|
||||
for (String h : message.getHeaders().keySet())
|
||||
logger.debug(String.format("%s=%s (class: %s)", h, message.getHeaders().get(h), message.getHeaders().get(h).getClass().toString()));
|
||||
}
|
||||
});
|
||||
messagingTemplate.send(input, MessageBuilder.withPayload("foo").build());
|
||||
}
|
||||
@Test
|
||||
public void to() {
|
||||
MessagingTemplate messagingTemplate = new MessagingTemplate();
|
||||
output.subscribe(new MessageHandler() {
|
||||
public void handleMessage(Message<?> message)
|
||||
throws MessageRejectedException, MessageHandlingException,
|
||||
MessageDeliveryException {
|
||||
for (String h : message.getHeaders().keySet())
|
||||
logger.debug(String.format("%s=%s (class: %s)", h, message.getHeaders().get(h), message.getHeaders().get(h).getClass().toString()));
|
||||
}
|
||||
});
|
||||
messagingTemplate.send(input, MessageBuilder.withPayload("foo").build());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,15 +24,16 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
/**
|
||||
* @author Mark Fisher
|
||||
* @since 2.0
|
||||
* @since 2.0
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
public class ConsoleChatTests {
|
||||
|
||||
@Test @Ignore
|
||||
@Test
|
||||
@Ignore
|
||||
public void run() throws Exception {
|
||||
Thread.sleep( 10 * 1000 );
|
||||
Thread.sleep(10 * 1000);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -30,9 +30,10 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
public class InboundXmppEndpointTests {
|
||||
|
||||
@Test @Ignore
|
||||
@Test
|
||||
@Ignore
|
||||
public void run() throws Exception {
|
||||
Thread.sleep( 10 * 1000 );
|
||||
Thread.sleep(10 * 1000);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,13 +19,12 @@ package org.springframework.integration.xmpp.messages;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
/**
|
||||
* Testing support for sending messages.
|
||||
*
|
||||
*
|
||||
* @author Josh Long
|
||||
* @since 2.0
|
||||
*/
|
||||
@@ -33,9 +32,10 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
public class OutboundXmppEndpointTests {
|
||||
|
||||
@Test @Ignore
|
||||
@Test
|
||||
@Ignore
|
||||
public void run() throws Exception {
|
||||
Thread.sleep(10 * 1000);
|
||||
Thread.sleep(10 * 1000);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package org.springframework.integration.xmpp.messages;
|
||||
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
|
||||
import org.springframework.integration.annotation.ServiceActivator;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@@ -36,16 +35,14 @@ public class XmppMessageConsumer {
|
||||
String text = null;
|
||||
if (input instanceof Message) {
|
||||
text = ((Message) input).getBody();
|
||||
}
|
||||
else if (input instanceof String) {
|
||||
} else if (input instanceof String) {
|
||||
text = (String) input;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
throw new IllegalArgumentException(
|
||||
"expected either a Smack Message or a String, but received: " + input);
|
||||
}
|
||||
System.out.println("================================================================================");
|
||||
System.out.println("message: " + text);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -36,13 +36,13 @@ public class XmppMessageProducer implements MessageSource<String> {
|
||||
private static final Log logger = LogFactory.getLog(XmppMessageProducer.class);
|
||||
|
||||
private volatile int counter;
|
||||
private String recipient;
|
||||
private String recipient;
|
||||
|
||||
public void setRecipient(final String recipient) {
|
||||
this.recipient = recipient;
|
||||
}
|
||||
public void setRecipient(final String recipient) {
|
||||
this.recipient = recipient;
|
||||
}
|
||||
|
||||
public Message<String> receive() {
|
||||
public Message<String> receive() {
|
||||
try {
|
||||
if (counter > 10) {
|
||||
logger.debug("return null");
|
||||
@@ -51,10 +51,10 @@ public class XmppMessageProducer implements MessageSource<String> {
|
||||
counter += 1;
|
||||
Thread.sleep(1000 * 2);
|
||||
|
||||
String msg = "the current time is " + new Date();
|
||||
String msg = "the current time is " + new Date();
|
||||
|
||||
logger.info("sending message to recipient " + recipient);
|
||||
|
||||
|
||||
return MessageBuilder.withPayload(msg).setHeader(XmppHeaders.CHAT_TO_USER, recipient).build();
|
||||
}
|
||||
catch (InterruptedException e) {
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
/**
|
||||
* this class demonstrates that when I launch this and then manipulate the status of the
|
||||
* user using Pidgin, the updated state is immediately delivered to the Spring Integration bus.
|
||||
*
|
||||
*
|
||||
* @author Josh Long
|
||||
* @since 2.0
|
||||
*/
|
||||
@@ -33,9 +33,10 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
public class InboundXmppRosterEventsEndpointTests {
|
||||
|
||||
@Test @Ignore
|
||||
@Test
|
||||
@Ignore
|
||||
public void run() throws Exception {
|
||||
Thread.sleep( 60 * 1000);
|
||||
Thread.sleep(60 * 1000);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -23,10 +23,8 @@ import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
/**
|
||||
*
|
||||
* Tests {@link XmppRosterEventMessageSendingHandler} to ensure that we are able to publish status.
|
||||
*
|
||||
*
|
||||
* @author Josh Long
|
||||
* @since 2.0
|
||||
*/
|
||||
@@ -34,8 +32,9 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
public class OutboundXmppRosterEventsEndpointTests {
|
||||
|
||||
@Test @Ignore
|
||||
public void testOutbound() throws Throwable {
|
||||
Thread.sleep( 60 * 1000);
|
||||
}
|
||||
@Test
|
||||
@Ignore
|
||||
public void testOutbound() throws Throwable {
|
||||
Thread.sleep(60 * 1000);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,11 +23,10 @@ import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
/**
|
||||
*
|
||||
* This class will demonstrate using both inbound adapter types in a 1-2 punch of:
|
||||
* <UL>
|
||||
* <LI> notifying the bus of a user's sudden online availability using <xmpp:roster-event-inbound-channel-adapter></LI>
|
||||
* <LI> sending that user a message using the <xmpp:outbound-message-channel-adapter /></LI>
|
||||
* <LI> notifying the bus of a user's sudden online availability using <xmpp:roster-event-inbound-channel-adapter></LI>
|
||||
* <LI> sending that user a message using the <xmpp:outbound-message-channel-adapter /></LI>
|
||||
* </UL>
|
||||
*
|
||||
* @author Josh Long
|
||||
@@ -37,9 +36,10 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
public class PresenceMessageComboTests {
|
||||
|
||||
@Test @Ignore
|
||||
public void run () throws Throwable {
|
||||
Thread.sleep( 60 * 1000);
|
||||
}
|
||||
@Test
|
||||
@Ignore
|
||||
public void run() throws Throwable {
|
||||
Thread.sleep(60 * 1000);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.springframework.integration.xmpp.XmppHeaders;
|
||||
/**
|
||||
* This class reacts to changes in
|
||||
* {@link org.jivesoftware.smack.packet.Presence} objects for a given account.
|
||||
*
|
||||
*
|
||||
* @author Josh Long
|
||||
* @since 2.0
|
||||
*/
|
||||
|
||||
@@ -17,20 +17,17 @@
|
||||
package org.springframework.integration.xmpp.presence;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
import org.jivesoftware.smack.packet.Presence;
|
||||
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.integration.core.MessageBuilder;
|
||||
import org.springframework.integration.core.MessageSource;
|
||||
import org.springframework.integration.mapping.*;
|
||||
import org.springframework.integration.xmpp.XmppHeaders;
|
||||
|
||||
/**
|
||||
* This is used in
|
||||
* {@link org.springframework.integration.xmpp.presence.OutboundXmppRosterEventsEndpointTests}
|
||||
* to produce fake status / presence updates.
|
||||
*
|
||||
*
|
||||
* @author Josh Long
|
||||
* @since 2.0
|
||||
*/
|
||||
@@ -47,8 +44,8 @@ public class XmppRosterEventProducer implements MessageSource<String> {
|
||||
XmppHeaders.PRESENCE_MODE, Presence.Mode.chat).setHeader(XmppHeaders.PRESENCE_TYPE,
|
||||
Presence.Type.available).setHeader(XmppHeaders.PRESENCE_STATUS, "She Loves me").build()
|
||||
: MessageBuilder.withPayload(StringUtils.EMPTY).setHeader(XmppHeaders.PRESENCE_MODE, Presence.Mode.dnd)
|
||||
.setHeader(XmppHeaders.PRESENCE_TYPE, Presence.Type.available).setHeader(
|
||||
XmppHeaders.PRESENCE_STATUS, "She Loves me not").build();
|
||||
.setHeader(XmppHeaders.PRESENCE_TYPE, Presence.Type.available).setHeader(
|
||||
XmppHeaders.PRESENCE_STATUS, "She Loves me not").build();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -15,29 +15,29 @@
|
||||
~ limitations under the License.
|
||||
-->
|
||||
<beans:beans
|
||||
xmlns="http://www.springframework.org/schema/integration"
|
||||
xmlns:beans="http://www.springframework.org/schema/beans"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xmlns:util="http://www.springframework.org/schema/util"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:xmpp="http://www.springframework.org/schema/integration/xmpp"
|
||||
xsi:schemaLocation="
|
||||
xmlns="http://www.springframework.org/schema/integration"
|
||||
xmlns:beans="http://www.springframework.org/schema/beans"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xmlns:util="http://www.springframework.org/schema/util"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:xmpp="http://www.springframework.org/schema/integration/xmpp"
|
||||
xsi:schemaLocation="
|
||||
http://www.springframework.org/schema/integration/xmpp http://www.springframework.org/schema/integration/xmpp/spring-integration-xmpp.xsd
|
||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/context http://www.springframework.org/schema/beans/spring-context.xsd
|
||||
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd
|
||||
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd">
|
||||
|
||||
<channel id="input"/>
|
||||
<channel id="output"/>
|
||||
<channel id="input"/>
|
||||
<channel id="output"/>
|
||||
|
||||
|
||||
<xmpp:header-enricher input-channel="input" output-channel="output">
|
||||
<xmpp:presence-from value="test@example.org"/>
|
||||
<xmpp:presence-mode value="available"/>
|
||||
<xmpp:message-to value="test1@example.org"/>
|
||||
<xmpp:presence-type value="unavailable"/>
|
||||
</xmpp:header-enricher>
|
||||
<xmpp:header-enricher input-channel="input" output-channel="output">
|
||||
<xmpp:presence-from value="test@example.org"/>
|
||||
<xmpp:presence-mode value="available"/>
|
||||
<xmpp:message-to value="test1@example.org"/>
|
||||
<xmpp:presence-type value="unavailable"/>
|
||||
</xmpp:header-enricher>
|
||||
|
||||
|
||||
</beans:beans>
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Copyright 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.
|
||||
-->
|
||||
<!--
|
||||
~ Copyright 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.
|
||||
-->
|
||||
<beans:beans xmlns="http://www.springframework.org/schema/integration"
|
||||
xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context"
|
||||
xmlns:util="http://www.springframework.org/schema/util" xmlns:xmpp="http://www.springframework.org/schema/integration/xmpp"
|
||||
xmlns:tool="http://www.springframework.org/schema/tool" xmlns:lang="http://www.springframework.org/schema/lang"
|
||||
xmlns:console="http://www.springframework.org/schema/integration/stream"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration-1.0.xsd
|
||||
xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context"
|
||||
xmlns:util="http://www.springframework.org/schema/util" xmlns:xmpp="http://www.springframework.org/schema/integration/xmpp"
|
||||
xmlns:tool="http://www.springframework.org/schema/tool" xmlns:lang="http://www.springframework.org/schema/lang"
|
||||
xmlns:console="http://www.springframework.org/schema/integration/stream"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration-1.0.xsd
|
||||
http://www.springframework.org/schema/tool http://www.springframework.org/schema/tool/spring-tool-3.0.xsd
|
||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/integration/xmpp http://www.springframework.org/schema/integration/xmpp/spring-integration-xmpp.xsd
|
||||
@@ -26,43 +26,41 @@
|
||||
http://www.springframework.org/schema/integration/stream http://www.springframework.org/schema/integration/stream/spring-integration-stream.xsd">
|
||||
|
||||
|
||||
<beans:bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" p:ignoreUnresolvablePlaceholders="false">
|
||||
<beans:property name="location">
|
||||
<beans:bean class="org.springframework.core.io.FileSystemResource">
|
||||
<beans:constructor-arg value="#{ systemProperties['user.home'] }/Desktop/test.properties"/>
|
||||
</beans:bean>
|
||||
</beans:property>
|
||||
</beans:bean>
|
||||
|
||||
<xmpp:xmpp-connection
|
||||
id="testConnection"
|
||||
user="${user.2.login}"
|
||||
password="${user.2.password}"
|
||||
host="${user.2.host}"
|
||||
port="${user.2.port}"
|
||||
resource="${user.2.resource}"
|
||||
sasl-mechanism-supported="${user.2.sasl.mechanism}"
|
||||
sasl-mechanism-supported-index="${user.2.sasl.index}"
|
||||
service-name="${user.2.service}"
|
||||
/>
|
||||
|
||||
<beans:bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" p:ignoreUnresolvablePlaceholders="false">
|
||||
<beans:property name="location">
|
||||
<beans:bean class="org.springframework.core.io.FileSystemResource">
|
||||
<beans:constructor-arg value="#{ systemProperties['user.home'] }/Desktop/test.properties"/>
|
||||
</beans:bean>
|
||||
</beans:property>
|
||||
</beans:bean>
|
||||
<console:stdout-channel-adapter id="stdout" append-newline="true"/>
|
||||
<console:stdin-channel-adapter id="stdin"/>
|
||||
|
||||
<xmpp:xmpp-connection
|
||||
id="testConnection"
|
||||
user="${user.2.login}"
|
||||
password="${user.2.password}"
|
||||
host="${user.2.host}"
|
||||
port="${user.2.port}"
|
||||
resource="${user.2.resource}"
|
||||
sasl-mechanism-supported="${user.2.sasl.mechanism}"
|
||||
sasl-mechanism-supported-index="${user.2.sasl.index}"
|
||||
service-name="${user.2.service}"
|
||||
/>
|
||||
<header-enricher input-channel="stdin" output-channel="messagesToSend">
|
||||
<header name="#{T(org.springframework.integration.xmpp.XmppHeaders).CHAT_TO_USER}" value="${user.1.login}"/>
|
||||
</header-enricher>
|
||||
|
||||
<console:stdout-channel-adapter id="stdout" append-newline="true"/>
|
||||
<console:stdin-channel-adapter id="stdin"/>
|
||||
|
||||
<header-enricher input-channel="stdin" output-channel="messagesToSend">
|
||||
<header name="#{T(org.springframework.integration.xmpp.XmppHeaders).CHAT_TO_USER}" value="${user.1.login}"/>
|
||||
</header-enricher>
|
||||
|
||||
<xmpp:message-inbound-channel-adapter channel="stdout" xmpp-connection="testConnection"/>
|
||||
<xmpp:message-inbound-channel-adapter channel="stdout" xmpp-connection="testConnection"/>
|
||||
|
||||
<channel id="messagesToSend"/>
|
||||
|
||||
|
||||
<xmpp:message-outbound-channel-adapter channel="messagesToSend" xmpp-connection="testConnection"/>
|
||||
|
||||
<poller default="true">
|
||||
<interval-trigger interval="1" time-unit="SECONDS" />
|
||||
<interval-trigger interval="1" time-unit="SECONDS"/>
|
||||
</poller>
|
||||
|
||||
|
||||
|
||||
@@ -15,16 +15,16 @@
|
||||
~ limitations under the License.
|
||||
-->
|
||||
<beans:beans
|
||||
xmlns="http://www.springframework.org/schema/integration"
|
||||
xmlns:beans="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:p="http://www.springframework.org/schema/p"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xmlns:util="http://www.springframework.org/schema/util"
|
||||
xmlns:xmpp="http://www.springframework.org/schema/integration/xmpp"
|
||||
xmlns:tool="http://www.springframework.org/schema/tool"
|
||||
xmlns:lang="http://www.springframework.org/schema/lang"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/integration/xmpp
|
||||
xmlns="http://www.springframework.org/schema/integration"
|
||||
xmlns:beans="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:p="http://www.springframework.org/schema/p"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xmlns:util="http://www.springframework.org/schema/util"
|
||||
xmlns:xmpp="http://www.springframework.org/schema/integration/xmpp"
|
||||
xmlns:tool="http://www.springframework.org/schema/tool"
|
||||
xmlns:lang="http://www.springframework.org/schema/lang"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/integration/xmpp
|
||||
http://www.springframework.org/schema/integration/xmpp/spring-integration-xmpp.xsd
|
||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
|
||||
@@ -33,26 +33,26 @@
|
||||
http://www.springframework.org/schema/tool http://www.springframework.org/schema/tool/spring-tool-3.0.xsd
|
||||
http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-3.0.xsd">
|
||||
|
||||
<context:component-scan base-package="org.springframework.integration.xmpp"/>
|
||||
<context:component-scan base-package="org.springframework.integration.xmpp"/>
|
||||
|
||||
<context:property-placeholder location="#{ systemProperties['user.home'] }/Desktop/test.properties"/>
|
||||
<context:property-placeholder location="#{ systemProperties['user.home'] }/Desktop/test.properties"/>
|
||||
|
||||
<channel id="xmppInbound"/>
|
||||
<channel id="xmppInbound"/>
|
||||
|
||||
<xmpp:xmpp-connection
|
||||
id="testConnection"
|
||||
user="${user.2.login}"
|
||||
password="${user.2.password}"
|
||||
host="${user.2.host}"
|
||||
port="${user.2.port}"
|
||||
resource="${user.2.resource}"
|
||||
sasl-mechanism-supported="${user.2.sasl.mechanism}"
|
||||
sasl-mechanism-supported-index="${user.2.sasl.index}"
|
||||
service-name="${user.2.service}"
|
||||
/>
|
||||
<xmpp:xmpp-connection
|
||||
id="testConnection"
|
||||
user="${user.2.login}"
|
||||
password="${user.2.password}"
|
||||
host="${user.2.host}"
|
||||
port="${user.2.port}"
|
||||
resource="${user.2.resource}"
|
||||
sasl-mechanism-supported="${user.2.sasl.mechanism}"
|
||||
sasl-mechanism-supported-index="${user.2.sasl.index}"
|
||||
service-name="${user.2.service}"
|
||||
/>
|
||||
|
||||
<xmpp:message-inbound-channel-adapter channel="xmppInbound" xmpp-connection="testConnection"/>
|
||||
<xmpp:message-inbound-channel-adapter channel="xmppInbound" xmpp-connection="testConnection"/>
|
||||
|
||||
<service-activator input-channel="xmppInbound" ref="xmppMessageConsumer"/>
|
||||
<service-activator input-channel="xmppInbound" ref="xmppMessageConsumer"/>
|
||||
|
||||
</beans:beans>
|
||||
|
||||
@@ -12,11 +12,11 @@
|
||||
-->
|
||||
|
||||
<beans:beans xmlns="http://www.springframework.org/schema/integration"
|
||||
xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context"
|
||||
xmlns:util="http://www.springframework.org/schema/util" xmlns:xmpp="http://www.springframework.org/schema/integration/xmpp"
|
||||
xmlns:tool="http://www.springframework.org/schema/tool" xmlns:lang="http://www.springframework.org/schema/lang"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/integration/xmpp http://www.springframework.org/schema/integration/xmpp/spring-integration-xmpp.xsd
|
||||
xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context"
|
||||
xmlns:util="http://www.springframework.org/schema/util" xmlns:xmpp="http://www.springframework.org/schema/integration/xmpp"
|
||||
xmlns:tool="http://www.springframework.org/schema/tool" xmlns:lang="http://www.springframework.org/schema/lang"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/integration/xmpp http://www.springframework.org/schema/integration/xmpp/spring-integration-xmpp.xsd
|
||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
|
||||
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
|
||||
@@ -24,33 +24,33 @@
|
||||
http://www.springframework.org/schema/tool http://www.springframework.org/schema/tool/spring-tool-3.0.xsd
|
||||
http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-3.0.xsd">
|
||||
|
||||
<context:component-scan base-package="org.springframework.integration.xmpp"/>
|
||||
<context:component-scan base-package="org.springframework.integration.xmpp"/>
|
||||
|
||||
<context:property-placeholder location="file://${user.home}/Desktop/test.properties" ignore-unresolvable="true"/>
|
||||
<context:property-placeholder location="file://${user.home}/Desktop/test.properties" ignore-unresolvable="true"/>
|
||||
|
||||
<beans:bean id="xmppProducer" class="org.springframework.integration.xmpp.messages.XmppMessageProducer" p:recipient="${user.2.login}"/>
|
||||
<beans:bean id="xmppProducer" class="org.springframework.integration.xmpp.messages.XmppMessageProducer" p:recipient="${user.2.login}"/>
|
||||
|
||||
<poller default="true">
|
||||
<interval-trigger fixed-rate="true" interval="10" time-unit="SECONDS"/>
|
||||
</poller>
|
||||
<poller default="true">
|
||||
<interval-trigger fixed-rate="true" interval="10" time-unit="SECONDS"/>
|
||||
</poller>
|
||||
|
||||
<xmpp:xmpp-connection
|
||||
id="testConnection"
|
||||
user="${user.1.login}"
|
||||
password="${user.1.password}"
|
||||
host="${user.1.host}"
|
||||
port="${user.1.port}"
|
||||
resource="${user.1.resource}"
|
||||
sasl-mechanism-supported="${user.1.sasl.mechanism}"
|
||||
sasl-mechanism-supported-index="${user.1.sasl.index}"
|
||||
service-name="${user.1.service}"
|
||||
/>
|
||||
<xmpp:xmpp-connection
|
||||
id="testConnection"
|
||||
user="${user.1.login}"
|
||||
password="${user.1.password}"
|
||||
host="${user.1.host}"
|
||||
port="${user.1.port}"
|
||||
resource="${user.1.resource}"
|
||||
sasl-mechanism-supported="${user.1.sasl.mechanism}"
|
||||
sasl-mechanism-supported-index="${user.1.sasl.index}"
|
||||
service-name="${user.1.service}"
|
||||
/>
|
||||
|
||||
|
||||
<inbound-channel-adapter ref="xmppProducer" channel="outboundChannel"/>
|
||||
<inbound-channel-adapter ref="xmppProducer" channel="outboundChannel"/>
|
||||
|
||||
<channel id="outboundChannel"/>
|
||||
<channel id="outboundChannel"/>
|
||||
|
||||
<xmpp:message-outbound-channel-adapter channel="outboundChannel" xmpp-connection="testConnection"/>
|
||||
<xmpp:message-outbound-channel-adapter channel="outboundChannel" xmpp-connection="testConnection"/>
|
||||
|
||||
</beans:beans>
|
||||
|
||||
@@ -11,12 +11,12 @@
|
||||
permissions and ~ limitations under the License.
|
||||
-->
|
||||
<beans:beans xmlns="http://www.springframework.org/schema/integration"
|
||||
xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context"
|
||||
xmlns:util="http://www.springframework.org/schema/util" xmlns:xmpp="http://www.springframework.org/schema/integration/xmpp"
|
||||
xmlns:tool="http://www.springframework.org/schema/tool" xmlns:lang="http://www.springframework.org/schema/lang"
|
||||
xmlns:console="http://www.springframework.org/schema/integration/stream"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration-1.0.xsd
|
||||
xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context"
|
||||
xmlns:util="http://www.springframework.org/schema/util" xmlns:xmpp="http://www.springframework.org/schema/integration/xmpp"
|
||||
xmlns:tool="http://www.springframework.org/schema/tool" xmlns:lang="http://www.springframework.org/schema/lang"
|
||||
xmlns:console="http://www.springframework.org/schema/integration/stream"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration-1.0.xsd
|
||||
http://www.springframework.org/schema/tool http://www.springframework.org/schema/tool/spring-tool-3.0.xsd
|
||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/integration/xmpp http://www.springframework.org/schema/integration/xmpp/spring-integration-xmpp.xsd
|
||||
@@ -26,32 +26,32 @@
|
||||
http://www.springframework.org/schema/integration/stream http://www.springframework.org/schema/integration/stream/spring-integration-stream.xsd">
|
||||
|
||||
|
||||
<beans:bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" p:ignoreUnresolvablePlaceholders="false">
|
||||
<beans:property name="location">
|
||||
<beans:bean class="org.springframework.core.io.FileSystemResource">
|
||||
<beans:constructor-arg value="#{ systemProperties['user.home'] }/Desktop/test.properties"/>
|
||||
</beans:bean>
|
||||
</beans:property>
|
||||
</beans:bean>
|
||||
<beans:bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" p:ignoreUnresolvablePlaceholders="false">
|
||||
<beans:property name="location">
|
||||
<beans:bean class="org.springframework.core.io.FileSystemResource">
|
||||
<beans:constructor-arg value="#{ systemProperties['user.home'] }/Desktop/test.properties"/>
|
||||
</beans:bean>
|
||||
</beans:property>
|
||||
</beans:bean>
|
||||
|
||||
<beans:bean id="xmppRosterEventConsumer" class="org.springframework.integration.xmpp.presence.XmppRosterEventConsumer" />
|
||||
<beans:bean id="xmppRosterEventConsumer" class="org.springframework.integration.xmpp.presence.XmppRosterEventConsumer"/>
|
||||
|
||||
<xmpp:xmpp-connection
|
||||
id="testConnection"
|
||||
user="${user.1.login}"
|
||||
password="${user.1.password}"
|
||||
host="${user.1.host}"
|
||||
port="${user.1.port}"
|
||||
resource="${user.1.resource}"
|
||||
sasl-mechanism-supported="${user.1.sasl.mechanism}"
|
||||
sasl-mechanism-supported-index="${user.1.sasl.index}"
|
||||
service-name="${user.1.service}"
|
||||
/>
|
||||
<xmpp:xmpp-connection
|
||||
id="testConnection"
|
||||
user="${user.1.login}"
|
||||
password="${user.1.password}"
|
||||
host="${user.1.host}"
|
||||
port="${user.1.port}"
|
||||
resource="${user.1.resource}"
|
||||
sasl-mechanism-supported="${user.1.sasl.mechanism}"
|
||||
sasl-mechanism-supported-index="${user.1.sasl.index}"
|
||||
service-name="${user.1.service}"
|
||||
/>
|
||||
|
||||
<channel id="inboundRosterEventChannel"/>
|
||||
<channel id="inboundRosterEventChannel"/>
|
||||
|
||||
<xmpp:roster-event-inbound-channel-adapter channel="inboundRosterEventChannel" xmpp-connection="testConnection"/>
|
||||
<xmpp:roster-event-inbound-channel-adapter channel="inboundRosterEventChannel" xmpp-connection="testConnection"/>
|
||||
|
||||
<service-activator input-channel="inboundRosterEventChannel" ref="xmppRosterEventConsumer"/>
|
||||
<service-activator input-channel="inboundRosterEventChannel" ref="xmppRosterEventConsumer"/>
|
||||
|
||||
</beans:beans>
|
||||
|
||||
@@ -11,12 +11,12 @@
|
||||
permissions and ~ limitations under the License.
|
||||
-->
|
||||
<beans:beans xmlns="http://www.springframework.org/schema/integration"
|
||||
xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context"
|
||||
xmlns:util="http://www.springframework.org/schema/util" xmlns:xmpp="http://www.springframework.org/schema/integration/xmpp"
|
||||
xmlns:tool="http://www.springframework.org/schema/tool" xmlns:lang="http://www.springframework.org/schema/lang"
|
||||
xmlns:console="http://www.springframework.org/schema/integration/stream"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration-1.0.xsd
|
||||
xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context"
|
||||
xmlns:util="http://www.springframework.org/schema/util" xmlns:xmpp="http://www.springframework.org/schema/integration/xmpp"
|
||||
xmlns:tool="http://www.springframework.org/schema/tool" xmlns:lang="http://www.springframework.org/schema/lang"
|
||||
xmlns:console="http://www.springframework.org/schema/integration/stream"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration-1.0.xsd
|
||||
http://www.springframework.org/schema/tool http://www.springframework.org/schema/tool/spring-tool-3.0.xsd
|
||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/integration/xmpp http://www.springframework.org/schema/integration/xmpp/spring-integration-xmpp.xsd
|
||||
@@ -26,39 +26,38 @@
|
||||
http://www.springframework.org/schema/integration/stream http://www.springframework.org/schema/integration/stream/spring-integration-stream.xsd">
|
||||
|
||||
|
||||
<beans:bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" p:ignoreUnresolvablePlaceholders="false">
|
||||
<beans:property name="location">
|
||||
<beans:bean class="org.springframework.core.io.FileSystemResource">
|
||||
<beans:constructor-arg value="#{ systemProperties['user.home'] }/Desktop/test.properties"/>
|
||||
</beans:bean>
|
||||
</beans:property>
|
||||
</beans:bean>
|
||||
<beans:bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" p:ignoreUnresolvablePlaceholders="false">
|
||||
<beans:property name="location">
|
||||
<beans:bean class="org.springframework.core.io.FileSystemResource">
|
||||
<beans:constructor-arg value="#{ systemProperties['user.home'] }/Desktop/test.properties"/>
|
||||
</beans:bean>
|
||||
</beans:property>
|
||||
</beans:bean>
|
||||
|
||||
|
||||
|
||||
<xmpp:xmpp-connection
|
||||
id="testConnection"
|
||||
user="${user.1.login}"
|
||||
password="${user.1.password}"
|
||||
host="${user.1.host}"
|
||||
port="${user.1.port}"
|
||||
resource="${user.1.resource}"
|
||||
sasl-mechanism-supported="${user.1.sasl.mechanism}"
|
||||
sasl-mechanism-supported-index="${user.1.sasl.index}"
|
||||
service-name="${user.1.service}"
|
||||
/>
|
||||
<xmpp:xmpp-connection
|
||||
id="testConnection"
|
||||
user="${user.1.login}"
|
||||
password="${user.1.password}"
|
||||
host="${user.1.host}"
|
||||
port="${user.1.port}"
|
||||
resource="${user.1.resource}"
|
||||
sasl-mechanism-supported="${user.1.sasl.mechanism}"
|
||||
sasl-mechanism-supported-index="${user.1.sasl.index}"
|
||||
service-name="${user.1.service}"
|
||||
/>
|
||||
|
||||
|
||||
<beans:bean id="eventProducer" class="org.springframework.integration.xmpp.presence.XmppRosterEventProducer" />
|
||||
<beans:bean id="eventProducer" class="org.springframework.integration.xmpp.presence.XmppRosterEventProducer"/>
|
||||
|
||||
<inbound-channel-adapter ref="eventProducer" channel="rosterPresenceUpdatingProducerChannel">
|
||||
<poller>
|
||||
<interval-trigger interval="10000" />
|
||||
</poller>
|
||||
</inbound-channel-adapter>
|
||||
<inbound-channel-adapter ref="eventProducer" channel="rosterPresenceUpdatingProducerChannel">
|
||||
<poller>
|
||||
<interval-trigger interval="10000"/>
|
||||
</poller>
|
||||
</inbound-channel-adapter>
|
||||
|
||||
<channel id="rosterPresenceUpdatingProducerChannel"/>
|
||||
<channel id="rosterPresenceUpdatingProducerChannel"/>
|
||||
|
||||
<xmpp:roster-event-outbound-channel-adapter xmpp-connection="testConnection" channel="rosterPresenceUpdatingProducerChannel"/>
|
||||
<xmpp:roster-event-outbound-channel-adapter xmpp-connection="testConnection" channel="rosterPresenceUpdatingProducerChannel"/>
|
||||
|
||||
</beans:beans>
|
||||
|
||||
Reference in New Issue
Block a user