Smack

org.jivesoftware.smackx
Class ServiceDiscoveryManager

java.lang.Object
  extended byorg.jivesoftware.smackx.ServiceDiscoveryManager

public class ServiceDiscoveryManager
extends Object

Manages discovery of services in XMPP entities. This class provides:

  1. A registry of supported features in this XMPP entity.
  2. Automatic response when this XMPP entity is queried for information.
  3. Ability to discover items and information of remote XMPP entities.
  4. Ability to publish publicly available items.

Author:
Gaston Dombiak

Constructor Summary
ServiceDiscoveryManager(XMPPConnection connection)
          Creates a new ServiceDiscoveryManager for a given XMPPConnection.
 
Method Summary
 void addFeature(String feature)
          Registers that a new feature is supported by this XMPP entity.
 DiscoverInfo discoverInfo(String entityID)
          Returns the discovered information of a given XMPP entity addressed by its JID.
 DiscoverInfo discoverInfo(String entityID, String node)
          Returns the discovered information of a given XMPP entity addressed by its JID and note attribute.
 DiscoverItems discoverItems(String entityID)
          Returns the discovered items of a given XMPP entity addressed by its JID.
 DiscoverItems discoverItems(String entityID, String node)
          Returns the discovered items of a given XMPP entity addressed by its JID and note attribute.
 Iterator getFeatures()
          Returns the supported features by this XMPP entity.
static ServiceDiscoveryManager getInstanceFor(XMPPConnection connection)
          Returns the ServiceDiscoveryManager instance associated with a given XMPPConnection.
 boolean includesFeature(String feature)
          Returns true if the specified feature is registered in the ServiceDiscoveryManager.
 void publishItems(String entityID, DiscoverItems discoverItems)
          Publishes new items to a parent entity.
 void removeFeature(String feature)
          Removes the specified feature from the supported features by this XMPP entity.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ServiceDiscoveryManager

public ServiceDiscoveryManager(XMPPConnection connection)
Creates a new ServiceDiscoveryManager for a given XMPPConnection. This means that the service manager will respond to any service discovery request that the connection may receive.

Parameters:
connection - the connection to which a ServiceDiscoveryManager is going to be created
Method Detail

getInstanceFor

public static ServiceDiscoveryManager getInstanceFor(XMPPConnection connection)
Returns the ServiceDiscoveryManager instance associated with a given XMPPConnection.

Parameters:
connection - the connection used to look for the proper ServiceDiscoveryManager
Returns:
the ServiceDiscoveryManager associated with a given XMPPConnection

getFeatures

public Iterator getFeatures()
Returns the supported features by this XMPP entity.

Returns:
an Iterator on the supported features by this XMPP entity

addFeature

public void addFeature(String feature)
Registers that a new feature is supported by this XMPP entity. When this client is queried for its information the registered features will be answered.

Parameters:
feature - the feature to register as supported

removeFeature

public void removeFeature(String feature)
Removes the specified feature from the supported features by this XMPP entity.

Parameters:
feature - the feature to remove from the supported features

includesFeature

public boolean includesFeature(String feature)
Returns true if the specified feature is registered in the ServiceDiscoveryManager.

Parameters:
feature - the feature to look for
Returns:
a boolean indicating if the specified featured is registered or not

discoverInfo

public DiscoverInfo discoverInfo(String entityID)
                          throws XMPPException
Returns the discovered information of a given XMPP entity addressed by its JID.

Parameters:
entityID - the address of the XMPP entity
Returns:
the discovered information
Throws:
XMPPException - if the operation failed for some reason

discoverInfo

public DiscoverInfo discoverInfo(String entityID,
                                 String node)
                          throws XMPPException
Returns the discovered information of a given XMPP entity addressed by its JID and note attribute. Use this message only when trying to query information which is not directly addressable.

Parameters:
entityID - the address of the XMPP entity
node - the attribute that supplements the 'jid' attribute
Returns:
the discovered information
Throws:
XMPPException - if the operation failed for some reason

discoverItems

public DiscoverItems discoverItems(String entityID)
                            throws XMPPException
Returns the discovered items of a given XMPP entity addressed by its JID.

Parameters:
entityID - the address of the XMPP entity
Returns:
the discovered information
Throws:
XMPPException - if the operation failed for some reason

discoverItems

public DiscoverItems discoverItems(String entityID,
                                   String node)
                            throws XMPPException
Returns the discovered items of a given XMPP entity addressed by its JID and note attribute. Use this message only when trying to query information which is not directly addressable.

Parameters:
entityID - the address of the XMPP entity
node - the attribute that supplements the 'jid' attribute
Returns:
the discovered items
Throws:
XMPPException - if the operation failed for some reason

publishItems

public void publishItems(String entityID,
                         DiscoverItems discoverItems)
                  throws XMPPException
Publishes new items to a parent entity. The item elements to publish MUST have at least a 'jid' attribute specifying the Entity ID of the item, and an action attribute which specifies the action being taken for that item. Possible action values are: "update" and "remove".

Parameters:
entityID - the address of the XMPP entity
discoverItems - the DiscoveryItems to publish
Throws:
XMPPException - if the operation failed for some reason

Smack

Copyright © 2003 Jive Software.