Class IQPEPHandler
- All Implemented Interfaces:
ChannelHandler<org.xmpp.packet.IQ>,Module,DiscoInfoProvider,ServerFeaturesProvider,ServerIdentitiesProvider,UserFeaturesProvider,UserIdentitiesProvider,UserItemsProvider,UserEventListener,RosterEventListener,PresenceEventListener
An IQHandler used to implement XEP-0163: "Personal Eventing via Pubsub"
Version 1.0
For each user on the server there is an associated PEPService interacting
with a single PubSubEngine for managing the user's PEP nodes.
An IQHandler can only handle one namespace in its IQHandlerInfo. However, PEP
related packets are seen having a variety of different namespaces. Thus,
classes like IQPEPOwnerHandler are used to forward packets having these other
namespaces to handleIQ(IQ).
This handler is used for the following namespaces:
- http://jabber.org/protocol/pubsub
- http://jabber.org/protocol/pubsub#owner
- Author:
- Armando Jagucki, Guus der Kinderen, guus.der.kinderen@gmail.com
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final SystemProperty<Boolean>Controls if the PEP service is available on this domain.static final SystemProperty<Integer>The number of threads to keep in the thread pool used to send PEP notifications, even if they are idle.static final SystemProperty<Integer>The maximum number of threads to allow in the thread pool used to send PEP notifications.static final SystemProperty<Duration>The number of threads in the thread pool used to send PEP notifications is greater than the core, this is the maximum time that excess idle threads will wait for new tasks before terminating.Fields inherited from class org.jivesoftware.openfire.handler.IQHandler
deliverer, sessionManager -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanaddingContact(Roster roster, RosterItem item, boolean persistent) Notification message indicating that a contact is about to be added to a roster.voidaddSubscriptionForRosterItems(PEPService pepService) Populates the PEPService instance with subscriptions.voidavailableSession(ClientSession session, org.xmpp.packet.Presence presence) Notification message indicating that a session that was not available is now available.voidcontactAdded(Roster roster, RosterItem item) Notification message indicating that a contact has been added to a roster.voidcontactDeleted(Roster roster, RosterItem item) Notification message indicating that a contact has been deleted from a roster.voidcontactUpdated(Roster roster, RosterItem item) Notification message indicating that a contact has been updated.voiddestroy()Destroys the module.Set<org.xmpp.forms.DataForm>getExtendedInfos(String name, String node, org.xmpp.packet.JID senderJID) Returns a collection of XDataForm with the extended information about the entity or an empty collection if none.Implements ServerFeaturesProvider to include all supported XEP-0060 features in the server's disco#info result (as per section 4 of XEP-0163).getFeatures(String name, String node, org.xmpp.packet.JID senderJID) Returns an Iterator (of String) with the supported features.Iterator<org.dom4j.Element>Implements ServerIdentitiesProvider and UserIdentitiesProvider, adding the PEP identity to the respective disco#info results.Iterator<org.dom4j.Element>getIdentities(String name, String node, org.xmpp.packet.JID senderJID) Returns an Iterator (of Element) with the target entity's identities.getInfo()Returns the handler information to help generically handle IQ packets.Iterator<org.dom4j.Element>getUserItems(String name, org.xmpp.packet.JID senderJID) Implements UserItemsProvider, adding PEP related items to a disco#items result.org.xmpp.packet.IQhandleIQ(org.xmpp.packet.IQ packet) Handles the received IQ packet.booleanReturns true if we can provide information related to the requested name and node.voidinitialize(XMPPServer server) Initializes the basic module.voidpresenceChanged(ClientSession session, org.xmpp.packet.Presence presence) Notification message indicating that an available session has changed its presence.voidrosterLoaded(Roster roster) Notification message indicating that a roster has just been loaded.voidstart()Starts the basic module.voidstop()Stops the basic module.voidsubscribedToPresence(org.xmpp.packet.JID subscriberJID, org.xmpp.packet.JID authorizerJID) Notification message indicating that a user has successfully subscribed to the presence of another user.voidunavailableSession(ClientSession session, org.xmpp.packet.Presence presence) The following functions are unimplemented required interface methods.voidunsubscribedToPresence(org.xmpp.packet.JID unsubscriberJID, org.xmpp.packet.JID recipientJID) Notification message indicating that a user has unsubscribed to the presence of another user.voiduserCreated(User user, Map<String, Object> params) A user was created.voiduserDeleting(User user, Map<String, Object> params) A user is being deleted.voiduserModified(User user, Map<String, Object> params) A user's name, email, or an extended property was changed.Methods inherited from class org.jivesoftware.openfire.handler.IQHandler
performNoSuchUserCheck, process, processNoSuchUserCheckMethods inherited from class org.jivesoftware.openfire.container.BasicModule
getName
-
Field Details
-
ENABLED
Controls if the PEP service is available on this domain. -
EXECUTOR_CORE_POOL_SIZE
The number of threads to keep in the thread pool used to send PEP notifications, even if they are idle. -
EXECUTOR_MAX_POOL_SIZE
The maximum number of threads to allow in the thread pool used to send PEP notifications. -
EXECUTOR_POOL_KEEP_ALIVE
The number of threads in the thread pool used to send PEP notifications is greater than the core, this is the maximum time that excess idle threads will wait for new tasks before terminating.
-
-
Constructor Details
-
IQPEPHandler
public IQPEPHandler()Constructs a newIQPEPHandlerinstance.
-
-
Method Details
-
initialize
Description copied from class:BasicModuleInitializes the basic module.
Inheriting classes that choose to override this method MUST call this initialize() method before accessing BasicModule resources.
- Specified by:
initializein interfaceModule- Overrides:
initializein classIQHandler- Parameters:
server- the server hosting this module.
-
getServiceManager
-
destroy
public void destroy()Description copied from class:BasicModuleDestroys the module.
Does nothing in the basic module.
- Specified by:
destroyin interfaceModule- Overrides:
destroyin classBasicModule
-
start
public void start()Description copied from class:BasicModuleStarts the basic module.
Inheriting classes that choose to override this method MUST call this start() method before accessing BasicModule resources.
- Specified by:
startin interfaceModule- Overrides:
startin classBasicModule
-
stop
public void stop()Description copied from class:BasicModuleStops the basic module.
Inheriting classes that choose to override this method MUST call this stop() method before accessing BasicModule resources.
- Specified by:
stopin interfaceModule- Overrides:
stopin classBasicModule
-
getInfo
Description copied from class:IQHandlerReturns the handler information to help generically handle IQ packets. IQHandlers that aren't local server iq handlers (e.g. chatbots, transports, etc) returnnull. -
getIdentities
Implements ServerIdentitiesProvider and UserIdentitiesProvider, adding the PEP identity to the respective disco#info results.- Specified by:
getIdentitiesin interfaceServerIdentitiesProvider- Specified by:
getIdentitiesin interfaceUserIdentitiesProvider- Returns:
- an Iterator (of Element) with identities of protocols supported by the server.
-
getFeatures
Implements ServerFeaturesProvider to include all supported XEP-0060 features in the server's disco#info result (as per section 4 of XEP-0163).- Specified by:
getFeaturesin interfaceServerFeaturesProvider- Specified by:
getFeaturesin interfaceUserFeaturesProvider- Returns:
- an Iterator (of String) with the supported features by the server.
-
handleIQ
public org.xmpp.packet.IQ handleIQ(org.xmpp.packet.IQ packet) Description copied from class:IQHandlerHandles the received IQ packet. -
addSubscriptionForRosterItems
Populates the PEPService instance with subscriptions. The subscriptions that are added to the PEPService are based on the roster of the owner of the PEPService: every entity that's subscribed to the presence of the owner, is added as a subscriber of the PEPService. This method adds, but does not remove of update existing subscriptions.- Parameters:
pepService- The PEPService to be populated with subscriptions.
-
getUserItems
Implements UserItemsProvider, adding PEP related items to a disco#items result.- Specified by:
getUserItemsin interfaceUserItemsProvider- Parameters:
name- the recipient JID's name.senderJID- the XMPPAddress of user that sent the disco items request.- Returns:
- an Iterator (of Element) with the target entity's items or null if none.
-
subscribedToPresence
public void subscribedToPresence(org.xmpp.packet.JID subscriberJID, org.xmpp.packet.JID authorizerJID) Description copied from interface:PresenceEventListenerNotification message indicating that a user has successfully subscribed to the presence of another user.- Specified by:
subscribedToPresencein interfacePresenceEventListener- Parameters:
subscriberJID- the user that initiated the subscription.authorizerJID- the user that authorized the subscription.
-
unsubscribedToPresence
public void unsubscribedToPresence(org.xmpp.packet.JID unsubscriberJID, org.xmpp.packet.JID recipientJID) Description copied from interface:PresenceEventListenerNotification message indicating that a user has unsubscribed to the presence of another user.- Specified by:
unsubscribedToPresencein interfacePresenceEventListener- Parameters:
unsubscriberJID- the user that initiated the unsubscribe request.recipientJID- the recipient user of the unsubscribe request.
-
availableSession
Description copied from interface:PresenceEventListenerNotification message indicating that a session that was not available is now available. A session becomes available when an available presence is received. Sessions that are available will have a route in the routing table thus becoming eligible for receiving messages (in particular messages sent to the user bare JID).- Specified by:
availableSessionin interfacePresenceEventListener- Parameters:
session- the session that is now available.presence- the received available presence.
-
contactDeleted
Description copied from interface:RosterEventListenerNotification message indicating that a contact has been deleted from a roster.- Specified by:
contactDeletedin interfaceRosterEventListener- Parameters:
roster- the roster that was updated.item- the roster item that was deleted.
-
userDeleting
Description copied from interface:UserEventListenerA user is being deleted.- Specified by:
userDeletingin interfaceUserEventListener- Parameters:
user- the user.params- event parameters.
-
presenceChanged
Description copied from interface:PresenceEventListenerNotification message indicating that an available session has changed its presence. This is the case when the user presence changed the show value (e.g. away, dnd, etc.) or the presence status message.- Specified by:
presenceChangedin interfacePresenceEventListener- Parameters:
session- the affected session.presence- the received available presence with the new information.
-
addingContact
Description copied from interface:RosterEventListenerNotification message indicating that a contact is about to be added to a roster. New contacts may be persisted to the database or not. Listeners may indicate that contact about to be persisted should not be persisted. Only one listener is needed to returnfalseso that the contact is not persisted.- Specified by:
addingContactin interfaceRosterEventListener- Parameters:
roster- the roster that was updated.item- the new roster item.persistent- true if the new contact is going to be saved to the database.- Returns:
- false if the contact should not be persisted to the database.
-
contactAdded
Description copied from interface:RosterEventListenerNotification message indicating that a contact has been added to a roster.- Specified by:
contactAddedin interfaceRosterEventListener- Parameters:
roster- the roster that was updated.item- the new roster item.
-
contactUpdated
Description copied from interface:RosterEventListenerNotification message indicating that a contact has been updated.- Specified by:
contactUpdatedin interfaceRosterEventListener- Parameters:
roster- the roster that was updated.item- the updated roster item.
-
rosterLoaded
Description copied from interface:RosterEventListenerNotification message indicating that a roster has just been loaded.- Specified by:
rosterLoadedin interfaceRosterEventListener- Parameters:
roster- the loaded roster.
-
userCreated
Description copied from interface:UserEventListenerA user was created.- Specified by:
userCreatedin interfaceUserEventListener- Parameters:
user- the user.params- event parameters.
-
userModified
Description copied from interface:UserEventListenerA user's name, email, or an extended property was changed.- Specified by:
userModifiedin interfaceUserEventListener- Parameters:
user- the user.params- event parameters.
-
getIdentities
public Iterator<org.dom4j.Element> getIdentities(String name, String node, org.xmpp.packet.JID senderJID) Description copied from interface:DiscoInfoProviderReturns an Iterator (of Element) with the target entity's identities. Each Element must include the category, type and name attributes of the entity.- Specified by:
getIdentitiesin interfaceDiscoInfoProvider- Parameters:
name- the recipient JID's name.node- the requested disco node.senderJID- the XMPPAddress of user that sent the disco info request.- Returns:
- an Iterator (of Element) with the target entity's identities.
-
getFeatures
Description copied from interface:DiscoInfoProviderReturns an Iterator (of String) with the supported features. The features to include are the features offered and supported protocols by the target entity identified by the requested name and node.- Specified by:
getFeaturesin interfaceDiscoInfoProvider- Parameters:
name- the recipient JID's name.node- the requested disco node.senderJID- the XMPPAddress of user that sent the disco info request.- Returns:
- an Iterator (of String) with the supported features.
-
getExtendedInfos
public Set<org.xmpp.forms.DataForm> getExtendedInfos(String name, String node, org.xmpp.packet.JID senderJID) Description copied from interface:DiscoInfoProviderReturns a collection of XDataForm with the extended information about the entity or an empty collection if none. Each bit of information about the entity must be included as a value of a field of the form.- Specified by:
getExtendedInfosin interfaceDiscoInfoProvider- Parameters:
name- the recipient JID's name.node- the requested disco node.senderJID- the XMPPAddress of user that sent the disco info request.- Returns:
- A collection of XDataForms with the extended information about the entity or an empty collection if none.
-
hasInfo
public boolean hasInfo(String name, String node, org.xmpp.packet.JID senderJID) throws UnauthorizedException Description copied from interface:DiscoInfoProviderReturns true if we can provide information related to the requested name and node. For example, if the requested name refers to a non-existent MUC room then the answer will be false. In case that the sender of the disco request is not authorized to discover this information an UnauthorizedException will be thrown.- Specified by:
hasInfoin interfaceDiscoInfoProvider- Parameters:
name- the recipient JID's name.node- the requested disco node.senderJID- the XMPPAddress of user that sent the disco info request.- Returns:
- true if we can provide information related to the requested name and node.
- Throws:
UnauthorizedException- When senderJID is not authorized to discover information
-