Overview | Package | Class | Tree | Deprecated | Index | Help
| Openfire 3.9.3 Javadoc
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.jivesoftware.openfire.handler
Class PresenceUpdateHandler

    java.lang.Object
      org.jivesoftware.openfire.container.BasicModule
          org.jivesoftware.openfire.handler.PresenceUpdateHandler

All Implemented Interfaces:
  ChannelHandler, ClusterEventListener, Module

    public class PresenceUpdateHandler

extends BasicModule
implements ChannelHandler, ClusterEventListener

Implements the presence protocol. Clients use this protocol to update presence and roster information.

The handler must properly detect the presence type, update the user's roster, and inform presence subscribers of the session's updated presence status. Presence serves many purposes in Jabber so this handler will likely be the most complex of all handlers in the server.

There are four basic types of presence updates:

- Simple presence updates - addressed to the server (or to address), these updates are properly addressed by the server, and multicast to interested subscribers on the user's roster. An empty, missing, or "unavailable" type attribute indicates a simple update (there is no "available" type although it should be accepted by the server.
- Directed presence updates - addressed to particular jabber entities, these presence updates are properly addressed and directly delivered to the entity without broadcast to roster subscribers. Any update type is possible except those reserved for subscription requests.
- Subscription requests - these updates request presence subscription status changes. Such requests always affect the roster. The server must:
  - update the roster with the proper subscriber info
  - push the roster changes to the user
  - forward the update to the correct parties.
  The valid types include "subscribe", "subscribed", "unsubscribed", and "unsubscribe".
- XMPPServer probes - Provides a mechanism for servers to query the presence status of users on another server. This allows users to immediately know the presence status of users when they come online rather than way for a presence update broadcast from the other server or tracking them as they are received. Requires S2S capabilities.

Author:
  Iain Shigeoka

Field Summary
`static String` | `PRESENCE_CACHE_NAME`

Constructor Summary
`PresenceUpdateHandler()`

Method Summary
`org.xmpp.packet.Presence` | `createSubscribePresence(org.xmpp.packet.JID senderAddress, org.xmpp.packet.JID targetJID, boolean isSubscribe)`
`void` | `directedPresenceSent(org.xmpp.packet.Presence update, org.xmpp.packet.JID handlerJID, String jid)` Notification method sent to this handler when a user has sent a directed presence to an entity.
`boolean` | `hasDirectPresence(org.xmpp.packet.JID ownerJID, org.xmpp.packet.JID recipientJID)`
`void` | `initialize(XMPPServer server)` Initializes the basic module.
`void` | `joinedCluster()` Notification event indicating that this JVM is now part of a cluster.
`void` | `joinedCluster(byte[] nodeID)` Notification event indicating that another JVM is now part of a cluster.
`void` | `leftCluster()` Notification event indicating that this JVM is no longer part of the cluster.
`void` | `leftCluster(byte[] nodeID)` Notification event indicating that another JVM is no longer part of the cluster.
`void` | `markedAsSeniorClusterMember()` Notification event indicating that this JVM is now the senior cluster member.
`void` | `process(org.xmpp.packet.Packet packet)` Process an XMPP packet.
`void` | `process(org.xmpp.packet.Presence presence)` Handle presence updates that affect roster subscriptions.
`void` | `removedExpiredPresences()` Removes directed presences sent to entities that are no longer available.

Methods inherited from class org.jivesoftware.openfire.container.BasicModule
`destroy, getName, start, stop`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### PRESENCE_CACHE_NAME

    public static final String PRESENCE_CACHE_NAME

See Also:
  Constant Field Values

Constructor Detail

### PresenceUpdateHandler

    public PresenceUpdateHandler()

Method Detail

