diff --git a/spring-integration-xmpp/pom.xml b/spring-integration-xmpp/pom.xml index 75c1a1b978..7f1ea77224 100644 --- a/spring-integration-xmpp/pom.xml +++ b/spring-integration-xmpp/pom.xml @@ -1,98 +1,98 @@ - 4.0.0 - - org.springframework.integration - spring-integration-parent - 2.0.0.BUILD-SNAPSHOT - - spring-integration-xmpp - jar - Spring Integration XMPP Support - - - jivesoftware - smack - 3.1.0 - - - jivesoftware - smackx - 3.1.0 - - - javax.activation - activation - 1.1.1 - true - - - cglib - cglib-nodep - ${cglib.version} - test - - - org.easymock - easymock - ${org.easymock.version} - test - - - org.easymock - easymockclassextension - ${org.easymock.version} - test - - - junit - junit - ${junit.version} - test - - - org.springframework - spring-context-support - ${org.springframework.version} - compile - - - org.springframework - spring-test - ${org.springframework.version} - test - - - org.springframework.integration - spring-integration-stream - ${project.version} - compile - - - org.springframework.integration - spring-integration-core - ${project.version} - compile - - - commons-lang - commons-lang - 2.5 - - - commons-io - commons-io - 1.4 - - - - - - com.springsource.bundlor - com.springsource.bundlor.maven - - - + 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"> + 4.0.0 + + org.springframework.integration + spring-integration-parent + 2.0.0.BUILD-SNAPSHOT + + spring-integration-xmpp + jar + Spring Integration XMPP Support + + + jivesoftware + smack + 3.1.0 + + + jivesoftware + smackx + 3.1.0 + + + javax.activation + activation + 1.1.1 + true + + + cglib + cglib-nodep + ${cglib.version} + test + + + org.easymock + easymock + ${org.easymock.version} + test + + + org.easymock + easymockclassextension + ${org.easymock.version} + test + + + junit + junit + ${junit.version} + test + + + org.springframework + spring-context-support + ${org.springframework.version} + compile + + + org.springframework + spring-test + ${org.springframework.version} + test + + + org.springframework.integration + spring-integration-stream + ${project.version} + compile + + + org.springframework.integration + spring-integration-core + ${project.version} + compile + + + commons-lang + commons-lang + 2.5 + + + commons-io + commons-io + 1.4 + + + + + + com.springsource.bundlor + com.springsource.bundlor.maven + + + diff --git a/spring-integration-xmpp/src/main/java/org/springframework/integration/xmpp/XmppConnectionFactory.java b/spring-integration-xmpp/src/main/java/org/springframework/integration/xmpp/XmppConnectionFactory.java index 3aa3149828..cb2364bbb4 100644 --- a/spring-integration-xmpp/src/main/java/org/springframework/integration/xmpp/XmppConnectionFactory.java +++ b/spring-integration-xmpp/src/main/java/org/springframework/integration/xmpp/XmppConnectionFactory.java @@ -33,173 +33,172 @@ import org.springframework.util.StringUtils; * @since 2.0 */ public class XmppConnectionFactory extends AbstractFactoryBean { - // 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 getObjectType() { - return XMPPConnection.class; - } + @Override + public Class 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()); + } } diff --git a/spring-integration-xmpp/src/main/java/org/springframework/integration/xmpp/XmppHeaders.java b/spring-integration-xmpp/src/main/java/org/springframework/integration/xmpp/XmppHeaders.java index cc8fb0fcb9..65e427f480 100644 --- a/spring-integration-xmpp/src/main/java/org/springframework/integration/xmpp/XmppHeaders.java +++ b/spring-integration-xmpp/src/main/java/org/springframework/integration/xmpp/XmppHeaders.java @@ -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"; + - } diff --git a/spring-integration-xmpp/src/main/java/org/springframework/integration/xmpp/config/XmppNamespaceHandler.java b/spring-integration-xmpp/src/main/java/org/springframework/integration/xmpp/config/XmppNamespaceHandler.java index 7600ba3df3..1c68347154 100644 --- a/spring-integration-xmpp/src/main/java/org/springframework/integration/xmpp/config/XmppNamespaceHandler.java +++ b/spring-integration-xmpp/src/main/java/org/springframework/integration/xmpp/config/XmppNamespaceHandler.java @@ -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); + } + } } diff --git a/spring-integration-xmpp/src/main/java/org/springframework/integration/xmpp/messages/XmppMessageDrivenEndpoint.java b/spring-integration-xmpp/src/main/java/org/springframework/integration/xmpp/messages/XmppMessageDrivenEndpoint.java index d4926bbec1..c138f62259 100644 --- a/spring-integration-xmpp/src/main/java/org/springframework/integration/xmpp/messages/XmppMessageDrivenEndpoint.java +++ b/spring-integration-xmpp/src/main/java/org/springframework/integration/xmpp/messages/XmppMessageDrivenEndpoint.java @@ -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. - *

