FileDocCategorySizeDatePackage
ClusterSessionListener.javaAPI DocApache Tomcat 6.0.143981Fri Jul 20 04:20:34 BST 2007org.apache.catalina.ha.session

ClusterSessionListener

public class ClusterSessionListener extends ClusterListener
Receive replicated SessionMessage form other cluster node.
author
Filip Hanik
author
Peter Rossbach
version
$Revision: 467222 $ $Date: 2006-10-24 05:17:11 +0200 (mar., 24 oct. 2006) $

Fields Summary
protected static final String
info
The descriptive information about this implementation.
Constructors Summary
public ClusterSessionListener()


    //--Constructor---------------------------------------------

      
    
Methods Summary
public booleanaccept(org.apache.catalina.ha.ClusterMessage msg)
Accept only SessionMessage

param
msg ClusterMessage
return
boolean - returns true to indicate that messageReceived should be invoked. If false is returned, the messageReceived method will not be invoked.

        return (msg instanceof SessionMessage);
    
public java.lang.StringgetInfo()
Return descriptive information about this implementation.


        return (info);

    
public voidmessageReceived(org.apache.catalina.ha.ClusterMessage myobj)
Callback from the cluster, when a message is received, The cluster will broadcast it invoking the messageReceived on the receiver.

param
myobj ClusterMessage - the message received from the cluster

        if (myobj != null && myobj instanceof SessionMessage) {
            SessionMessage msg = (SessionMessage) myobj;
            String ctxname = msg.getContextName();
            //check if the message is a EVT_GET_ALL_SESSIONS,
            //if so, wait until we are fully started up
            Map managers = cluster.getManagers() ;
            if (ctxname == null) {
                java.util.Iterator i = managers.keySet().iterator();
                while (i.hasNext()) {
                    String key = (String) i.next();
                    ClusterManager mgr = (ClusterManager) managers.get(key);
                    if (mgr != null)
                        mgr.messageDataReceived(msg);
                    else {
                        //this happens a lot before the system has started
                        // up
                        if (log.isDebugEnabled())
                            log.debug("Context manager doesn't exist:"
                                    + key);
                    }
                }
            } else {
                ClusterManager mgr = (ClusterManager) managers.get(ctxname);
                if (mgr != null)
                    mgr.messageDataReceived(msg);
                else if (log.isWarnEnabled())
                    log.warn("Context manager doesn't exist:" + ctxname);
            }
        }
        return;