### process

    public void process(org.xmpp.packet.Packet packet)
                 throws UnauthorizedException,
                        PacketException

  Description copied from interface: `ChannelHandler`
  Process an XMPP packet.

  Specified by:
    `process` in interface `ChannelHandler`
  Parameters:
    `packet` - a packet to process.
  Throws:
    `UnauthorizedException` - if not allowed to process the packet.
    `PacketException` - thrown if the packet is malformed (results in the sender's session being shutdown).

### process

    public void process(org.xmpp.packet.Presence presence)
                 throws PacketException

  Handle presence updates that affect roster subscriptions.

  Parameters:
    `presence` - The presence presence to handle
  Throws:
    `PacketException` - if the packet is null or the packet could not be routed.

### createSubscribePresence

    public org.xmpp.packet.Presence createSubscribePresence(org.xmpp.packet.JID senderAddress,
                                                            org.xmpp.packet.JID targetJID,
                                                            boolean isSubscribe)

### directedPresenceSent

    public void directedPresenceSent(org.xmpp.packet.Presence update,
                                     org.xmpp.packet.JID handlerJID,
                                     String jid)

  Notification method sent to this handler when a user has sent a directed presence to an entity. If the sender of the presence is local (to this server) and the target entity does not belong to the user's roster then update the registry of sent directed presences by the user.

  Parameters:
    `update` - the directed Presence sent by the user to an entity.
    `handlerJID` - the JID of the handler that will receive/handle/process the sent packet.
    `jid` - the receipient specified in the packet to handle.

### hasDirectPresence

    public boolean hasDirectPresence(org.xmpp.packet.JID ownerJID,
                                     org.xmpp.packet.JID recipientJID)

### removedExpiredPresences

    public void removedExpiredPresences()

  Removes directed presences sent to entities that are no longer available.

### initialize

    public void initialize(XMPPServer server)

  Description copied from class: `BasicModule`

  Initializes the basic module.

  Inheriting classes that choose to override this method MUST call this initialize() method before accessing BasicModule resources.

  Specified by:
    `initialize` in interface `Module`
  Overrides:
    `initialize` in class `BasicModule`
  Parameters:
    `server` - the server hosting this module.

### joinedCluster

    public void joinedCluster()

  Description copied from interface: `ClusterEventListener`
  Notification event indicating that this JVM is now part of a cluster. At this point the `XMPPServer.getNodeID()` holds the new nodeID value.

  When joining the cluster as the senior cluster member the `ClusterEventListener.markedAsSeniorClusterMember()` event will be sent right after this event.

  At this point the CacheFactory holds clustered caches. That means that modifications to the caches will be reflected in the cluster. The clustered caches were just obtained from the cluster and no local cached data was automatically moved.

  Specified by:
    `joinedCluster` in interface `ClusterEventListener`

### joinedCluster

    public void joinedCluster(byte[] nodeID)

  Description copied from interface: `ClusterEventListener`
  Notification event indicating that another JVM is now part of a cluster.

  At this point the CacheFactory of the new node holds clustered caches. That means that modifications to the caches of this JVM will be reflected in the cluster and in particular in the new node.

  Specified by:
    `joinedCluster` in interface `ClusterEventListener`
  Parameters:
    `nodeID` - ID of the node that joined the cluster.

### leftCluster

    public void leftCluster()

  Description copied from interface: `ClusterEventListener`
  Notification event indicating that this JVM is no longer part of the cluster. This could happen when disabling clustering support, removing the enterprise plugin that provides clustering support or connection to cluster got lost.

  Moreover, if we were in a "split brain" scenario (ie. separated cluster islands) and the island were this JVM belonged was marked as "old" then all nodes of that island will get the `left cluster event` and `joined cluster events`. That means that caches will be reset and thus will need to be repopulated again with fresh data from this JVM. This also includes the case where this JVM was the senior cluster member and when the islands met again then this JVM stopped being the senior member.

  At this point the CacheFactory holds local caches. That means that modifications to the caches will only affect this JVM.

  Specified by:
    `leftCluster` in interface `ClusterEventListener`

### leftCluster

    public void leftCluster(byte[] nodeID)

  Description copied from interface: `ClusterEventListener`
  Notification event indicating that another JVM is no longer part of the cluster. This could happen when disabling clustering support, removing the enterprise plugin that provides clustering support or connection to cluster got lost.

  Moreover, if we were in a "split brain" scenario (ie. separated cluster islands) and the island were the other JVM belonged was marked as "old" then all nodes of that island will get the `left cluster event` and `joined cluster events`. That means that caches will be reset and thus will need to be repopulated again with fresh data from this JVM. This also includes the case where the other JVM was the senior cluster member and when the islands met again then the other JVM stopped being the senior member.

  At this point the CacheFactory of the leaving node holds local caches. That means that modifications to the caches of this JVM will not affect the leaving node but other cluster members.

  Specified by:
    `leftCluster` in interface `ClusterEventListener`
  Parameters:
    `nodeID` - ID of the node that is left the cluster.

### markedAsSeniorClusterMember

    public void markedAsSeniorClusterMember()

  Description copied from interface: `ClusterEventListener`
  Notification event indicating that this JVM is now the senior cluster member. This could either happen when initially joining the cluster or when the senior cluster member node left the cluster and this JVM was marked as the new senior cluster member.

  Moreover, in the case of a "split brain" scenario (ie. separated cluster islands) each island will have its own senior cluster member. However, when the islands meet again there could only be one senior cluster member so one of the senior cluster members will stop playing that role. When that happens the JVM no longer playing that role will receive the `ClusterEventListener.leftCluster()` and `ClusterEventListener.joinedCluster()` events.

  Specified by:
    `markedAsSeniorClusterMember` in interface `ClusterEventListener`

Overview | Package | Class | Tree | Deprecated | Index | Help
| Openfire 3.9.3 Javadoc
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2003-2008 Jive Software.