Wildfire 3.2.4 Javadoc

org.jivesoftware.wildfire.disco
Class IQDiscoItemsHandler

java.lang.Object
  extended by org.jivesoftware.wildfire.container.BasicModule
      extended by org.jivesoftware.wildfire.handler.IQHandler
          extended by org.jivesoftware.wildfire.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.wildfire.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.
 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 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.wildfire.handler.IQHandler
process
 
Methods inherited from class org.jivesoftware.wildfire.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)
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.

Wildfire 3.2.4 Javadoc

Copyright © 2003-2007 Jive Software.