Clearspace API (1.7.0) Core Javadocs

com.jivesoftware.community.xmpp
Class IMManager

java.lang.Object
  extended by com.jivesoftware.community.xmpp.IMManager
All Implemented Interfaces:
UserListener, com.jivesoftware.community.cache.CacheFactory.ClusteringListener, JiveManager

public class IMManager
extends java.lang.Object
implements JiveManager, UserListener, com.jivesoftware.community.cache.CacheFactory.ClusteringListener

Manages connection to the Openfire RTC server. Clearspace connects to Openfire as an external component, which allows it to monitor presence information, run commands, link authentication and user accounts, etc.

In order to connect to Openfire, Clearspace must be configured with the external component address, port, and secret key. A multi-cast DNS service assists Clearspace in discovering all Openfire servers on the local network.

The external component connection is made using the open XMPP protocol. However, Clearspace relies on Ad-Hoc Commands that are specifically implemented in Openfire.


Nested Class Summary
static class IMManager.LocalRestartTask
           
 
Constructor Summary
IMManager()
           
 
Method Summary
 void addXMPPListener(XMPPListener listener)
          Adds an XMPP listener, which listens for connects and disconnects as well as presence updates.
 void clusteringStarted()
           
 void clusteringStopped()
           
 void destroy()
          Notifies the manager to release any resources that may be holding on too.
 com.jivesoftware.community.xmpp.ClearspaceComponent getClearspaceComponent()
           
 javax.jmdns.ServiceInfo getDiscoveredComponentInfo(java.lang.String name)
          Returns the external component information for a service name discovered through multi-cast DNS.
 java.util.Collection<javax.jmdns.ServiceInfo> getDiscoveredXMPPHosts()
          Returns a collection of the Openfire servers that have been discovered through multi-cast DNS.
 java.lang.String getHttpBindSecureUrl()
          If the HTTP binding service is enabled on the RTC server, see isHttpBindEnabled(), this method will return the secure URL on which it can be reached.
 java.lang.String getHttpBindUnsecureUrl()
          If the HTTP binding service is enabled on the RTC server, see isHttpBindEnabled(), this method will return the unsecure URL on which it can be reached.
 java.lang.String getHttpBindUrl()
          If the HTTP binding service is enabled on the RTC server, see isHttpBindEnabled(), this method will return the URL on which it can be reached.
 java.lang.String getJavaScriptUrl()
           
 org.xmpp.packet.JID getJIDForUser(User user)
           
 org.xmpp.packet.Presence getPresence(org.xmpp.packet.JID xmppAddress)
          Returns the presence info for a particular XMPP address, or null if is unavailable (offline) or if no presence information is available.
 org.xmpp.packet.Presence getPresence(User user)
          Returns the presence info for a User, or null if is unavailable (offline) or if no presence information is available.
 org.xmpp.packet.Presence getPresenceForResource(org.xmpp.packet.JID xmppAddress)
          Returns the presence info for a particular XMPP address resource, or null if the resource is unavailable (offline) or if no presence information is available.
 java.util.Collection<org.xmpp.packet.Presence> getPresences(org.xmpp.packet.JID xmppAddress)
          Returns a collection Presence information for all the user's current resources or null if the user is unavailable (offline) or if no presence information is available.
 com.jivesoftware.community.xmpp.ServerInformation getServerInformation()
          Returns information about the XMPP server as well as some basic statistics.
 java.lang.String getServerVersion()
          Returns information about the XMPP server version.
 com.jivesoftware.community.xmpp.UserCommandManager getUserCommandManager()
           
 User getUserForJID(org.xmpp.packet.JID jid)
           
 void initialize(JiveContext jiveContext)
          Initialize the manager.
 boolean isConnected()
          Returns true if Clearspace is connected as an external component to a Openfire server.
 boolean isEnabled()
          Returns true if Clearspace is setup as an external component to a Openfire server.
 boolean isHttpBindEnabled()
          Returns true if the HTTP binding service on the RTC server is currently enabled and false if it is not.
 void localReset()
           
 void removeXMPPListener(XMPPListener listener)
          Removes an XMPP listener.
 void reset()
          Restarts the external component connection to Openfire.
 void sendPacket(org.xmpp.packet.Packet packet)
          Sends an XMPP packet to the Openfire server.
protected  void setHttpBindEnabled(boolean enabled)
           
protected  void setHttpBindSecureUrl(java.lang.String url)
           
protected  void setHttpBindUnsecureUrl(java.lang.String url)
           
 void setJIDNodeForUser(User user, java.lang.String node)
           
