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

## org.jivesoftware.openfire.disco
Class IQDiscoItemsHandler

    java.lang.Object
      org.jivesoftware.openfire.container.BasicModule
          org.jivesoftware.openfire.handler.IQHandler
              org.jivesoftware.openfire.disco.IQDiscoItemsHandler

All Implemented Interfaces:
  ChannelHandler, ClusterEventListener, Module, ServerFeaturesProvider, UserItemsProvider

    public class IQDiscoItemsHandler

extends IQHandler
implements ServerFeaturesProvider, ClusterEventListener, UserItemsProvider

IQDiscoItemsHandler is responsible for handling disco#items requests. This class holds a map with the main entities and the associated DiscoItemsProvider. We are considering the host of the recipient JIDs as main entities. It's the DiscoItemsProvider responsibility to provide the items associated with the JID's name together with any possible requested node.

For example, let's have in the entities map the following entries: "localhost" and "conference.localhost". Associated with each entry we have different DiscoItemsProvider. Now we receive a disco#items request for the following JID: "room@conference.localhost" which is a disco request for a MUC room. So IQDiscoItemsHandler will look for the DiscoItemsProvider associated with the JID's host which in this case is "conference.localhost". Once we have located the provider we will delegate to the provider the responsibility to provide the items specific to the JID's name which in this case is "room". Depending on the implementation, the items could be the list of existing occupants if that information is publicly available. Finally, after we have collected all the items provided by the provider we will add them to the reply. On the other hand, if no provider was found or the provider has no information for the requested name/node then a not-found error will be returned.

Publishing of client items is still not supported.

Author:
  Gaston Dombiak

Field Summary
`static String` | `NAMESPACE_DISCO_ITEMS`

Fields inherited from class org.jivesoftware.openfire.handler.IQHandler
`deliverer, sessionManager`

Constructor Summary
`IQDiscoItemsHandler()`

Method Summary
`void` | `addComponentItem(String jid, String name)` Registers a new disco item for a component.
`void` | `addComponentItem(String jid, String node, String name)` Registers a new disco item for a component.
`void` | `addServerItemsProvider(ServerItemsProvider provider)` Adds the items provided by the new service that implements the ServerItemsProvider interface.
`Iterator<String>` | `getFeatures()` Returns an Iterator (of String) with the supported features by the server.
`IQHandlerInfo` | `getInfo()` Returns the handler information to help generically handle IQ packets.
`Iterator<org.dom4j.Element>` | `getUserItems(String name, org.xmpp.packet.JID senderJID)` Returns an Iterator (of Element) with the target entity's items or null if none.
`org.xmpp.packet.IQ` | `handleIQ(org.xmpp.packet.IQ packet)` Handles the received IQ packet.
`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` | `removeComponentItem(String jid)` Removes a disco item for a component that has been removed from the server.
`protected void` | `removeProvider(String name)` Removes the DiscoItemsProvider related to a given entity.
`void` | `removeServerItemsProvider(ServerItemsProvider provider)` Removes the provided items as a service of the service.
`void` | `removeServerNodeInfoProvider(String node)` Removes the DiscoItemsProvider to use when a disco#items packet is sent to the server itself and the specified node.
`protected void` | `setProvider(String name, DiscoItemsProvider provider)` Sets that a given DiscoItemsProvider will provide the items related to a given entity.
`void` | `setServerNodeInfoProvider(String node, DiscoItemsProvider provider)` Sets the DiscoItemsProvider to use when a disco#items packet is sent to the server itself and the specified node.
`void` | `start()` Starts the basic module.

Methods inherited from class org.jivesoftware.openfire.handler.IQHandler
`process`

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

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

Field Detail

### NAMESPACE_DISCO_ITEMS

    public static final String NAMESPACE_DISCO_ITEMS

See Also:
  Constant Field Values

Constructor Detail

### IQDiscoItemsHandler

    public IQDiscoItemsHandler()

Method Detail

### getInfo

    public IQHandlerInfo getInfo()

  Description copied from class: `IQHandler`
  Returns the handler information to help generically handle IQ packets. IQHandlers that aren't local server iq handlers (e.g. chatbots, transports, etc) return `null`.

  Specified by:
    `getInfo` in class `IQHandler`
  Returns:
    The IQHandlerInfo for this handler

