public final class ServiceDiscoveryManager extends Manager
Manages XEP-0030: Service Discovery.
The ability to discover information about entities on the Jabber network is extremely valuable. Such information might include features offered or protocols supported by the entity, the entity’s type or identity, and additional entities that are associated with the original entity in some way (often thought of as “children” of the “parent” entity).
Enabled extensions are automatically added to the list of features by their respective manager class. Disabled extensions are removed.
This class automatically manages inbound service discovery requests by responding with a list of enabled extensions (features).
Modifier and Type | Method and Description |
---|---|
void |
addCapabilitiesChangeListener(java.util.function.Consumer<java.util.EventObject> listener)
Adds a property change listener, which listens for changes in the identities, features, extensions and items collections.
|
void |
addExtension(DataForm extension)
Adds an extension.
|
void |
addFeature(java.lang.Class<? extends Manager> managerClass)
Adds a feature by its manager class.
|
void |
addFeature(java.lang.String feature)
Adds a feature.
|
void |
addIdentity(Identity identity)
Adds an identity.
|
void |
addInfoNode(InfoNode infoNode)
Adds an info node.
|
AsyncResult<InfoNode> |
discoverInformation(Jid jid)
Discovers information about another XMPP entity.
|
AsyncResult<InfoNode> |
discoverInformation(Jid jid,
java.lang.String node)
Discovers information about another XMPP entity targeted at a specific node.
|
AsyncResult<ItemNode> |
discoverItems(Jid jid)
Discovers item associated with another XMPP entity.
|
AsyncResult<ItemNode> |
discoverItems(Jid jid,
ResultSetManagement resultSet)
Discovers item associated with another XMPP entity.
|
AsyncResult<ItemNode> |
discoverItems(Jid jid,
java.lang.String node)
Discovers item associated with another XMPP entity.
|
AsyncResult<ItemNode> |
discoverItems(Jid jid,
java.lang.String node,
ResultSetManagement resultSetManagement)
Discovers item associated with another XMPP entity.
|
AsyncResult<java.util.List<Item>> |
discoverServices(Identity identity)
Discovers a service on the connected server by its identity.
|
AsyncResult<java.util.List<Item>> |
discoverServices(java.lang.String feature)
Discovers a service on the connected server by its feature namespace.
|
java.util.List<DataForm> |
getExtensions()
Gets an unmodifiable list of extensions.
|
java.util.Set<java.lang.String> |
getFeatures()
Gets an unmodifiable set of features.
|
java.util.Set<Identity> |
getIdentities()
Gets an unmodifiable set of identities.
|
java.util.List<Item> |
getItems()
Gets an unmodifiable list of items.
|
void |
registerFeature(Extension extension)
Registers a feature / extension.
|
void |
removeCapabilitiesChangeListener(java.util.function.Consumer<java.util.EventObject> listener)
Removes a property change listener.
|
void |
removeExtension(DataForm extension)
Removes an extension.
|
void |
removeFeature(java.lang.Class<? extends Manager> managerClass)
Removes a feature by its manager class.
|
void |
removeFeature(java.lang.String feature)
Removes a feature.
|
void |
removeIdentity(Identity identity)
Removes an identity.
|
void |
removeInfoNode(java.lang.String node)
Removes an info node.
|
void |
setItemProvider(ResultSetProvider<Item> itemProvider)
Sets an item provider for the root node.
|
void |
setItemProvider(java.lang.String node,
ResultSetProvider<Item> itemProvider)
Sets an item provider for a node.
|
isEnabled, setEnabled
public final void addCapabilitiesChangeListener(java.util.function.Consumer<java.util.EventObject> listener)
Adds a property change listener, which listens for changes in the identities, features, extensions and items collections.
listener
- The listener.removeCapabilitiesChangeListener(Consumer)
public final void removeCapabilitiesChangeListener(java.util.function.Consumer<java.util.EventObject> listener)
Removes a property change listener.
listener
- The listener.addCapabilitiesChangeListener(Consumer)
public final java.util.List<Item> getItems()
Gets an unmodifiable list of items.
public final java.util.Set<Identity> getIdentities()
Gets an unmodifiable set of identities.
addIdentity(rocks.xmpp.extensions.disco.model.info.Identity)
,
removeIdentity(rocks.xmpp.extensions.disco.model.info.Identity)
public final java.util.Set<java.lang.String> getFeatures()
Gets an unmodifiable set of features.
addFeature(String)
,
removeFeature(String)
public final java.util.List<DataForm> getExtensions()
Gets an unmodifiable list of extensions.
addExtension(rocks.xmpp.extensions.data.model.DataForm)
,
removeExtension(rocks.xmpp.extensions.data.model.DataForm)
,
XEP-0128: Service Discovery Extensionspublic final void addIdentity(Identity identity)
Adds an identity.
identity
- The identity.removeIdentity(rocks.xmpp.extensions.disco.model.info.Identity)
,
getIdentities()
public final void removeIdentity(Identity identity)
Removes an identity.
identity
- The identity.addIdentity(rocks.xmpp.extensions.disco.model.info.Identity)
,
getIdentities()
public final void addFeature(java.lang.String feature)
Adds a feature. Features should not be added or removed directly. Instead enable or disable the respective extension manager, which will then add or remove the feature. That way, supported features are consistent with enabled extension managers and service discovery won’t reveal features, that are in fact not supported.
feature
- The feature.removeFeature(String)
,
getFeatures()
public final void removeFeature(java.lang.String feature)
Removes a feature.
feature
- The feature.addFeature(String)
,
getFeatures()
public final void addFeature(java.lang.Class<? extends Manager> managerClass)
Adds a feature by its manager class.
managerClass
- The manager class.addFeature(String)
,
getFeatures()
public final void removeFeature(java.lang.Class<? extends Manager> managerClass)
Removes a feature by its manager class.
managerClass
- The feature.addFeature(String)
,
getFeatures()
public final void addExtension(DataForm extension)
Adds an extension.
extension
- The extension.removeExtension(rocks.xmpp.extensions.data.model.DataForm)
,
getExtensions()
,
XEP-0128: Service Discovery Extensionspublic final void removeExtension(DataForm extension)
Removes an extension.
extension
- The extension.addExtension(rocks.xmpp.extensions.data.model.DataForm)
,
getExtensions()
,
XEP-0128: Service Discovery Extensionspublic final AsyncResult<InfoNode> discoverInformation(Jid jid)
Discovers information about another XMPP entity.
3. Discovering Information About a Jabber Entity
A requesting entity may want to discover information about another entity on the network. The information desired generally is of two kinds:
- The target entity’s identity.
- The features offered and protocols supported by the target entity.
jid
- The entity’s JID.public final AsyncResult<InfoNode> discoverInformation(Jid jid, java.lang.String node)
Discovers information about another XMPP entity targeted at a specific node.
A disco#info query MAY also be directed to a specific node identifier associated with a JID.
jid
- The entity’s JID.node
- The node.discoverInformation(Jid)
public final AsyncResult<ItemNode> discoverItems(Jid jid)
Discovers item associated with another XMPP entity.
jid
- The JID.public final AsyncResult<ItemNode> discoverItems(Jid jid, ResultSetManagement resultSet)
Discovers item associated with another XMPP entity.
jid
- The JID.resultSet
- The result set management.public final AsyncResult<ItemNode> discoverItems(Jid jid, java.lang.String node)
Discovers item associated with another XMPP entity.
jid
- The JID.node
- The node.public final AsyncResult<ItemNode> discoverItems(Jid jid, java.lang.String node, ResultSetManagement resultSetManagement)
Discovers item associated with another XMPP entity.
jid
- The JID.node
- The node.resultSetManagement
- The result set management.public final AsyncResult<java.util.List<Item>> discoverServices(Identity identity)
Discovers a service on the connected server by its identity.
E.g. to discover MUC services you could call this method with Identity.conferenceText()
;
This method is generally preferred over discoverServices(String)
.
identity
- The identity.public final AsyncResult<java.util.List<Item>> discoverServices(java.lang.String feature)
Discovers a service on the connected server by its feature namespace.
feature
- The feature namespace.public final void addInfoNode(InfoNode infoNode)
Adds an info node.
infoNode
- The info node.public final void removeInfoNode(java.lang.String node)
Removes an info node.
node
- The node name.public final void setItemProvider(ResultSetProvider<Item> itemProvider)
Sets an item provider for the root node.
If you want to manage items in memory, you can use ResultSetProvider.forItems(Collection)
}.
itemProvider
- The item provider.public final void setItemProvider(java.lang.String node, ResultSetProvider<Item> itemProvider)
Sets an item provider for a node.
If you want to manage items in memory, you can use ResultSetProvider.forItems(Collection)
}.
node
- The node name.itemProvider
- The item provider.public final void registerFeature(Extension extension)
Registers a feature / extension.
extension
- The extension.Copyright © 2014–2019 XMPP.rocks. All rights reserved.