From ce1b89a3dee12cabd35b093de0278e08fc0105e2 Mon Sep 17 00:00:00 2001 From: Josh Long Date: Tue, 13 Jul 2010 01:32:18 +0000 Subject: [PATCH] Updating the XMPP adapter's documentation --- src/docbkx/xmpp.xml | 244 +++++++++++++++++++++++++++++++++----------- 1 file changed, 186 insertions(+), 58 deletions(-) diff --git a/src/docbkx/xmpp.xml b/src/docbkx/xmpp.xml index 9047636287..1035af308d 100644 --- a/src/docbkx/xmpp.xml +++ b/src/docbkx/xmpp.xml @@ -51,6 +51,49 @@ + +
+ Using The Spring Integration XMPP Namespace + + + Using the Spring Integration XMPP namespace support is simple. + + Its use is like any other module in the Spring framework: import the XML schema, and use it to define elements. + + A prototypical XMPP-based integration might feature the following header. We won't repeat this in subsequent + examples, because it is uninteresting. + + + + + + ... + + +]]> + + +
@@ -79,25 +122,21 @@
Inbound Message Adapter The Spring Integration adapters support receiving messages from other users in the system. To do this, the - adapter "logs in" as a user - on your behalf and receives the messages sent to that user. Those messages are then forwarded to your Spring - Integration - client. - The payload of the inbound Spring Integration message may be of the raw type - org.jivesoftware.smack.packet.Message, or of the type - java.lang.String + adapter "logs in" as a user on your behalf and receives the messages sent to that user. Those messages are then + forwarded to your Spring Integration client. + The payload of the inbound Spring Integration message may be of the raw type + org.jivesoftware.smack.packet.Message, or of the type + java.lang.String - which is the type of the raw Message's - - body - + body property - depending on whether you specify extract-payload on the adapter's configuration or not. Inbound Messages are typically small and are text-oriented. Messages received using the adapter have - a pretty standard layout, with known headers (all headers have keys defined on - org.springframework.integration.xmpp.XmppHeaders): + a pretty standard layout, with known headers (all headers have keys defined on + org.springframework.integration.xmpp.XmppHeaders): @@ -116,37 +155,33 @@ - XmppHeaders.TYPE - The value of the - the - org.jivesoftware.smack.packet.Message.Type enum that describes the inbound message. Possible values are: - normal, - chat, - groupchat, - headline, - error. + XmppHeaders.TYPE + The value of the + the + + org.jivesoftware.smack.packet.Message.Type + + enum that describes the inbound message. Possible values are: + normal, + chat, + groupchat, + headline, + error. + - XmppHeaders.CHAT - A reference to the org.jivesoftware.smack.Chat class which represents the - threaded conversation containing the message. + XmppHeaders.CHAT + A reference to the + org.jivesoftware.smack.Chat + class which represents the + threaded conversation containing the message. + -
@@ -160,24 +195,7 @@ - + @@ -190,12 +208,10 @@ - - ]]> - + ]]> @@ -203,10 +219,122 @@ + + In this example, the message is received from the XMPP adapter and passed to a + service-activator + component. Here's the declaration of theservice-activator. + + + +
Outbound Message Adapter - TBD + + You may also send messages to other users on XMPP using the + outbound-message-channel-adapter + adapter. The is configured like the + + xmpp-message-inbound-channel-adapter. The + adapter takes an + xmpp-connection + reference. + + + Here is a (necessarily) contrived example solution using the outbound adapter. + + + + + + + + + + + + + + + + + + + + + + + +]]> + + + + + The adapter expects as its input - at a minimum - a payload of typejava.lang.String, and + a header value + for + XmppHeaders.CHAT_TO_USER + that specifies to which the user the payload body should be sent to. + To create a message destined for theoutbound-message-channel-adapter, you might use the following + Java code: + + + xmppOutboundMsg = MessageBuilder.withPayload("Hello, world!" ) + .setHeader(XmppHeaders.CHAT_TO_USER, "userhandle") + .build(); +]]> + + + + It's easy enough to use Java to handle this and this lets you update the target of the + XMPP message dynamically at runtime in Java code. If, however, the target is more static in nature, you can + configure it using the + XMPP enricher support. Here is an example using the enricher. The enricher enriches the Spring Integration + message + to support the header values that the outbound XMPP adapters expect. + + + + + + + +]]> + + + + +