public class IQDiscoInfoHandler extends IQHandler implements ClusterEventListener
For example, let's have in the entities map the following entries: "localhost" and "conference.localhost". Associated with each entry we have different DiscoInfoProviders. Now we receive a disco#info request for the following JID: "room@conference.localhost" which is a disco request for a MUC room. So IQDiscoInfoHandler will look for the DiscoInfoProvider 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 info specific to the JID's name which in this case is "room". Among the information that a room could provide we could find its identity and the features it supports (e.g. 'muc_passwordprotected', 'muc_unmoderated', etc.). Finally, after we have collected all the information provided by the provider we will add it 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.
Modifier and Type | Field and Description |
---|---|
static String |
NAMESPACE_DISCO_INFO |
deliverer, sessionManager
Constructor and Description |
---|
IQDiscoInfoHandler() |
Modifier and Type | Method and Description |
---|---|
void |
addServerFeature(String namespace)
Adds one specific feature to the information returned whenever a disco for information is
made against the server.
|
IQHandlerInfo |
getInfo()
Returns the handler information to help generically handle IQ packets.
|
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.
|
protected void |
removeProvider(String name)
Removes the DiscoInfoProvider related to a given entity.
|
void |
removeServerFeature(String namespace)
Removes a feature from the information returned whenever a disco for information is
made against the server.
|
void |
removeServerNodeInfoProvider(String node)
Removes the DiscoInfoProvider to use when a disco#info packet is sent to the server itself
and the specified node.
|
protected void |
setProvider(String name,
DiscoInfoProvider provider)
Sets that a given DiscoInfoProvider will provide information about a given entity.
|
void |
setServerNodeInfoProvider(String node,
DiscoInfoProvider provider)
Sets the DiscoInfoProvider to use when a disco#info packet is sent to the server itself
and the specified node.
|
destroy, getName, start, stop
public static final String NAMESPACE_DISCO_INFO
public IQHandlerInfo getInfo()
IQHandler
public org.xmpp.packet.IQ handleIQ(org.xmpp.packet.IQ packet)
IQHandler
public void setServerNodeInfoProvider(String node, DiscoInfoProvider provider)
node
- the node that the provider will handle.provider
- the DiscoInfoProvider that will handle disco#info packets sent with the
specified node.public void removeServerNodeInfoProvider(String node)
node
- the node that the provider was handling.protected void setProvider(String name, DiscoInfoProvider provider)
name
- the name of the entity.provider
- the DiscoInfoProvider that will provide the entity's information.protected void removeProvider(String name)
name
- the name of the entity.public void addServerFeature(String namespace)
namespace
- the namespace identifying the new server feature.public void removeServerFeature(String namespace)
namespace
- the namespace of the feature to be removed.public void initialize(XMPPServer server)
BasicModule
Initializes the basic module.
Inheriting classes that choose to override this method MUST call this initialize() method before accessing BasicModule resources.
initialize
in interface Module
initialize
in class IQHandler
server
- the server hosting this module.public void joinedCluster()
ClusterEventListener
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.
joinedCluster
in interface ClusterEventListener
public void joinedCluster(byte[] nodeID)
ClusterEventListener
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.
joinedCluster
in interface ClusterEventListener
nodeID
- ID of the node that joined the cluster.public void leftCluster()
ClusterEventListener
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.
leftCluster
in interface ClusterEventListener
public void leftCluster(byte[] nodeID)
ClusterEventListener
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.
leftCluster
in interface ClusterEventListener
nodeID
- ID of the node that is left the cluster.public void markedAsSeniorClusterMember()
ClusterEventListener
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.
markedAsSeniorClusterMember
in interface ClusterEventListener
Copyright © 2003-2008 Jive Software.