FileDocCategorySizeDatePackage
SessionMessageImpl.javaAPI DocApache Tomcat 6.0.145668Fri Jul 20 04:20:36 BST 2007org.apache.catalina.ha.session

SessionMessageImpl

public class SessionMessageImpl extends org.apache.catalina.ha.ClusterMessageBase implements SessionMessage, Serializable
Session cluster message
author
Filip Hanik
author
Peter Rossbach
version
$Revision: 531471 $ $Date: 2007-04-23 16:11:44 +0200 (lun., 23 avr. 2007) $

Fields Summary
private int
mEvtType
private byte[]
mSession
private String
mSessionID
private String
mContextName
private long
serializationTimestamp
private boolean
timestampSet
private String
uniqueId
Constructors Summary
public SessionMessageImpl()

    
private SessionMessageImpl(String contextName, int eventtype, byte[] session, String sessionID)



       
                            
                            
                            
    
        mEvtType = eventtype;
        mSession = session;
        mSessionID = sessionID;
        mContextName = contextName;
        uniqueId = sessionID;
    
public SessionMessageImpl(String contextName, int eventtype, byte[] session, String sessionID, String uniqueID)
Creates a session message. Depending on what event type you want this message to represent, you populate the different parameters in the constructor
The following rules apply dependent on what event type argument you use:
EVT_SESSION_CREATED
The parameters: session, sessionID must be set.
EVT_SESSION_EXPIRED
The parameters: sessionID must be set.
EVT_SESSION_ACCESSED
The parameters: sessionID must be set.
EVT_SESSION_EXPIRED_XXXX
The parameters: sessionID must be set.
EVT_SESSION_DELTA
Send attribute delta (add,update,remove attribute or principal, ...).
EVT_ALL_SESSION_DATA
Send complete serializes session list
EVT_ALL_SESSION_TRANSFERCOMPLETE
send that all session state information are transfered after GET_ALL_SESSION received from this sender.

param
contextName - the name of the context (application
param
eventtype - one of the 8 event type defined in this class
param
session - the serialized byte array of the session itself
param
sessionID - the id that identifies this session
param
uniqueID - the id that identifies this message

        this(contextName,eventtype,session,sessionID);
        uniqueId = uniqueID;
    
Methods Summary
public java.lang.StringgetContextName()

       return mContextName;
    
public intgetEventType()
returns the event type

return
one of the event types EVT_XXXX

 return mEvtType; 
public java.lang.StringgetEventTypeString()
clear text event type name (for logging purpose only)

return
the event type in a string representating, useful for debugging

        switch (mEvtType)
        {
            case EVT_SESSION_CREATED : return "SESSION-MODIFIED";
            case EVT_SESSION_EXPIRED : return "SESSION-EXPIRED";
            case EVT_SESSION_ACCESSED : return "SESSION-ACCESSED";
            case EVT_GET_ALL_SESSIONS : return "SESSION-GET-ALL";
            case EVT_SESSION_DELTA : return "SESSION-DELTA";
            case EVT_ALL_SESSION_DATA : return "ALL-SESSION-DATA";
            case EVT_ALL_SESSION_TRANSFERCOMPLETE : return "SESSION-STATE-TRANSFERED";
            default : return "UNKNOWN-EVENT-TYPE";
        }
    
public byte[]getSession()

return
the serialized data for the session

 return mSession;
public java.lang.StringgetSessionID()

return
the session ID for the session

 return mSessionID; 
public longgetTimestamp()

 return serializationTimestamp;
public java.lang.StringgetUniqueId()

        return uniqueId;
    
public voidsetTimestamp(long time)
set message send time but only the first setting works (one shot)

        synchronized(this) {
            if(!timestampSet) {
                serializationTimestamp=time;
                timestampSet = true ;
            }
        }
    
public voidsetUniqueId(java.lang.String uniqueId)

        this.uniqueId = uniqueId;
    
public java.lang.StringtoString()

        return getEventTypeString() + "#" + getContextName() + "#" + getSessionID() ;