org.jboss.web.tomcat.service.session
Class FieldBasedClusteredSipSession

java.lang.Object
  extended by org.mobicents.servlet.sip.core.session.SipSessionImpl
      extended by org.jboss.web.tomcat.service.session.ClusteredSipSession
          extended by org.jboss.web.tomcat.service.session.JBossCacheClusteredSipSession
              extended by org.jboss.web.tomcat.service.session.FieldBasedClusteredSipSession
All Implemented Interfaces:
java.io.Externalizable, java.io.Serializable, SipSession, org.jboss.aspects.patterns.observable.Observer, MobicentsSipSession

public class FieldBasedClusteredSipSession
extends JBossCacheClusteredSipSession
implements org.jboss.aspects.patterns.observable.Observer

Implementation of a clustered sip session for the JBossCacheManager. This class is based on the following Jboss class org.jboss.web.tomcat.service.session.FieldBasedClusteredSession JBOSS AS 4.2.2 Tag The replication granularity level is field based; that is, we replicate only the dirty field in a POJO that is part of a session attribute. E.g., once a user do setAttribute("pojo", pojo), pojo will be monitored automatically for field changes and accessing. It offers couple of advantages:

Note that in current version, all the attributes and its associated childre graph objects are required to be aspectized. That is, you can't simply declare them as Serializable. This is restricted because of the marshalling/unmarshalling issue.

We use JBossCache for our internal, replicated data store. The internal structure is like in JBossCache:

 /SIPSESSION
    /hostname
       /sip_application_name    (path + session id is unique)
          /sipappsessionid    Map(id, session)
                          (VERSION_KEY, version)  // Used for version tracking. version is an Integer.
                /sipsessionid   Map(id, session)
                    (VERSION_KEY, version)  // Used for version tracking. version is an Integer.
                                /ATTRIBUTE    Map(can be empty)
                                        /pojo      Map(field name, field value) (pojo naming is by field.getName())

 

Author:
Ben Wang, Brian Stansberry, Jean Deruelle
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class org.mobicents.servlet.sip.core.session.SipSessionImpl
SipSessionImpl.SipSessionEventType
 
Nested classes/interfaces inherited from interface javax.servlet.sip.SipSession
SipSession.State
 
Field Summary
protected  java.util.Map attributes_
           
protected static java.lang.String info
          Descriptive information describing this Session implementation.
 
Fields inherited from class org.jboss.web.tomcat.service.session.JBossCacheClusteredSipSession
proxy_
 
Fields inherited from class org.jboss.web.tomcat.service.session.ClusteredSipSession
alwaysReplicateMetadata, excludedAttributes, firstAccess, hasActivationListener, invalidationPolicy, isSessionModifiedSinceLastSave, lastReplicated, maxUnreplicatedFactor, maxUnreplicatedInterval, outdatedTime, outdatedVersion, replicationExcludes, sessionAttributesDirty, sessionMetadataDirty, sipAppSessionParentKey, sm, version
 
Fields inherited from class org.mobicents.servlet.sip.core.session.SipSessionImpl
b2buaHelper, creationTime, derivedSipSessions, executorService, handlerServlet, invalidateWhenReady, isValid, key, lastAccessedTime, localParty, okToByeSentOrReceived, ongoingTransactions, originalTransaction, outboundInterface, parentSession, proxy, readyToInvalidate, remoteParty, routingRegion, sessionCreatingDialog, sessionCreatingTransaction, sipApplicationSession, sipFactory, sipSessionAttributeMap, state, stateInfo, subscriberURI, subscriptions, userPrincipal
 
Constructor Summary
protected FieldBasedClusteredSipSession(SipSessionKey key, SipFactoryImpl sipFactoryImpl, MobicentsSipApplicationSession mobicentsSipApplicationSession)
           
 
Method Summary
protected  boolean canAttributeBeReplicated(java.lang.Object attribute)
          Overrides the superclass to allow instrumented classes and non-serializable Collections and Maps.
 void fireChange(org.jboss.aspects.patterns.observable.Subject subject)
          Call back handler for the aop Subject/Observer pattern.
protected  java.lang.Object getJBossInternalAttribute(java.lang.String name)
           
protected  java.util.Map getJBossInternalAttributes()
           
protected  java.util.Set getJBossInternalKeys()
           
protected  boolean isMutable(java.lang.Object attribute)
          Overrides the superclass to treat classes implementing Subject as "immutable", since as an Observer we will detect any changes to those types.
protected  java.lang.String[] keys()
          Method inherited from Tomcat.
protected  void populateAttributes()
          Populate the attributes stored in the distributed store to the local transient map.
protected  java.lang.Object removeJBossInternalAttribute(java.lang.String name, boolean localCall, boolean localOnly)
           
 void removeMyself()
          Remove myself from the internal store.
 void removeMyselfLocal()
          Remove myself from the local internal store.
protected  java.lang.Object setJBossInternalAttribute(java.lang.String key, java.lang.Object value)
          This is the hook for setAttribute.
 java.lang.String toString()
          Return a string representation of this object.
 
Methods inherited from class org.jboss.web.tomcat.service.session.JBossCacheClusteredSipSession
establishProxy, initAfterLoad, processSessionRepl, removeAttributeInternal, removeFromManager, removeJBossInternalAttribute
 
