Spring Integration

org.springframework.integration.xmpp.messages
Class XmppMessageDrivenEndpoint

java.lang.Object
  extended by org.springframework.integration.context.IntegrationObjectSupport
      extended by org.springframework.integration.endpoint.AbstractEndpoint
          extended by org.springframework.integration.xmpp.messages.XmppMessageDrivenEndpoint
All Implemented Interfaces:
BeanFactoryAware, BeanNameAware, InitializingBean, Lifecycle, Phased, SmartLifecycle, NamedComponent

public class XmppMessageDrivenEndpoint
extends AbstractEndpoint
implements Lifecycle

This component logs in as a user and forwards any messages to that user on to downstream components. The component is an endpoint that has its own lifecycle and does not need any poller to work. It takes any message from a given XMPP session (as established by the current XMPPConnection) and forwards the Message as the payload of the Spring Integration Message. The Chat instance that's used is passed along as a header (under XmppHeaders.CHAT). Additionally, the Message.Type is passed along under the header 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 ChatManager maintains a Map<String, Chat> for threads and users, where the threadID (String) is the key or the userID String is the key. This Map is a Smack-specific implementation called org.jivesoftware.smack.util.collections.ReferenceMap that removes 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, Mark Fisher
See Also:
the ChatManager class that keeps watch over all Chats between the client and any other participants., handles all interesing operations on any Spring Integration channels., the XMPPConnection (as created by {@link XmppConnectionFactory}

Constructor Summary
XmppMessageDrivenEndpoint()
           
 
Method Summary
protected  void doStart()
          Subclasses must implement this method with the start behavior.
protected  void doStop()
          Subclasses must implement this method with the stop behavior.
protected  void onInit()
          Subclasses may implement this for initialization logic.
 void setExtractPayload(boolean extractPayload)
          Specify whether the text message body should be extracted when mapping to a Spring Integration Message payload.
 void setRequestChannel(MessageChannel requestChannel)
           
 void setXmppConnection(org.jivesoftware.smack.XMPPConnection xmppConnection)
          This will be injected or configured via a xmpp-connection-factory element.
 
Methods inherited from class org.springframework.integration.endpoint.AbstractEndpoint
getPhase, isAutoStartup, isRunning, setAutoStartup, setPhase, setTaskScheduler, start, stop, stop
 
Methods inherited from class org.springframework.integration.context.IntegrationObjectSupport
afterPropertiesSet, getBeanFactory, getComponentName, getComponentType, getConversionService, getRequiredMetadataPersister, getTaskScheduler, setBeanFactory, setBeanName, setComponentName, setConversionService, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.springframework.context.Lifecycle
isRunning, start, stop
 

Constructor Detail

XmppMessageDrivenEndpoint

public XmppMessageDrivenEndpoint()
Method Detail

setXmppConnection

public void setXmppConnection(org.jivesoftware.smack.XMPPConnection xmppConnection)
This will be injected or configured via a xmpp-connection-factory element.

Parameters:
xmppConnection - the connection

setRequestChannel

public void setRequestChannel(MessageChannel requestChannel)
Parameters:
requestChannel - the channel on which the inbound message should be sent

setExtractPayload

public void setExtractPayload(boolean extractPayload)
Specify whether the text message body should be extracted when mapping to a Spring Integration Message payload. Otherwise, the full XMPP Message will be passed within the payload. This value is true by default.


doStart

protected void doStart()
Description copied from class: AbstractEndpoint
Subclasses must implement this method with the start behavior. This method will be invoked while holding the AbstractEndpoint.lifecycleLock.

Specified by:
doStart in class AbstractEndpoint

doStop

protected void doStop()
Description copied from class: AbstractEndpoint
Subclasses must implement this method with the stop behavior. This method will be invoked while holding the AbstractEndpoint.lifecycleLock.

Specified by:
doStop in class AbstractEndpoint

onInit

protected void onInit()
               throws Exception
Description copied from class: IntegrationObjectSupport
Subclasses may implement this for initialization logic.

Overrides:
onInit in class IntegrationObjectSupport
Throws:
Exception

Spring Integration

Copyright © 2010. All Rights Reserved.