+ *

* Note: 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 xmpp-connection-factory element. - * - * @param xmppConnection the connection - */ + /** + * This will be injected or configured via a xmpp-connection-factory 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 diff --git a/spring-integration-xmpp/src/main/java/org/springframework/integration/xmpp/messages/XmppMessageSendingMessageHandler.java b/spring-integration-xmpp/src/main/java/org/springframework/integration/xmpp/messages/XmppMessageSendingMessageHandler.java index 6540bd4520..74f51f438c 100644 --- a/spring-integration-xmpp/src/main/java/org/springframework/integration/xmpp/messages/XmppMessageSendingMessageHandler.java +++ b/spring-integration-xmpp/src/main/java/org/springframework/integration/xmpp/messages/XmppMessageSendingMessageHandler.java @@ -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); diff --git a/spring-integration-xmpp/src/main/java/org/springframework/integration/xmpp/presence/XmppPresenceMessageMapper.java b/spring-integration-xmpp/src/main/java/org/springframework/integration/xmpp/presence/XmppPresenceMessageMapper.java index 159bbd2e55..ba5fdb020a 100644 --- a/spring-integration-xmpp/src/main/java/org/springframework/integration/xmpp/presence/XmppPresenceMessageMapper.java +++ b/spring-integration-xmpp/src/main/java/org/springframework/integration/xmpp/presence/XmppPresenceMessageMapper.java @@ -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, - InboundMessageMapper { - - private static final Log logger = LogFactory.getLog(XmppPresenceMessageMapper.class); + InboundMessageMapper { - /** - * 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; + } } diff --git a/spring-integration-xmpp/src/main/java/org/springframework/integration/xmpp/presence/XmppRosterEventMessageDrivenEndpoint.java b/spring-integration-xmpp/src/main/java/org/springframework/integration/xmpp/presence/XmppRosterEventMessageDrivenEndpoint.java index de1af7309d..0bc458fbef 100644 --- a/spring-integration-xmpp/src/main/java/org/springframework/integration/xmpp/presence/XmppRosterEventMessageDrivenEndpoint.java +++ b/spring-integration-xmpp/src/main/java/org/springframework/integration/xmpp/presence/XmppRosterEventMessageDrivenEndpoint.java @@ -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 messageMapper; + private InboundMessageMapper messageMapper; - private final MessagingTemplate messagingTemplate = new MessagingTemplate(); + private final MessagingTemplate messagingTemplate = new MessagingTemplate(); - /** - * This will be injected or configured via a xmpp-connection-factory element. - * - * @param xmppConnection the connection - */ - public void setXmppConnection(final XMPPConnection xmppConnection) { - this.xmppConnection = xmppConnection; - } + /** + * This will be injected or configured via a xmpp-connection-factory 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 messageMapper) { - this.messageMapper = messageMapper; - } + public void setMessageMapper(InboundMessageMapper 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 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 entries) { + logger.debug("entries added: " + StringUtils.join(entries.iterator(), ",")); + } - public void entriesUpdated(final Collection entries) { - logger.debug("entries updated: " + StringUtils.join(entries.iterator(), ",")); - } + public void entriesUpdated(final Collection entries) { + logger.debug("entries updated: " + StringUtils.join(entries.iterator(), ",")); + } - public void entriesDeleted(final Collection entries) { - logger.debug("entries deleted: " + StringUtils.join(entries.iterator(), ",")); - } + public void entriesDeleted(final Collection 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); - } - } - } diff --git a/spring-integration-xmpp/src/main/java/org/springframework/integration/xmpp/presence/XmppRosterEventMessageSendingHandler.java b/spring-integration-xmpp/src/main/java/org/springframework/integration/xmpp/presence/XmppRosterEventMessageSendingHandler.java index 3f33f34bfd..b18428762d 100644 --- a/spring-integration-xmpp/src/main/java/org/springframework/integration/xmpp/presence/XmppRosterEventMessageSendingHandler.java +++ b/spring-integration-xmpp/src/main/java/org/springframework/integration/xmpp/presence/XmppRosterEventMessageSendingHandler.java @@ -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 messageMapper) { diff --git a/spring-integration-xmpp/src/main/resources/org/springframework/integration/xmpp/config/spring-integration-xmpp-2.0.xsd b/spring-integration-xmpp/src/main/resources/org/springframework/integration/xmpp/config/spring-integration-xmpp-2.0.xsd index 6d246ffc50..add6e22bf9 100644 --- a/spring-integration-xmpp/src/main/resources/org/springframework/integration/xmpp/config/spring-integration-xmpp-2.0.xsd +++ b/spring-integration-xmpp/src/main/resources/org/springframework/integration/xmpp/config/spring-integration-xmpp-2.0.xsd @@ -15,203 +15,202 @@ ~ limitations under the License. --> + 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"> - + + schemaLocation="http://www.springframework.org/schema/integration/spring-integration-2.0.xsd"/> - - - - Configures an XMPP connection that can in turn be referenced by other components - - - - - - - - - - - - - - - + + + Configures an XMPP connection that can in turn be referenced by other components + + + + + + + + + + + + + + + - - - - - - - - - + + + + + + + + + - - + + - - - - Configures an endpoint that will publish an updated {@link org.jivesoftware.smack.packet.Presence} state on your {@link XMPPConnection } object. - - - - - - - - - - - - - - - - - - - - - - - - + + + + Configures an endpoint that will publish an updated {@link org.jivesoftware.smack.packet.Presence} state on your {@link XMPPConnection } object. + + + + + + + + + + + + + + + + + + + + + + + + - - - -Configures an endpoint that will forward roster based events (entry managment and presence state changes) to components in the bus. - - - - - - - - - - - - - - - - - - - - - - - - + + + + Configures an endpoint that will forward roster based events (entry managment and presence state changes) to components in the bus. + + + + + + + + + + + + + + + + + + + + + + + + - - - -Configures an endpoint that will receive messages sent to a given account and then forward those messages to components in the bus. - - - - - - - - - - - - - - - - - - - - - - - - + + + + Configures an endpoint that will receive messages sent to a given account and then forward those messages to components in the bus. + + + + + + + + + + + + + + + + + + + + + + + + - - - -Component that sends messages to an entry in the roster on behalf of components in the bus. - - - - - - - - - - - - - - - - - - - - - - - - + + + + Component that sends messages to an entry in the roster on behalf of components in the bus. + + + + + + + + + + + + + + + + + + + + + + + + - Defines a Transformer for adding XMPP headers. + Defines a Transformer for adding XMPP headers. - - - - - - - + + + + + + - 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. - + @@ -219,13 +218,13 @@ Component that sends messages to an entry in the roster on behalf of components - - - + + + - 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. diff --git a/spring-integration-xmpp/src/test/java/org/springframework/integration/xmpp/config/XmppHeaderEnricherParserTests.java b/spring-integration-xmpp/src/test/java/org/springframework/integration/xmpp/config/XmppHeaderEnricherParserTests.java index 629d44cf08..6c8bec311e 100644 --- a/spring-integration-xmpp/src/test/java/org/springframework/integration/xmpp/config/XmppHeaderEnricherParserTests.java +++ b/spring-integration-xmpp/src/test/java/org/springframework/integration/xmpp/config/XmppHeaderEnricherParserTests.java @@ -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()); + } } diff --git a/spring-integration-xmpp/src/test/java/org/springframework/integration/xmpp/messages/ConsoleChatTests.java b/spring-integration-xmpp/src/test/java/org/springframework/integration/xmpp/messages/ConsoleChatTests.java index e8acd276d4..643e82aaf3 100644 --- a/spring-integration-xmpp/src/test/java/org/springframework/integration/xmpp/messages/ConsoleChatTests.java +++ b/spring-integration-xmpp/src/test/java/org/springframework/integration/xmpp/messages/ConsoleChatTests.java @@ -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); } } diff --git a/spring-integration-xmpp/src/test/java/org/springframework/integration/xmpp/messages/InboundXmppEndpointTests.java b/spring-integration-xmpp/src/test/java/org/springframework/integration/xmpp/messages/InboundXmppEndpointTests.java index 867a0fa9b6..4867a56ff5 100644 --- a/spring-integration-xmpp/src/test/java/org/springframework/integration/xmpp/messages/InboundXmppEndpointTests.java +++ b/spring-integration-xmpp/src/test/java/org/springframework/integration/xmpp/messages/InboundXmppEndpointTests.java @@ -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); } } diff --git a/spring-integration-xmpp/src/test/java/org/springframework/integration/xmpp/messages/OutboundXmppEndpointTests.java b/spring-integration-xmpp/src/test/java/org/springframework/integration/xmpp/messages/OutboundXmppEndpointTests.java index 6bde271c88..1b9e094517 100644 --- a/spring-integration-xmpp/src/test/java/org/springframework/integration/xmpp/messages/OutboundXmppEndpointTests.java +++ b/spring-integration-xmpp/src/test/java/org/springframework/integration/xmpp/messages/OutboundXmppEndpointTests.java @@ -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); } } diff --git a/spring-integration-xmpp/src/test/java/org/springframework/integration/xmpp/messages/XmppMessageConsumer.java b/spring-integration-xmpp/src/test/java/org/springframework/integration/xmpp/messages/XmppMessageConsumer.java index d2a59d9ac8..2f44267563 100644 --- a/spring-integration-xmpp/src/test/java/org/springframework/integration/xmpp/messages/XmppMessageConsumer.java +++ b/spring-integration-xmpp/src/test/java/org/springframework/integration/xmpp/messages/XmppMessageConsumer.java @@ -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); - } + } } diff --git a/spring-integration-xmpp/src/test/java/org/springframework/integration/xmpp/messages/XmppMessageProducer.java b/spring-integration-xmpp/src/test/java/org/springframework/integration/xmpp/messages/XmppMessageProducer.java index d4a16e340a..75873f59cc 100644 --- a/spring-integration-xmpp/src/test/java/org/springframework/integration/xmpp/messages/XmppMessageProducer.java +++ b/spring-integration-xmpp/src/test/java/org/springframework/integration/xmpp/messages/XmppMessageProducer.java @@ -36,13 +36,13 @@ public class XmppMessageProducer implements MessageSource { 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 receive() { + public Message receive() { try { if (counter > 10) { logger.debug("return null"); @@ -51,10 +51,10 @@ public class XmppMessageProducer implements MessageSource { 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) { diff --git a/spring-integration-xmpp/src/test/java/org/springframework/integration/xmpp/presence/InboundXmppRosterEventsEndpointTests.java b/spring-integration-xmpp/src/test/java/org/springframework/integration/xmpp/presence/InboundXmppRosterEventsEndpointTests.java index 18a27bd2e1..02f4e5db4f 100644 --- a/spring-integration-xmpp/src/test/java/org/springframework/integration/xmpp/presence/InboundXmppRosterEventsEndpointTests.java +++ b/spring-integration-xmpp/src/test/java/org/springframework/integration/xmpp/presence/InboundXmppRosterEventsEndpointTests.java @@ -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); } } diff --git a/spring-integration-xmpp/src/test/java/org/springframework/integration/xmpp/presence/OutboundXmppRosterEventsEndpointTests.java b/spring-integration-xmpp/src/test/java/org/springframework/integration/xmpp/presence/OutboundXmppRosterEventsEndpointTests.java index 4c8c818e09..61c5fe3a10 100644 --- a/spring-integration-xmpp/src/test/java/org/springframework/integration/xmpp/presence/OutboundXmppRosterEventsEndpointTests.java +++ b/spring-integration-xmpp/src/test/java/org/springframework/integration/xmpp/presence/OutboundXmppRosterEventsEndpointTests.java @@ -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); + } } diff --git a/spring-integration-xmpp/src/test/java/org/springframework/integration/xmpp/presence/PresenceMessageComboTests.java b/spring-integration-xmpp/src/test/java/org/springframework/integration/xmpp/presence/PresenceMessageComboTests.java index 955e969d38..9547a8ca33 100644 --- a/spring-integration-xmpp/src/test/java/org/springframework/integration/xmpp/presence/PresenceMessageComboTests.java +++ b/spring-integration-xmpp/src/test/java/org/springframework/integration/xmpp/presence/PresenceMessageComboTests.java @@ -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: *

* * @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); + } } diff --git a/spring-integration-xmpp/src/test/java/org/springframework/integration/xmpp/presence/XmppRosterEventConsumer.java b/spring-integration-xmpp/src/test/java/org/springframework/integration/xmpp/presence/XmppRosterEventConsumer.java index c84fc188a1..f75da61f3f 100644 --- a/spring-integration-xmpp/src/test/java/org/springframework/integration/xmpp/presence/XmppRosterEventConsumer.java +++ b/spring-integration-xmpp/src/test/java/org/springframework/integration/xmpp/presence/XmppRosterEventConsumer.java @@ -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 */ diff --git a/spring-integration-xmpp/src/test/java/org/springframework/integration/xmpp/presence/XmppRosterEventProducer.java b/spring-integration-xmpp/src/test/java/org/springframework/integration/xmpp/presence/XmppRosterEventProducer.java index bf89ec6876..075285ef1c 100644 --- a/spring-integration-xmpp/src/test/java/org/springframework/integration/xmpp/presence/XmppRosterEventProducer.java +++ b/spring-integration-xmpp/src/test/java/org/springframework/integration/xmpp/presence/XmppRosterEventProducer.java @@ -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 { 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(); } } diff --git a/spring-integration-xmpp/src/test/resources/org/springframework/integration/xmpp/config/XmppHeaderEnricherParserTests-context.xml b/spring-integration-xmpp/src/test/resources/org/springframework/integration/xmpp/config/XmppHeaderEnricherParserTests-context.xml index e23f2ccb07..2ea13eccec 100644 --- a/spring-integration-xmpp/src/test/resources/org/springframework/integration/xmpp/config/XmppHeaderEnricherParserTests-context.xml +++ b/spring-integration-xmpp/src/test/resources/org/springframework/integration/xmpp/config/XmppHeaderEnricherParserTests-context.xml @@ -15,29 +15,29 @@ ~ limitations under the License. --> - - + + - - - - - - + + + + + + diff --git a/spring-integration-xmpp/src/test/resources/org/springframework/integration/xmpp/messages/ConsoleChatTests-context.xml b/spring-integration-xmpp/src/test/resources/org/springframework/integration/xmpp/messages/ConsoleChatTests-context.xml index 84da3ba91d..593fc92634 100644 --- a/spring-integration-xmpp/src/test/resources/org/springframework/integration/xmpp/messages/ConsoleChatTests-context.xml +++ b/spring-integration-xmpp/src/test/resources/org/springframework/integration/xmpp/messages/ConsoleChatTests-context.xml @@ -1,22 +1,22 @@ - + + + + + + + + + - - - - - - - + + - + +
+ - - - - -
- - - + - + - + diff --git a/spring-integration-xmpp/src/test/resources/org/springframework/integration/xmpp/messages/InboundXmppEndpointTests-context.xml b/spring-integration-xmpp/src/test/resources/org/springframework/integration/xmpp/messages/InboundXmppEndpointTests-context.xml index 489c766656..8eb9125809 100644 --- a/spring-integration-xmpp/src/test/resources/org/springframework/integration/xmpp/messages/InboundXmppEndpointTests-context.xml +++ b/spring-integration-xmpp/src/test/resources/org/springframework/integration/xmpp/messages/InboundXmppEndpointTests-context.xml @@ -15,16 +15,16 @@ ~ limitations under the License. --> - + - + - + - + - + - + diff --git a/spring-integration-xmpp/src/test/resources/org/springframework/integration/xmpp/messages/OutboundXmppEndpointTests-context.xml b/spring-integration-xmpp/src/test/resources/org/springframework/integration/xmpp/messages/OutboundXmppEndpointTests-context.xml index 90e0792466..33dd691865 100644 --- a/spring-integration-xmpp/src/test/resources/org/springframework/integration/xmpp/messages/OutboundXmppEndpointTests-context.xml +++ b/spring-integration-xmpp/src/test/resources/org/springframework/integration/xmpp/messages/OutboundXmppEndpointTests-context.xml @@ -12,11 +12,11 @@ --> - + - + - + - - - + + + - + - + - + - + diff --git a/spring-integration-xmpp/src/test/resources/org/springframework/integration/xmpp/presence/InboundXmppRosterEventsEndpointTests-context.xml b/spring-integration-xmpp/src/test/resources/org/springframework/integration/xmpp/presence/InboundXmppRosterEventsEndpointTests-context.xml index 4e558d9912..52ef01c465 100644 --- a/spring-integration-xmpp/src/test/resources/org/springframework/integration/xmpp/presence/InboundXmppRosterEventsEndpointTests-context.xml +++ b/spring-integration-xmpp/src/test/resources/org/springframework/integration/xmpp/presence/InboundXmppRosterEventsEndpointTests-context.xml @@ -11,12 +11,12 @@ permissions and ~ limitations under the License. --> - - - - - - - + + + + + + + - + - + - + - + - + diff --git a/spring-integration-xmpp/src/test/resources/org/springframework/integration/xmpp/presence/OutboundXmppRosterEventsEndpointTests-context.xml b/spring-integration-xmpp/src/test/resources/org/springframework/integration/xmpp/presence/OutboundXmppRosterEventsEndpointTests-context.xml index 82ce44f795..f390083e9e 100644 --- a/spring-integration-xmpp/src/test/resources/org/springframework/integration/xmpp/presence/OutboundXmppRosterEventsEndpointTests-context.xml +++ b/spring-integration-xmpp/src/test/resources/org/springframework/integration/xmpp/presence/OutboundXmppRosterEventsEndpointTests-context.xml @@ -11,12 +11,12 @@ permissions and ~ limitations under the License. --> - - - - - - - + + + + + + + - - + - + - - - - - + + + + + - + - +