Methods inherited from class org.jboss.web.tomcat.service.session.ClusteredSipSession
access, activate, clearOutdated, expire, expire, getAttribute, getAttributeInternal, getAttributeNames, getAttributesInternal, getExceedsMaxUnreplicatedInterval, getLastReplicated, getMaxUnreplicatedFactor, getMaxUnreplicatedInterval, getReplicateSessionBody, getSessionAttributesDirty, getSessionMetadataDirty, getUseJK, getVersion, incrementVersion, isGetDirty, isNewData, isOutdated, isSessionDirty, isValid, isValid, passivate, readExternal, removeAttributeInternal, removeAttributeInternal, removeExcludedAttributes, sessionAttributesDirty, sessionDirty, sessionMetadataDirty, setAttribute, setInternalAttribute, setIsOutdated, setMaxUnreplicatedFactor, setMaxUnreplicatedInterval, setOutdatedVersion, setPrincipal, setVersion, updateAccessTimeFromOutdatedTime, updateLastReplicated, writeExternal
 
Methods inherited from class org.mobicents.servlet.sip.core.session.SipSessionImpl
addDerivedSipSessions, addOngoingTransaction, addSubscription, createRequest, findDerivedSipSession, getApplicationSession, getB2buaHelper, getCallId, getCreationTime, getDerivedSipSessions, getExecutorService, getHandler, getId, getInvalidateWhenReady, getKey, getLastAccessedTime, getLocalParty, getOngoingTransactions, getOutboundInterface, getProxy, getRegion, getRegionInternal, getRemoteParty, getServletContext, getSessionCreatingDialog, getSessionCreatingTransaction, getSipApplicationSession, getSipSessionAttributeMap, getSipSubscriberURI, getState, getStateInfo, getSubscriberURI, getUserPrincipal, hasOngoingTransaction, invalidate, isReadyToInvalidate, isSupervisedMode, onDialogTimeout, onReadyToInvalidate, onTerminatedState, removeAttribute, removeDerivedSipSession, removeOngoingTransaction, removeSubscription, setB2buaHelper, setHandler, setInvalidateWhenReady, setKey, setLocalParty, setOutboundInterface, setOutboundInterface, setParentSession, setProxy, setRemoteParty, setRoutingRegion, setSessionCreatingDialog, setSessionCreatingTransaction, setSipApplicationSession, setSipSessionAttributeMap, setSipSubscriberURI, setState, setStateInfo, setUserPrincipal, updateStateOnResponse, updateStateOnSubsequentRequest
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

info

protected static final java.lang.String info
Descriptive information describing this Session implementation.

See Also:
Constant Field Values

attributes_

protected transient java.util.Map attributes_
Constructor Detail

FieldBasedClusteredSipSession

protected FieldBasedClusteredSipSession(SipSessionKey key,
                                        SipFactoryImpl sipFactoryImpl,
                                        MobicentsSipApplicationSession mobicentsSipApplicationSession)
Method Detail

toString

public java.lang.String toString()
Return a string representation of this object.

Overrides:
toString in class ClusteredSipSession

removeMyself

public void removeMyself()
Description copied from class: ClusteredSipSession
Remove myself from the internal store.

Specified by:
removeMyself in class ClusteredSipSession

removeMyselfLocal

public void removeMyselfLocal()
Description copied from class: ClusteredSipSession
Remove myself from the local internal store.

Specified by:
removeMyselfLocal in class ClusteredSipSession

populateAttributes

protected void populateAttributes()
Populate the attributes stored in the distributed store to the local transient map. Add ourself as an Observer to newly found attributes and remove ourself as an Observer to existing attributes that are no longer in the distributed store.

Specified by:
populateAttributes in class JBossCacheClusteredSipSession

getJBossInternalAttribute

protected java.lang.Object getJBossInternalAttribute(java.lang.String name)
Specified by:
getJBossInternalAttribute in class ClusteredSipSession

isMutable

protected boolean isMutable(java.lang.Object attribute)
Overrides the superclass to treat classes implementing Subject as "immutable", since as an Observer we will detect any changes to those types.

Overrides:
isMutable in class ClusteredSipSession

removeJBossInternalAttribute

protected java.lang.Object removeJBossInternalAttribute(java.lang.String name,
                                                        boolean localCall,
                                                        boolean localOnly)
Specified by:
removeJBossInternalAttribute in class JBossCacheClusteredSipSession

getJBossInternalAttributes

protected java.util.Map getJBossInternalAttributes()
Specified by:
getJBossInternalAttributes in class ClusteredSipSession

getJBossInternalKeys

protected java.util.Set getJBossInternalKeys()

keys

protected java.lang.String[] keys()
Method inherited from Tomcat. Return zero-length based string if not found.

Overrides:
keys in class ClusteredSipSession

canAttributeBeReplicated

protected boolean canAttributeBeReplicated(java.lang.Object attribute)
Overrides the superclass to allow instrumented classes and non-serializable Collections and Maps.

Overrides:
canAttributeBeReplicated in class ClusteredSipSession
Parameters:
attribute - the attribute
Returns:
true if attribute is null, Serializable or an array of primitives.

setJBossInternalAttribute

protected java.lang.Object setJBossInternalAttribute(java.lang.String key,
                                                     java.lang.Object value)
This is the hook for setAttribute. Note that in this FieldBasedClusteredSession using aop, user should not call setAttribute call too often since this will re-connect the attribute with the internal cache (and this is expensive).

Specified by:
setJBossInternalAttribute in class ClusteredSipSession
Parameters:
key -
value -
Returns:
Object

fireChange

public void fireChange(org.jboss.aspects.patterns.observable.Subject subject)
Call back handler for the aop Subject/Observer pattern. We subscribe to the event of field write and mark ourself dirty.

Specified by:
fireChange in interface org.jboss.aspects.patterns.observable.Observer
Parameters:
subject - the object we are Observing


Copyright © 2008. All Rights Reserved.