org.mobicents.servlet.sip.core.session
Class SipApplicationSessionImpl

java.lang.Object
  extended by org.mobicents.servlet.sip.core.session.SipApplicationSessionImpl
All Implemented Interfaces:
SipApplicationSession, SipApplicationSessionExt, MobicentsSipApplicationSession

public class SipApplicationSessionImpl
extends java.lang.Object
implements MobicentsSipApplicationSession

Implementation of the SipApplicationSession interface. An instance of this sip application session can only be retrieved through the Session Manager (extended class from Tomcat's manager classes implementing the Manager interface) to constrain the creation of sip application session and to make sure that all sessions created can be retrieved only through the session manager

As a SipApplicationSession represents a call (that can contain multiple call legs, in the B2BUA case by example), the call id and the app name are used as a unique key for a given SipApplicationSession instance.

Author:
Jean Deruelle

Nested Class Summary
 
Nested classes/interfaces inherited from interface javax.servlet.sip.SipApplicationSession
SipApplicationSession.Protocol
 
Field Summary
protected  long creationTime
           
protected  java.lang.String currentRequestHandler
           
protected  long expirationTime
           
protected  SipApplicationSessionTimerTask expirationTimerTask
           
protected  boolean expired
           
protected  MobicentsSipApplicationSessionFacade facade
           
protected  java.util.Set<java.lang.String> httpSessions
           
protected  boolean invalidateWhenReady
           
protected  boolean isValid
           
protected  java.util.concurrent.atomic.AtomicBoolean isValidInternal
           
protected  java.lang.String jvmRoute
           
protected  SipApplicationSessionKey key
           
protected  long lastAccessedTime
           
protected  boolean readyToInvalidate
           
protected  java.util.concurrent.Semaphore semaphore
           
protected  java.util.concurrent.ConcurrentHashMap<java.lang.String,ServletTimer> servletTimers
           
protected  java.util.Map<java.lang.String,java.lang.Object> sipApplicationSessionAttributeMap
           
protected  long sipApplicationSessionTimeout
           
protected  SipContext sipContext
          The first sip application for subsequent requests.
protected  java.util.Set<SipSessionKey> sipSessions
           
 
Fields inherited from interface org.mobicents.servlet.sip.core.session.MobicentsSipApplicationSession
SIP_APPLICATION_KEY_PARAM_NAME
 
Constructor Summary
protected SipApplicationSessionImpl(SipApplicationSessionKey key, SipContext sipContext)
           
 
Method Summary
 void access()
          Update the accessed time information for this session.
 void activate()
          Perform internal processing required to activate this session.
 boolean addHttpSession(javax.servlet.http.HttpSession httpSession)
           
 void addServletTimer(ServletTimer servletTimer)
          Add a servlet timer to this application session
 boolean addSipSession(MobicentsSipSession mobicentsSipSession)
           
 void encodeURI(URI uri)
          
 java.net.URL encodeURL(java.net.URL url)
           Adds a get parameter to the URL like this: http://hostname/link -> http://hostname/link?org.mobicents.servlet.sip.ApplicationSessionKey=0 http://hostname/link?something=1 -> http://hostname/link?something=1&org.mobicents.servlet.sip.ApplicationSessionKey=0
 boolean equals(java.lang.Object obj)
           
 javax.servlet.http.HttpSession findHttpSession(java.lang.String sessionId)
           
 java.lang.String getApplicationName()
           
 java.lang.Object getAttribute(java.lang.String name)
          
protected  java.util.Map<java.lang.String,java.lang.Object> getAttributeMap()
           
 java.util.Iterator<java.lang.String> getAttributeNames()
           
 long getCreationTime()
           
 java.lang.String getCurrentRequestHandler()
           
 long getExpirationTime()
           
 long getExpirationTimeInternal()
           
 SipApplicationSessionTimerTask getExpirationTimerTask()
           
protected  java.util.Set<javax.servlet.http.HttpSession> getHttpSessions()
           
 java.lang.String getId()
          
 boolean getInvalidateWhenReady()
           
 java.lang.String getJvmRoute()
           
 SipApplicationSessionKey getKey()
           
 long getLastAccessedTime()
           
 java.util.concurrent.Semaphore getSemaphore()
           
 MobicentsSipApplicationSessionFacade getSession()
           
 java.lang.Object getSession(java.lang.String id, SipApplicationSession.Protocol protocol)
          
 java.util.Iterator<?> getSessions()
           
 java.util.Iterator<?> getSessions(java.lang.String protocol)
           
 SipContext getSipContext()
           
 SipSession getSipSession(java.lang.String id)
           
 java.util.Set<MobicentsSipSession> getSipSessions()
           
 ServletTimer getTimer(java.lang.String id)
           
 java.util.Collection<ServletTimer> getTimers()
           
 int hashCode()
           
 boolean hasTimerListener()
           
 void invalidate()
           
 void invalidate(boolean bypassCheck)
           
 boolean isExpired()
           
 boolean isReadyToInvalidate()
           
 boolean isValid()
           
 boolean isValidInternal()
           
 void notifySipApplicationSessionListeners(SipApplicationSessionEventType sipApplicationSessionEventType)
          Notifies the listeners that a lifecycle event occured on that sip application session
 void onSipSessionReadyToInvalidate(MobicentsSipSession mobicentsSipSession)
           
 void passivate()
          Perform the internal processing required to passivate this session.
 void removeAttribute(java.lang.String name)
           
 void removeAttribute(java.lang.String name, boolean byPassValidCheck)
           
 boolean removeHttpSession(javax.servlet.http.HttpSession httpSession)
           
 void removeServletTimer(ServletTimer servletTimer)
          Remove a servlet timer from this application session
 SipSessionKey removeSipSession(MobicentsSipSession mobicentsSipSession)
           
 void scheduleAsynchronousWork(SipApplicationSessionAsynchronousWork work)
           
 void setAttribute(java.lang.String key, java.lang.Object attribute)
           
 void setCurrentRequestHandler(java.lang.String currentRequestHandler)
           
 void setExpirationTimerTask(SipApplicationSessionTimerTask expirationTimerTask)
           
 void setExpired(boolean hasExpired)
           
 int setExpires(int deltaMinutes)
           
 void setInvalidateWhenReady(boolean invalidateWhenReady)
           
 void setJvmRoute(java.lang.String jvmRoute)
           
 void setKey(SipApplicationSessionKey key)
           
protected  void setLastAccessedTime(long lastAccessTime)
           
protected  void setValid(boolean isValid)
           
 java.lang.String toString()
           
 void tryToInvalidate()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

sipApplicationSessionAttributeMap

protected java.util.Map<java.lang.String,java.lang.Object> sipApplicationSessionAttributeMap

sipSessions

protected transient java.util.Set<SipSessionKey> sipSessions

httpSessions

protected transient java.util.Set<java.lang.String> httpSessions

key

protected SipApplicationSessionKey key

lastAccessedTime

protected long lastAccessedTime

creationTime

protected long creationTime

expirationTime

protected long expirationTime

expired

protected boolean expired

expirationTimerTask

protected transient SipApplicationSessionTimerTask expirationTimerTask

servletTimers

protected transient java.util.concurrent.ConcurrentHashMap<java.lang.String,ServletTimer> servletTimers

isValidInternal

protected transient java.util.concurrent.atomic.AtomicBoolean isValidInternal

isValid

protected transient boolean isValid

invalidateWhenReady

protected boolean invalidateWhenReady

readyToInvalidate

protected boolean readyToInvalidate

sipContext

protected transient SipContext sipContext
The first sip application for subsequent requests.


currentRequestHandler

protected java.lang.String currentRequestHandler

semaphore

protected transient java.util.concurrent.Semaphore semaphore

facade

protected transient MobicentsSipApplicationSessionFacade facade

sipApplicationSessionTimeout

protected long sipApplicationSessionTimeout

jvmRoute

protected java.lang.String jvmRoute
Constructor Detail

SipApplicationSessionImpl

protected SipApplicationSessionImpl(SipApplicationSessionKey key,
                                    SipContext sipContext)
Method Detail

getAttributeMap

protected java.util.Map<java.lang.String,java.lang.Object> getAttributeMap()

notifySipApplicationSessionListeners

public void notifySipApplicationSessionListeners(SipApplicationSessionEventType sipApplicationSessionEventType)
Notifies the listeners that a lifecycle event occured on that sip application session

Specified by:
notifySipApplicationSessionListeners in interface MobicentsSipApplicationSession
Parameters:
sipApplicationSessionEventType - the type of event that happened

addSipSession

public boolean addSipSession(MobicentsSipSession mobicentsSipSession)
Specified by:
addSipSession in interface MobicentsSipApplicationSession

removeSipSession

public SipSessionKey removeSipSession(MobicentsSipSession mobicentsSipSession)

addHttpSession

public boolean addHttpSession(javax.servlet.http.HttpSession httpSession)
Specified by:
addHttpSession in interface MobicentsSipApplicationSession

removeHttpSession

public boolean removeHttpSession(javax.servlet.http.HttpSession httpSession)
Specified by:
removeHttpSession in interface MobicentsSipApplicationSession

findHttpSession

public javax.servlet.http.HttpSession findHttpSession(java.lang.String sessionId)
Specified by:
findHttpSession in interface MobicentsSipApplicationSession

encodeURI

public void encodeURI(URI uri)

Specified by:
encodeURI in interface SipApplicationSession

encodeURL

public java.net.URL encodeURL(java.net.URL url)
Adds a get parameter to the URL like this: http://hostname/link -> http://hostname/link?org.mobicents.servlet.sip.ApplicationSessionKey=0 http://hostname/link?something=1 -> http://hostname/link?something=1&org.mobicents.servlet.sip.ApplicationSessionKey=0

Specified by:
encodeURL in interface SipApplicationSession

getAttribute

public java.lang.Object getAttribute(java.lang.String name)

Specified by:
getAttribute in interface SipApplicationSession

getAttributeNames

public java.util.Iterator<java.lang.String> getAttributeNames()
Specified by:
getAttributeNames in interface SipApplicationSession

getCreationTime

public long getCreationTime()
Specified by:
getCreationTime in interface SipApplicationSession

getExpirationTime

public long getExpirationTime()
Specified by:
getExpirationTime in interface SipApplicationSession

getId

public java.lang.String getId()

Specified by:
getId in interface SipApplicationSession

getLastAccessedTime

public long getLastAccessedTime()
Specified by:
getLastAccessedTime in interface SipApplicationSession

setLastAccessedTime

protected void setLastAccessedTime(long lastAccessTime)

access

public void access()
Update the accessed time information for this session. This method should be called by the context when a request comes in for a particular session, even if the application does not reference it.

Specified by:
access in interface MobicentsSipApplicationSession

getSessions

public java.util.Iterator<?> getSessions()
Specified by:
getSessions in interface SipApplicationSession

getSessions

public java.util.Iterator<?> getSessions(java.lang.String protocol)
Specified by:
getSessions in interface SipApplicationSession

getSipSessions

public java.util.Set<MobicentsSipSession> getSipSessions()
Specified by:
getSipSessions in interface MobicentsSipApplicationSession

getHttpSessions

protected java.util.Set<javax.servlet.http.HttpSession> getHttpSessions()

getSipSession

public SipSession getSipSession(java.lang.String id)
Specified by:
getSipSession in interface SipApplicationSession

getTimers

public java.util.Collection<ServletTimer> getTimers()
Specified by:
getTimers in interface SipApplicationSession

addServletTimer

public void addServletTimer(ServletTimer servletTimer)
Add a servlet timer to this application session

Specified by:
addServletTimer in interface MobicentsSipApplicationSession
Parameters:
servletTimer - the servlet timer to add

removeServletTimer

public void removeServletTimer(ServletTimer servletTimer)
Remove a servlet timer from this application session

Specified by:
removeServletTimer in interface MobicentsSipApplicationSession
Parameters:
servletTimer - the servlet timer to remove

invalidate

public void invalidate()
Specified by:
invalidate in interface SipApplicationSession

invalidate

public void invalidate(boolean bypassCheck)

isValid

public boolean isValid()
Specified by:
isValid in interface SipApplicationSession

isValidInternal

public boolean isValidInternal()
Specified by:
isValidInternal in interface MobicentsSipApplicationSession

setValid

protected void setValid(boolean isValid)
Parameters:
isValid - the isValid to set

removeAttribute

public void removeAttribute(java.lang.String name)
Specified by:
removeAttribute in interface SipApplicationSession

removeAttribute

public void removeAttribute(java.lang.String name,
                            boolean byPassValidCheck)

setAttribute

public void setAttribute(java.lang.String key,
                         java.lang.Object attribute)
Specified by:
setAttribute in interface SipApplicationSession

setExpires

public int setExpires(int deltaMinutes)
Specified by:
setExpires in interface SipApplicationSession

hasTimerListener

public boolean hasTimerListener()
Specified by:
hasTimerListener in interface MobicentsSipApplicationSession

getSipContext

public SipContext getSipContext()
Specified by:
getSipContext in interface MobicentsSipApplicationSession

getKey

public SipApplicationSessionKey getKey()
Specified by:
getKey in interface MobicentsSipApplicationSession
Returns:
the key

setKey

public void setKey(SipApplicationSessionKey key)
Parameters:
key - the key to set

getApplicationName

public java.lang.String getApplicationName()
Specified by:
getApplicationName in interface SipApplicationSession

getTimer

public ServletTimer getTimer(java.lang.String id)
Specified by:
getTimer in interface SipApplicationSession

passivate

public void passivate()
Perform the internal processing required to passivate this session.


activate

public void activate()
Perform internal processing required to activate this session.


getInvalidateWhenReady

public boolean getInvalidateWhenReady()
Specified by:
getInvalidateWhenReady in interface SipApplicationSession

getSession

public java.lang.Object getSession(java.lang.String id,
                                   SipApplicationSession.Protocol protocol)

Specified by:
getSession in interface SipApplicationSession

isReadyToInvalidate

public boolean isReadyToInvalidate()
Specified by:
isReadyToInvalidate in interface SipApplicationSession

setInvalidateWhenReady

public void setInvalidateWhenReady(boolean invalidateWhenReady)
Specified by:
setInvalidateWhenReady in interface SipApplicationSession

onSipSessionReadyToInvalidate

public void onSipSessionReadyToInvalidate(MobicentsSipSession mobicentsSipSession)
Specified by:
onSipSessionReadyToInvalidate in interface MobicentsSipApplicationSession

tryToInvalidate

public void tryToInvalidate()
Specified by:
tryToInvalidate in interface MobicentsSipApplicationSession

isExpired

public boolean isExpired()
Specified by:
isExpired in interface MobicentsSipApplicationSession
Returns:
the expired

setCurrentRequestHandler

public void setCurrentRequestHandler(java.lang.String currentRequestHandler)
Specified by:
setCurrentRequestHandler in interface MobicentsSipApplicationSession
Parameters:
currentServletHandler - the currentServletHandler to set

getCurrentRequestHandler

public java.lang.String getCurrentRequestHandler()
Specified by:
getCurrentRequestHandler in interface MobicentsSipApplicationSession
Returns:
the currentServletHandler

getSemaphore

public java.util.concurrent.Semaphore getSemaphore()
Specified by:
getSemaphore in interface MobicentsSipApplicationSession
Returns:
the semaphore

getSession

public MobicentsSipApplicationSessionFacade getSession()
Specified by:
getSession in interface MobicentsSipApplicationSession

getJvmRoute

public java.lang.String getJvmRoute()
Specified by:
getJvmRoute in interface MobicentsSipApplicationSession

setJvmRoute

public void setJvmRoute(java.lang.String jvmRoute)
Specified by:
setJvmRoute in interface MobicentsSipApplicationSession

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

setExpirationTimerTask

public void setExpirationTimerTask(SipApplicationSessionTimerTask expirationTimerTask)
Specified by:
setExpirationTimerTask in interface MobicentsSipApplicationSession

getExpirationTimerTask

public SipApplicationSessionTimerTask getExpirationTimerTask()
Specified by:
getExpirationTimerTask in interface MobicentsSipApplicationSession

setExpired

public void setExpired(boolean hasExpired)
Specified by:
setExpired in interface MobicentsSipApplicationSession

getExpirationTimeInternal

public long getExpirationTimeInternal()
Specified by:
getExpirationTimeInternal in interface MobicentsSipApplicationSession

scheduleAsynchronousWork

public void scheduleAsynchronousWork(SipApplicationSessionAsynchronousWork work)
Specified by:
scheduleAsynchronousWork in interface SipApplicationSessionExt


Copyright © 2010. All Rights Reserved.