Jive Messenger 2.2.2 Javadoc

org.jivesoftware.messenger.disco
Class IQDiscoItemsHandler

java.lang.Object
  extended by org.jivesoftware.messenger.container.BasicModule
      extended by org.jivesoftware.messenger.handler.IQHandler
          extended by org.jivesoftware.messenger.disco.IQDiscoItemsHandler
All Implemented Interfaces:
ChannelHandler, Module, ServerFeaturesProvider

public class IQDiscoItemsHandler
extends IQHandler
implements ServerFeaturesProvider

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
 
Fields inherited from class org.jivesoftware.messenger.handler.IQHandler
deliverer, sessionManager
 
Constructor Summary
IQDiscoItemsHandler()
           
 
Method Summary
 void addComponentItem(String jid, String name)
          Registers a new disco item for a component.
 Iterator 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.
 IQ handleIQ(IQ packet)
          Handles the received IQ packet.
 void initialize(XMPPServer server)
          Initializes the basic module.
 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 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.messenger.handler.IQHandler
process
 
Methods inherited from class org.jivesoftware.messenger.container.BasicModule
destroy, getName, stop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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 IQ handleIQ(IQ packet)
            throws UnauthorizedException
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.
Throws:
UnauthorizedException - if the user that sent the packet is not authorized to request the given operation.

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.

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.

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 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.

Jive Messenger 2.2.2 Javadoc

Copyright © 1999-2004 Jive Software.