Package org.jivesoftware.openfire.pubsub
Interface PubSubService
- All Known Implementing Classes:
PEPService,PubSubModule
public interface PubSubService
A PubSubService is responsible for keeping the hosted nodes by the service, the default
configuration to use for newly created nodes and specify the policy to use regarding
node management.
Implementations of PubSubService are expected to collaborate with a PubSubEngine
that will take care of handling packets sent to the service.
The separation between PubSubService and PubSubEngine allows to
reuse the handling of packets and at the same time be able to create different pubsub
services with different configurations. Examples of different pubsub services are:
XEP-60: Publish-Subscribe and XEP-163: Personal Eventing Protocol.
- Author:
- Matt Tucker
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final classA unique identifier for an item, in context of all nodes of all services in the system. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds an already persistent node to the service.voidbroadcast(Node node, org.xmpp.packet.Message message, Collection<org.xmpp.packet.JID> jids) Broadcasts the specified Message containing an event notification to a list of subscribers to the specified node.booleancanCreateNode(org.xmpp.packet.JID creator) Returns true if the pubsub service allows the specified user to create nodes.org.xmpp.packet.JIDReturns the XMPP address of the service.getDefaultNodeConfiguration(boolean leafType) Returns the default node configuration for the specified node type ornullif the specified node type is not supported by the service.Returns the ad-hoc commands manager used for this service.default NodeReturns theNodethat matches the specified node ID ornullif none was found.getNode(Node.UniqueIdentifier nodeID) Returns theNodethat matches the specified node ID ornullif none was found.getNodes()Returns the collection of nodes hosted by the pubsub service.Returns theCollectionNodethat acts as the root node of the entire node hierarchy.Returns a String that uniquely identifies this pubsub service.getShowPresences(org.xmpp.packet.JID subscriber) Returns the show values of the last know presence of all connected resources of the specified subscriber.Returns a registry of the presence's show value of users that subscribed to a node of the pubsub service and for which the node only delivers notifications for online users or node subscriptions deliver events based on the user presence show value.default PubSubService.UniqueIdentifierReturns a value that uniquely identifies this service in the XMPP domain.booleanReturns true if the pubsub service supports collection nodes.booleanReturns true if the pubsub service allows users to create nodes without specifying the node ID.booleanReturns true if a user may have more than one subscription with the node.booleanisServiceAdmin(org.xmpp.packet.JID user) Returns true if the specified user is a sysadmin of the pubsub service or has admin privileges.voidpresenceSubscriptionNotRequired(Node node, org.xmpp.packet.JID user) Requests the pubsub service to unsubscribe from the presence of the user.voidpresenceSubscriptionRequired(Node node, org.xmpp.packet.JID user) Requests the pubsub service to subscribe to the presence of the user.default voidremoveNode(String nodeID) Removes the specified node from the service.voidremoveNode(Node.UniqueIdentifier nodeID) Removes the specified node from the service.voidsend(org.xmpp.packet.Packet packet) Sends the specified packet.voidsendNotification(Node node, org.xmpp.packet.Message message, org.xmpp.packet.JID jid) Sends the specified Message containing an event notification to a specific subscriber of the specified node.
-
Method Details
-
getAddress
org.xmpp.packet.JID getAddress()Returns the XMPP address of the service.- Returns:
- the XMPP address of the service.
-
getServiceID
String getServiceID()Returns a String that uniquely identifies this pubsub service. This information is being used when storing node information in the database so it's possible to have nodes with the same ID but under different pubsub services.- Returns:
- a String that uniquely identifies this pubsub service.
-
getSubscriberPresences
Returns a registry of the presence's show value of users that subscribed to a node of the pubsub service and for which the node only delivers notifications for online users or node subscriptions deliver events based on the user presence show value. Offline users will not have an entry in the map. Note: Key-> bare JID and Value-> Map whose key is full JID of connected resource and value is show value of the last received presence.- Returns:
- a registry of the presence's show value of users that subscribed to a node of the pubsub service.
-
canCreateNode
boolean canCreateNode(org.xmpp.packet.JID creator) Returns true if the pubsub service allows the specified user to create nodes.- Parameters:
creator- the JID of the entity trying to create a new node.- Returns:
- true if the pubsub service allows the specified user to create nodes.
-
isServiceAdmin
boolean isServiceAdmin(org.xmpp.packet.JID user) Returns true if the specified user is a sysadmin of the pubsub service or has admin privileges.- Parameters:
user- the user to check if he has admin privileges.- Returns:
- true if the specified user is a sysadmin of the pubsub service or has admin privileges.
-
isInstantNodeSupported
boolean isInstantNodeSupported()Returns true if the pubsub service allows users to create nodes without specifying the node ID. The service will create a random node ID and assigne it to the node.- Returns:
- true if the pubsub service allows users to create nodes without specifying the node ID.
-
isCollectionNodesSupported
boolean isCollectionNodesSupported()Returns true if the pubsub service supports collection nodes. When collection nodes is supported it is possible to create hierarchy of nodes where aCollectionNodemay only hold children nodes of typeCollectionNodeorLeafNode. On the other hand,LeafNodecan only holdPublishedItem.- Returns:
- true if the pubsub service supports collection nodes.
-
getRootCollectionNode
CollectionNode getRootCollectionNode()Returns theCollectionNodethat acts as the root node of the entire node hierarchy. The returned node does not have a node identifier. If collection nodes is not supported then returnnull.- Returns:
- the CollectionNode that acts as the root node of the entire node hierarchy
or
nullif collection nodes is not supported.
-
getNode
Returns theNodethat matches the specified node ID ornullif none was found.- Parameters:
nodeID- the ID that uniquely identifies the node in the pubsub service.- Returns:
- the Node that matches the specified node ID or
nullif none was found.
-
getNode
Returns theNodethat matches the specified node ID ornullif none was found.- Parameters:
nodeID- the ID that uniquely identifies the node.- Returns:
- the Node that matches the specified node ID or
nullif none was found.
-
getNodes
Collection<Node> getNodes()Returns the collection of nodes hosted by the pubsub service. The collection does not support modifications.- Returns:
- the collection of nodes hosted by the pubsub service.
-
addNode
Adds an already persistent node to the service.- Parameters:
node- the persistent node to add to the service.
-
removeNode
Removes the specified node from the service. Most probably the node was deleted from the database as well.A future version may support unloading of inactive nodes even though they may still exist in the database.
- Parameters:
nodeID- the ID that uniquely identifies the node in the pubsub service.
-
removeNode
Removes the specified node from the service. Most probably the node was deleted from the database as well.A future version may support unloading of inactive nodes even though they may still exist in the database.
- Parameters:
nodeID- the ID that uniquely identifies the node.
-
broadcast
Broadcasts the specified Message containing an event notification to a list of subscribers to the specified node. Each message being sent has to have a unique ID value so that the service can properly track any notification-related errors that may occur.- Parameters:
node- the node that triggered the event notification.message- the message containing the event notification.jids- the list of entities to get the event notification.
-
send
void send(org.xmpp.packet.Packet packet) Sends the specified packet.- Parameters:
packet- the packet to send.
-
sendNotification
Sends the specified Message containing an event notification to a specific subscriber of the specified node. The message being sent has to have a unique ID value so that the service can properly track any notification-related errors that may occur.- Parameters:
node- the node that triggered the event notification.message- the message containing the event notification.jid- the entity to get the event notification.
-
getDefaultNodeConfiguration
Returns the default node configuration for the specified node type ornullif the specified node type is not supported by the service.- Parameters:
leafType- true when requesting default configuration of leaf nodes- Returns:
- the default node configuration for the specified node type or
nullif the specified node type is not supported by the service.
-
getShowPresences
Returns the show values of the last know presence of all connected resources of the specified subscriber. When the subscriber JID is a bare JID then the answered collection will have many entries one for each connected resource. Moreover, if the user is offline then an empty collectin is returned. Available show status is represented by aonlinevalue. The rest of the possible show values as defined in RFC 3921.- Parameters:
subscriber- the JID of the subscriber. This is not the JID of the affiliate.- Returns:
- an empty collection when offline. Otherwise, a collection with the show value of each connected resource.
-
presenceSubscriptionRequired
Requests the pubsub service to subscribe to the presence of the user. If the service has already subscribed to the user's presence then do nothing.- Parameters:
node- the node that originated the subscription request.user- the JID of the affiliate to subscribe to his presence.
-
presenceSubscriptionNotRequired
Requests the pubsub service to unsubscribe from the presence of the user. If the service was not subscribed to the user's presence or any node still requires to be subscribed to the user presence then do nothing.- Parameters:
node- the node that originated the unsubscription request.user- the JID of the affiliate to unsubscribe from his presence.
-
isMultipleSubscriptionsEnabled
boolean isMultipleSubscriptionsEnabled()Returns true if a user may have more than one subscription with the node. When multiple subscriptions is enabled each subscription request, event notification and unsubscription request should include asubidattribute.- Returns:
- true if a user may have more than one subscription with the node.
-
getManager
AdHocCommandManager getManager()Returns the ad-hoc commands manager used for this service.- Returns:
- the ad-hoc commands manager used for this service.
-
getUniqueIdentifier
Returns a value that uniquely identifies this service in the XMPP domain.- Returns:
- Unique identifier for this service
-