Package org.apache.camel.component.xmpp
Class XmppEndpoint
- java.lang.Object
-
- org.apache.camel.support.service.BaseService
-
- org.apache.camel.support.service.ServiceSupport
-
- org.apache.camel.support.DefaultEndpoint
-
- org.apache.camel.component.xmpp.XmppEndpoint
-
- All Implemented Interfaces:
AutoCloseable,org.apache.camel.CamelContextAware,org.apache.camel.Endpoint,org.apache.camel.IsSingleton,org.apache.camel.Service,org.apache.camel.ShutdownableService,org.apache.camel.spi.HasId,org.apache.camel.spi.HeaderFilterStrategyAware,org.apache.camel.StatefulService,org.apache.camel.SuspendableService
@UriEndpoint(firstVersion="1.0", scheme="xmpp", title="XMPP", syntax="xmpp:host:port/participant", alternativeSyntax="xmpp:user:password@host:port/participant", category={CHAT,MESSAGING}) public class XmppEndpoint extends org.apache.camel.support.DefaultEndpoint implements org.apache.camel.spi.HeaderFilterStrategyAwareSend and receive messages to/from an XMPP chat server.
-
-
Constructor Summary
Constructors Constructor Description XmppEndpoint()XmppEndpoint(String uri, XmppComponent component)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description org.jivesoftware.smack.tcp.XMPPTCPConnectioncreateConnection()org.apache.camel.ConsumercreateConsumer(org.apache.camel.Processor processor)org.apache.camel.ProducercreateDirectProducer()protected StringcreateEndpointUri()org.apache.camel.ProducercreateGroupChatProducer()org.apache.camel.ProducercreatePrivateChatProducer(String participant)org.apache.camel.ProducercreateProducer()org.apache.camel.ProducercreatePubSubProducer()protected voiddoStop()XmppBindinggetBinding()StringgetChatId()org.jivesoftware.smack.ConnectionConfigurationgetConnectionConfig()StringgetConnectionDescription()static StringgetConnectionMessage(org.jivesoftware.smack.XMPPConnection connection)intgetConnectionPollDelay()org.apache.camel.spi.HeaderFilterStrategygetHeaderFilterStrategy()StringgetHost()StringgetNickname()StringgetParticipant()StringgetPassword()intgetPort()StringgetResource()StringgetRoom()protected StringgetRoomPassword()StringgetServiceName()StringgetUser()booleanisCreateAccount()booleanisDoc()booleanisLogin()booleanisPubsub()booleanisTestConnectionOnStartup()StringresolveParticipant(org.jivesoftware.smack.XMPPConnection connection)If there is no "@" symbol in the participant, find the service domain JID and return the fully qualified JID for the participant as user@server.domainStringresolveRoom(org.jivesoftware.smack.XMPPConnection connection)voidsetBinding(XmppBinding binding)Sets the binding used to convert from a Camel message to and from an XMPP messagevoidsetConnectionConfig(org.jivesoftware.smack.ConnectionConfiguration connectionConfig)To use an existing connection configuration.voidsetConnectionPollDelay(int connectionPollDelay)The amount of time in seconds between polls (in seconds) to verify the health of the XMPP connection, or between attempts to establish an initial consumer connection.voidsetCreateAccount(boolean createAccount)If true, an attempt to create an account will be made.voidsetDoc(boolean doc)Set a doc header on the IN message containing a Document form of the incoming packet; default is true if presence or pubsub are true, otherwise falsevoidsetHeaderFilterStrategy(org.apache.camel.spi.HeaderFilterStrategy headerFilterStrategy)To use a custom HeaderFilterStrategy to filter header to and from Camel message.voidsetHost(String host)Hostname for the chat servervoidsetLogin(boolean login)Whether to login the user.voidsetNickname(String nickname)Use nickname when joining room.voidsetParticipant(String participant)JID (Jabber ID) of person to receive messages.voidsetPassword(String password)Password for loginvoidsetPort(int port)Port number for the chat servervoidsetPubsub(boolean pubsub)Accept pubsub packets on input, default is falsevoidsetResource(String resource)XMPP resource.voidsetRoom(String room)If this option is specified, the component will connect to MUC (Multi User Chat).voidsetRoomPassword(String roomPassword)Password for roomvoidsetServiceName(String serviceName)The name of the service you are connecting to.voidsetTestConnectionOnStartup(boolean testConnectionOnStartup)Specifies whether to test the connection on startup.voidsetUser(String user)User name (without server name).-
Methods inherited from class org.apache.camel.support.DefaultEndpoint
configureConsumer, configureExchange, configurePollingConsumer, configureProperties, createAsyncProducer, createExchange, createExchange, createPollingConsumer, doInit, doStart, equals, getCamelContext, getComponent, getEndpointKey, getEndpointUri, getExceptionHandler, getExchangePattern, getId, getPollingConsumerBlockTimeout, getPollingConsumerQueueSize, hashCode, isAutowiredEnabled, isBridgeErrorHandler, isLazyStartProducer, isLenientProperties, isPollingConsumerBlockWhenFull, isPollingConsumerCopy, isSingleton, setAutowiredEnabled, setBridgeErrorHandler, setCamelContext, setComponent, setEndpointUri, setEndpointUriIfNotSpecified, setExceptionHandler, setExchangePattern, setLazyStartProducer, setPollingConsumerBlockTimeout, setPollingConsumerBlockWhenFull, setPollingConsumerCopy, setPollingConsumerQueueSize, setProperties, toString
-
Methods inherited from class org.apache.camel.support.service.BaseService
build, doBuild, doFail, doLifecycleChange, doResume, doShutdown, doSuspend, fail, getStatus, init, isBuild, isInit, isNew, isRunAllowed, isShutdown, isStarted, isStarting, isStartingOrStarted, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, isSuspendingOrSuspended, resume, shutdown, start, stop, suspend
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
-
-
-
Constructor Detail
-
XmppEndpoint
public XmppEndpoint()
-
XmppEndpoint
public XmppEndpoint(String uri, XmppComponent component)
-
-
Method Detail
-
createProducer
public org.apache.camel.Producer createProducer() throws Exception- Specified by:
createProducerin interfaceorg.apache.camel.Endpoint- Throws:
Exception
-
createGroupChatProducer
public org.apache.camel.Producer createGroupChatProducer()
-
createPrivateChatProducer
public org.apache.camel.Producer createPrivateChatProducer(String participant)
-
createDirectProducer
public org.apache.camel.Producer createDirectProducer()
-
createPubSubProducer
public org.apache.camel.Producer createPubSubProducer()
-
createConsumer
public org.apache.camel.Consumer createConsumer(org.apache.camel.Processor processor) throws Exception- Specified by:
createConsumerin interfaceorg.apache.camel.Endpoint- Throws:
Exception
-
createEndpointUri
protected String createEndpointUri()
- Overrides:
createEndpointUriin classorg.apache.camel.support.DefaultEndpoint
-
createConnection
public org.jivesoftware.smack.tcp.XMPPTCPConnection createConnection() throws InterruptedException, IOException, org.jivesoftware.smack.SmackException, org.jivesoftware.smack.XMPPException- Throws:
InterruptedExceptionIOExceptionorg.jivesoftware.smack.SmackExceptionorg.jivesoftware.smack.XMPPException
-
resolveParticipant
public String resolveParticipant(org.jivesoftware.smack.XMPPConnection connection)
If there is no "@" symbol in the participant, find the service domain JID and return the fully qualified JID for the participant as user@server.domain
-
resolveRoom
public String resolveRoom(org.jivesoftware.smack.XMPPConnection connection) throws InterruptedException, org.jivesoftware.smack.SmackException, org.jivesoftware.smack.XMPPException
- Throws:
InterruptedExceptionorg.jivesoftware.smack.SmackExceptionorg.jivesoftware.smack.XMPPException
-
getConnectionDescription
public String getConnectionDescription()
-
getConnectionMessage
public static String getConnectionMessage(org.jivesoftware.smack.XMPPConnection connection)
-
getChatId
public String getChatId()
-
getBinding
public XmppBinding getBinding()
-
setBinding
public void setBinding(XmppBinding binding)
Sets the binding used to convert from a Camel message to and from an XMPP message
-
getHost
public String getHost()
-
setHost
public void setHost(String host)
Hostname for the chat server
-
getPort
public int getPort()
-
setPort
public void setPort(int port)
Port number for the chat server
-
getUser
public String getUser()
-
setUser
public void setUser(String user)
User name (without server name). If not specified, anonymous login will be attempted.
-
getPassword
public String getPassword()
-
setPassword
public void setPassword(String password)
Password for login
-
getResource
public String getResource()
-
setResource
public void setResource(String resource)
XMPP resource. The default is Camel.
-
isLogin
public boolean isLogin()
-
setLogin
public void setLogin(boolean login)
Whether to login the user.
-
isCreateAccount
public boolean isCreateAccount()
-
setCreateAccount
public void setCreateAccount(boolean createAccount)
If true, an attempt to create an account will be made. Default is false.
-
getRoom
public String getRoom()
-
setRoom
public void setRoom(String room)
If this option is specified, the component will connect to MUC (Multi User Chat). Usually, the domain name for MUC is different from the login domain. For example, if you are superman@jabber.org and want to join the krypton room, then the room URL is krypton@conference.jabber.org. Note the conference part. It is not a requirement to provide the full room JID. If the room parameter does not contain the @ symbol, the domain part will be discovered and added by Camel
-
setRoomPassword
public void setRoomPassword(String roomPassword)
Password for room
-
getRoomPassword
protected String getRoomPassword()
-
getParticipant
public String getParticipant()
-
setParticipant
public void setParticipant(String participant)
JID (Jabber ID) of person to receive messages. room parameter has precedence over participant.
-
getNickname
public String getNickname()
-
setNickname
public void setNickname(String nickname)
Use nickname when joining room. If room is specified and nickname is not, user will be used for the nickname.
-
setServiceName
public void setServiceName(String serviceName)
The name of the service you are connecting to. For Google Talk, this would be gmail.com.
-
getServiceName
public String getServiceName()
-
getHeaderFilterStrategy
public org.apache.camel.spi.HeaderFilterStrategy getHeaderFilterStrategy()
- Specified by:
getHeaderFilterStrategyin interfaceorg.apache.camel.spi.HeaderFilterStrategyAware
-
setHeaderFilterStrategy
public void setHeaderFilterStrategy(org.apache.camel.spi.HeaderFilterStrategy headerFilterStrategy)
To use a custom HeaderFilterStrategy to filter header to and from Camel message.- Specified by:
setHeaderFilterStrategyin interfaceorg.apache.camel.spi.HeaderFilterStrategyAware
-
getConnectionConfig
public org.jivesoftware.smack.ConnectionConfiguration getConnectionConfig()
-
setConnectionConfig
public void setConnectionConfig(org.jivesoftware.smack.ConnectionConfiguration connectionConfig)
To use an existing connection configuration. CurrentlyXMPPTCPConnectionConfigurationis only supported (XMPP over TCP).
-
isTestConnectionOnStartup
public boolean isTestConnectionOnStartup()
-
setTestConnectionOnStartup
public void setTestConnectionOnStartup(boolean testConnectionOnStartup)
Specifies whether to test the connection on startup. This is used to ensure that the XMPP client has a valid connection to the XMPP server when the route starts. Camel throws an exception on startup if a connection cannot be established. When this option is set to false, Camel will attempt to establish a "lazy" connection when needed by a producer, and will poll for a consumer connection until the connection is established. Default is true.
-
getConnectionPollDelay
public int getConnectionPollDelay()
-
setConnectionPollDelay
public void setConnectionPollDelay(int connectionPollDelay)
The amount of time in seconds between polls (in seconds) to verify the health of the XMPP connection, or between attempts to establish an initial consumer connection. Camel will try to re-establish a connection if it has become inactive. Default is 10 seconds.
-
setPubsub
public void setPubsub(boolean pubsub)
Accept pubsub packets on input, default is false
-
isPubsub
public boolean isPubsub()
-
setDoc
public void setDoc(boolean doc)
Set a doc header on the IN message containing a Document form of the incoming packet; default is true if presence or pubsub are true, otherwise false
-
isDoc
public boolean isDoc()
-
-