protected  void setRelativeJavascriptUrl(java.lang.String javaScriptUrl)
           
 boolean testComponent(java.lang.String host, int port, java.lang.String secret)
          Tests an external component connection to the Openfire server.
 void userCreated(UserEvent event)
          Fired when a user is created.
 void userDeleted(UserEvent event)
          Fired when a user is deleted.
 void userLoggedIn(UserEvent event)
          This method is called whenever a user logs in.
 void userModified(UserEvent event)
          Fired when a user is modified.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IMManager

public IMManager()
Method Detail

initialize

public void initialize(JiveContext jiveContext)
Description copied from interface: JiveManager
Initialize the manager. It is within this method that it is ok to create, access and/or otherwise use external classes (including caches) with the possible exception of other JiveManagers. Until this method is called implementation should not access any external classes that could possibly either access one of the main Factory classes or any caches since doing so can cause deadlocks and possible clustering issues during startup. Attempting to access other JiveManager's may or may not work depending on the initialization order of the managers.

This method is used internally by Jive during application startup and should not be called during normal usage of the class.

Specified by:
initialize in interface JiveManager
Parameters:
jiveContext - the context to use during initialization

destroy

public void destroy()
Description copied from interface: JiveManager
Notifies the manager to release any resources that may be holding on too. This could also be used to clear out the managers caches, etc.

This method is used internally by Jive during application startup and should not be called during normal usage of the class.

Specified by:
destroy in interface JiveManager

testComponent

public boolean testComponent(java.lang.String host,
                             int port,
                             java.lang.String secret)
Tests an external component connection to the Openfire server.

Parameters:
host - the external component host.
port - the external component port
secret - the shared secret for the component connection.
Returns:
true if the connection worked.

reset

public void reset()
           throws org.xmpp.component.ComponentException
Restarts the external component connection to Openfire. Use the IMSettingsUtils class to configure external component settings.

Throws:
org.xmpp.component.ComponentException - if the external component connection failed.

localReset

public void localReset()
                throws org.xmpp.component.ComponentException
Throws:
org.xmpp.component.ComponentException

sendPacket

public void sendPacket(org.xmpp.packet.Packet packet)
Sends an XMPP packet to the Openfire server. It's recommended to call the isConnected() method before trying to send a packet.

Parameters:
packet - the packet to send.
Throws:
java.lang.IllegalStateException - if not connected to the server.

isEnabled

public boolean isEnabled()
Returns true if Clearspace is setup as an external component to a Openfire server.

Returns:
true if Clearspace is setup as an external component to a Openfire server.

isConnected

public boolean isConnected()
Returns true if Clearspace is connected as an external component to a Openfire server.

Returns:
true if Clearspace is connected as an external component to a Openfire server.

setJIDNodeForUser

public void setJIDNodeForUser(User user,
                              java.lang.String node)

getUserForJID

public User getUserForJID(org.xmpp.packet.JID jid)

getJIDForUser

public org.xmpp.packet.JID getJIDForUser(User user)

getDiscoveredXMPPHosts

public java.util.Collection<javax.jmdns.ServiceInfo> getDiscoveredXMPPHosts()
Returns a collection of the Openfire servers that have been discovered through multi-cast DNS. Each collection entry is a ServiceInfo object. Use the following properties: Additionally, you can check to see if component connections are enabled for the server by calling getDiscoveredComponentInfo(String) with ServiceInfo.getName() as an argument.

Returns:
a collection of Openfire servers discovered through multi-cast DNS.

getDiscoveredComponentInfo

public javax.jmdns.ServiceInfo getDiscoveredComponentInfo(java.lang.String name)
Returns the external component information for a service name discovered through multi-cast DNS. If no external component service is running on the host, this method will return null. Use the following properties: You must also know the secret key in order to make an external component connection.

Parameters:
name - the name of the service.
Returns:
the service info for the external component service or null if no information exists.

addXMPPListener

public void addXMPPListener(XMPPListener listener)
Adds an XMPP listener, which listens for connects and disconnects as well as presence updates.

Parameters:
listener - the XMPP listener.

removeXMPPListener

public void removeXMPPListener(XMPPListener listener)
Removes an XMPP listener.

Parameters:
listener - an XMPP listener.

getPresence

public org.xmpp.packet.Presence getPresence(org.xmpp.packet.JID xmppAddress)
Returns the presence info for a particular XMPP address, or null if is unavailable (offline) or if no presence information is available.

If the XMPP user has several presences (one for each resource), then the presence with the highest priority is returned. If several presence values have the same priority, the presence that is "most available" is returned.

Parameters:
xmppAddress - an XMPP address. If the address contains a resource, it will be ignored. To retrieve a presence information for a particular resource, see getPresenceForResource(org.xmpp.packet.JID).
Returns:
the user's current presence, or null if the user is unavailable or if no presence information is available..

getPresence

public org.xmpp.packet.Presence getPresence(User user)
Returns the presence info for a User, or null if is unavailable (offline) or if no presence information is available.