### handleIQ

    public org.xmpp.packet.IQ handleIQ(org.xmpp.packet.IQ packet)

  Description copied from class: `IQHandler`
  Handles the received IQ packet.

  Specified by:
    `handleIQ` in class `IQHandler`
  Parameters:
    `packet` - the IQ packet to handle.
  Returns:
    the response to send back.

### setProvider

    protected void setProvider(String name,
                               DiscoItemsProvider provider)

  Sets that a given DiscoItemsProvider will provide the items related to a given entity. This message must be used when new modules (e.g. MUC) are implemented and need to provide the items related to them.

  Parameters:
    `name` - the name of the entity.
    `provider` - the DiscoItemsProvider that will provide the entity's items.

### removeProvider

    protected void removeProvider(String name)

  Removes the DiscoItemsProvider related to a given entity.

  Parameters:
    `name` - the name of the entity.

### addServerItemsProvider

    public void addServerItemsProvider(ServerItemsProvider provider)

  Adds the items provided by the new service that implements the ServerItemsProvider interface. This information will be used whenever a disco for items is made against the server (i.e. the packet's target is the server). Example of item is: <item jid='conference.localhost' name='Public chatrooms'/>

  Parameters:
    `provider` - the ServerItemsProvider that provides new server items.

### removeServerItemsProvider

    public void removeServerItemsProvider(ServerItemsProvider provider)

  Removes the provided items as a service of the service.

  Parameters:
    `provider` - The provider that is being removed.

### setServerNodeInfoProvider

    public void setServerNodeInfoProvider(String node,
                                          DiscoItemsProvider provider)

  Sets the DiscoItemsProvider to use when a disco#items packet is sent to the server itself and the specified node. For instance, if node matches "http://jabber.org/protocol/offline" then a special DiscoItemsProvider should be use to return information about offline messages.

  Parameters:
    `node` - the node that the provider will handle.
    `provider` - the DiscoItemsProvider that will handle disco#items packets sent with the specified node.

### removeServerNodeInfoProvider

    public void removeServerNodeInfoProvider(String node)

  Removes the DiscoItemsProvider to use when a disco#items packet is sent to the server itself and the specified node.

  Parameters:
    `node` - the node that the provider was handling.

### addComponentItem

    public void addComponentItem(String jid,
                                 String name)

  Registers a new disco item for a component. The jid attribute of the item will match the jid of the component and the name should be the name of the component discovered using disco.

  Parameters:
    `jid` - the jid of the component.
    `name` - the discovered name of the component.

### addComponentItem

    public void addComponentItem(String jid,
                                 String node,
                                 String name)

  Registers a new disco item for a component. The jid attribute of the item will match the jid of the component and the name should be the name of the component discovered using disco.

  Parameters:
    `jid` - the jid of the component.
    `node` - the node that complements the jid address.
    `name` - the discovered name of the component.

### removeComponentItem

    public void removeComponentItem(String jid)

  Removes a disco item for a component that has been removed from the server.

  Parameters:
    `jid` - the jid of the component being removed.

### 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 `IQHandler`
  Parameters:
    `server` - the server hosting this module.

### start

    public void start()
               throws IllegalStateException

  Description copied from class: `BasicModule`

  Starts the basic module.

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

  Specified by:
    `start` in interface `Module`
  Overrides:
    `start` in class `BasicModule`
  Throws:
    `IllegalStateException` - If start is called before initialize successfully returns

### getFeatures

    public Iterator<String> getFeatures()

  Description copied from interface: `ServerFeaturesProvider`
  Returns an Iterator (of String) with the supported features by the server. The features to include are the features offered and supported protocols by the SERVER. The idea is that different modules may provide their features that will ultimately be part of the features offered by the server.

  Specified by:
    `getFeatures` in interface `ServerFeaturesProvider`
  Returns:
    an Iterator (of String) with the supported features by the server.

### 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`

### getUserItems

    public Iterator<org.dom4j.Element> getUserItems(String name,
                                                    org.xmpp.packet.JID senderJID)

  Description copied from interface: `UserItemsProvider`
  Returns an Iterator (of Element) with the target entity's items or null if none. Each Element must include a JID attribute and may include the name and node attributes of the entity. In case that the sender of the disco request is not authorized to discover items an UnauthorizedException will be thrown.

  Specified by:
    `getUserItems` in interface `UserItemsProvider`
  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.

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

Copyright © 2003-2008 Jive Software.