getPresence(org.xmpp.packet.JID)

Parameters:
user - the user to test for presence.
Returns:
the user's current presence, or null if the user is unavailable or if no presence information is available..

getPresenceForResource

public org.xmpp.packet.Presence getPresenceForResource(org.xmpp.packet.JID xmppAddress)
Returns the presence info for a particular XMPP address resource, or null if the resource is unavailable (offline) or if no presence information is available.

Parameters:
xmppAddress - a fully qualified XMPP ID, including a resource.
Returns:
the current presence, or null if unavailable or if no presence information is available.

getPresences

public java.util.Collection<org.xmpp.packet.Presence> getPresences(org.xmpp.packet.JID xmppAddress)
Returns a collection Presence information for all the user's current resources or null if the user is unavailable (offline) or if no presence information is available.

Parameters:
xmppAddress - an XMPP address (JID). It should be the bare address, e.g. jdoe@example.com, instead of jdoe@example.com/Work.
Returns:
an iterator (of Presence objects) for all the user's current presences, or null if the user is unavailable or if no presence information is available.

getClearspaceComponent

public com.jivesoftware.community.xmpp.ClearspaceComponent getClearspaceComponent()

getUserCommandManager

public com.jivesoftware.community.xmpp.UserCommandManager getUserCommandManager()

getServerInformation

public com.jivesoftware.community.xmpp.ServerInformation getServerInformation()
Returns information about the XMPP server as well as some basic statistics. If no information was found then null will be returned.

Returns:
information about the XMPP server as well as some basic statistics or null if nothing was found.

getServerVersion

public java.lang.String getServerVersion()
Returns information about the XMPP server version. If no information was found then null will be returned. The version of the server can also be obtained by using the method getServerInformation(), however, that method could return null for older versions of the server. This method exists as a standards way to always get the version of the server.

Returns:
information about the XMPP server version.

setHttpBindEnabled

protected void setHttpBindEnabled(boolean enabled)

isHttpBindEnabled

public boolean isHttpBindEnabled()
Returns true if the HTTP binding service on the RTC server is currently enabled and false if it is not.

Returns:
true if the HTTP binding service on the RTC server is currently enabled and false if it is not.

setHttpBindUnsecureUrl

protected void setHttpBindUnsecureUrl(java.lang.String url)

getHttpBindUnsecureUrl

public java.lang.String getHttpBindUnsecureUrl()
If the HTTP binding service is enabled on the RTC server, see isHttpBindEnabled(), this method will return the unsecure URL on which it can be reached. If the service is not enabled, this method will return null.

Returns:
the unsecure URL on which the HTTP binding service can be reached.

setHttpBindSecureUrl

protected void setHttpBindSecureUrl(java.lang.String url)

getHttpBindSecureUrl

public java.lang.String getHttpBindSecureUrl()
If the HTTP binding service is enabled on the RTC server, see isHttpBindEnabled(), this method will return the secure URL on which it can be reached. If the service is not enabled, this method will return null.

Returns:
the secure URL on which the HTTP binding service can be reached.

getHttpBindUrl

public java.lang.String getHttpBindUrl()
If the HTTP binding service is enabled on the RTC server, see isHttpBindEnabled(), this method will return the URL on which it can be reached. If the service is not enabled, this method will return null.

Returns:
the URL on which the HTTP binding service can be reached.

setRelativeJavascriptUrl

protected void setRelativeJavascriptUrl(java.lang.String javaScriptUrl)

getJavaScriptUrl

public java.lang.String getJavaScriptUrl()

userCreated

public void userCreated(UserEvent event)
Description copied from interface: UserListener
Fired when a user is created.

Specified by:
userCreated in interface UserListener
Parameters:
event - the UserEvent

userDeleted

public void userDeleted(UserEvent event)
Description copied from interface: UserListener
Fired when a user is deleted.

Specified by:
userDeleted in interface UserListener
Parameters:
event - the UserEvent

userModified

public void userModified(UserEvent event)
Description copied from interface: UserListener
Fired when a user is modified.

Specified by:
userModified in interface UserListener
Parameters:
event - the UserEvent

userLoggedIn

public void userLoggedIn(UserEvent event)
Description copied from interface: UserListener
This method is called whenever a user logs in.

Specified by:
userLoggedIn in interface UserListener
Parameters:
event - method is called whenever a user logs in.

clusteringStarted

public void clusteringStarted()
Specified by:
clusteringStarted in interface com.jivesoftware.community.cache.CacheFactory.ClusteringListener

clusteringStopped

public void clusteringStopped()
Specified by:
clusteringStopped in interface com.jivesoftware.community.cache.CacheFactory.ClusteringListener

Clearspace Project Page

Copyright © 1999-2007 Jive Software.