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

java.lang.Object
  extended by org.mobicents.servlet.sip.core.session.SipSessionImpl
All Implemented Interfaces:
SipSession, MobicentsSipSession
Direct Known Subclasses:
ClusteredSipSession

public class SipSessionImpl
extends java.lang.Object
implements MobicentsSipSession

Implementation of the SipSession interface. An instance of this sip 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 session and to make sure that all sessions created can be retrieved only through the session manager

As a SipApplicationSession represents a dialog, the call id and from header URI, from tag, to Header (and to Tag to identify forked requests) are used as a unique key for a given SipSession instance.

Author:
vralev, mranga, Jean Deruelle

Nested Class Summary
protected static class SipSessionImpl.SipSessionEventType
           
 
Nested classes/interfaces inherited from interface javax.servlet.sip.SipSession
SipSession.State
 
Field Summary
protected  B2buaHelperImpl b2buaHelper
           
protected  long creationTime
          Creation time.
protected  java.util.concurrent.ConcurrentHashMap<java.lang.String,MobicentsSipSession> derivedSipSessions
           
protected  ThreadPoolQueueExecutor executorService
           
protected  java.lang.String handlerServlet
          The name of the servlet withing this same app to handle all subsequent requests.
protected  boolean invalidateWhenReady
           
protected  boolean isValid
          Is the session valid.
protected  SipSessionKey key
           
protected  long lastAccessedTime
          Last access time.
protected  Address localParty
           
protected  boolean okToByeSentOrReceived
           
protected  java.util.Set<javax.sip.Transaction> ongoingTransactions
           
protected  javax.sip.Transaction originalTransaction
           
protected  SipURI outboundInterface
          Outbound interface is one of the allowed values in the Servlet Context attribute "javax.servlet.ip.outboundinterfaces" This one is not serialized, it has to be reset by the app on sessionActivated listener method
protected  MobicentsSipSession parentSession
           
protected  ProxyImpl proxy
           
protected  boolean readyToInvalidate
           
protected  Address remoteParty
           
protected  SipApplicationRoutingRegion routingRegion
          Routing region per session/dialog.
protected  javax.sip.Dialog sessionCreatingDialog
          We use this for dialog-related requests.
protected  javax.sip.Transaction sessionCreatingTransaction
          We use this for REGISTER, where a dialog doesn't exist to carry the session info.
protected  MobicentsSipApplicationSession sipApplicationSession
           
protected  SipFactoryImpl sipFactory
           
protected  java.util.Map<java.lang.String,java.lang.Object> sipSessionAttributeMap
           
protected  SipSession.State state
          Current state of the session, one of INTITIAL, EARLY, ESTABLISHED and TERMINATED.
protected  java.io.Serializable stateInfo
          AR state info
protected  URI subscriberURI
          Subscriber URI should be set for outbound sessions, from requests created in the container.
protected  java.util.Set<javax.sip.header.EventHeader> subscriptions
           
protected  java.security.Principal userPrincipal
           
 
Constructor Summary
protected SipSessionImpl(SipSessionKey key, SipFactoryImpl sipFactoryImpl, MobicentsSipApplicationSession mobicentsSipApplicationSession)
           
 
Method Summary
 void access()
          Update the accessed time information for this session.
 void activate()
          Perform internal processing required to activate this session.
 void addDerivedSipSessions(MobicentsSipSession derivedSession)
          Add the derived sip session it will be identified by the To tag from its key
 void addOngoingTransaction(javax.sip.Transaction transaction)
          Add an ongoing tx to the session.
 void addSubscription(SipServletMessageImpl sipServletMessageImpl)
          
 SipServletRequest createRequest(java.lang.String method)
           
 MobicentsSipSession findDerivedSipSession(java.lang.String toTag)
          Find the derived sip session identified by its to tag
 SipApplicationSession getApplicationSession()
           
 java.lang.Object getAttribute(java.lang.String name)
           
 java.util.Enumeration<java.lang.String> getAttributeNames()
           
 B2buaHelperImpl getB2buaHelper()
          
 java.lang.String getCallId()
           
 long getCreationTime()
           
 java.util.Iterator<MobicentsSipSession> getDerivedSipSessions()
          
 ThreadPoolQueueExecutor getExecutorService()
           
 java.lang.String getHandler()
          Retrieve the handler associated with this sip session
 java.lang.String getId()
           
 boolean getInvalidateWhenReady()
           
 SipSessionKey getKey()
          get the internal Mobicents Sip Session Key
 long getLastAccessedTime()
           
 Address getLocalParty()
           
 java.util.Set<javax.sip.Transaction> getOngoingTransactions()
           
 SipURI getOutboundInterface()
           
 ProxyImpl getProxy()
          Retieves the proxy of the sip session if any
 SipApplicationRoutingRegion getRegion()
          
 SipApplicationRoutingRegion getRegionInternal()
          
 Address getRemoteParty()
           
 javax.servlet.ServletContext getServletContext()
          
 javax.sip.Dialog getSessionCreatingDialog()
           
 javax.sip.Transaction getSessionCreatingTransaction()
           
 MobicentsSipApplicationSession getSipApplicationSession()
           
 java.util.Map<java.lang.String,java.lang.Object> getSipSessionAttributeMap()
          
 URI getSipSubscriberURI()
           
 SipSession.State getState()
           
 java.io.Serializable getStateInfo()
           
 URI getSubscriberURI()
          
 java.security.Principal getUserPrincipal()
           
protected  boolean hasOngoingTransaction()
          Removed from the interface in PFD stage so making it protected
 void invalidate()
           
 boolean isReadyToInvalidate()
           
 boolean isSupervisedMode()
           
 boolean isValid()
           
 void onDialogTimeout(javax.sip.Dialog dialog)
           
 void onReadyToInvalidate()
          This method is called immediately when the conditions for read to invalidate session are met
 void onTerminatedState()
           
 void passivate()
          Perform the internal processing required to passivate this session.
 void removeAttribute(java.lang.String name)
           
 MobicentsSipSession removeDerivedSipSession(java.lang.String toTag)
          Removes the derived sip session identified by the To tag in parameter
 void removeOngoingTransaction(javax.sip.Transaction transaction)
          Remove an ongoing tx to the session.
 void removeSubscription(SipServletMessageImpl sipServletMessageImpl)
          
 void setAttribute(java.lang.String key, java.lang.Object attribute)
           
 void setB2buaHelper(B2buaHelperImpl helperImpl)
          
 void setHandler(java.lang.String name)
           
 void setInvalidateWhenReady(boolean arg0)
           
 void setKey(SipSessionKey key)
           
 void setLocalParty(Address localParty)
           
 void setOutboundInterface(java.net.InetAddress inetAddress)
          
 void setOutboundInterface(java.net.InetSocketAddress inetSocketAddress)
          
 void setParentSession(MobicentsSipSession mobicentsSipSession)
          
 void setProxy(ProxyImpl proxy)
          Set the proxy of the sip session
 void setRemoteParty(Address remoteParty)
           
 void setRoutingRegion(SipApplicationRoutingRegion routingRegion)
          This method allows the application to set the region that the application is in with respect to this SipSession
 void setSessionCreatingDialog(javax.sip.Dialog dialog)
           
 void setSessionCreatingTransaction(javax.sip.Transaction sessionCreatingTransaction)
           
protected  void setSipApplicationSession(MobicentsSipApplicationSession sipApplicationSession)
           
 void setSipSessionAttributeMap(java.util.Map<java.lang.String,java.lang.Object> sipSessionAttributeMap)
          
 void setSipSubscriberURI(URI subscriberURI)
           
 void setState(SipSession.State state)
           
 void setStateInfo(java.io.Serializable stateInfo)
           
 void setUserPrincipal(java.security.Principal userPrincipal)
           
 void updateStateOnResponse(SipServletResponseImpl response, boolean receive)
          Update the sip session state upon sending/receiving a response Covers JSR 289 Section 6.2.1 along with updateStateOnRequest method
 void updateStateOnSubsequentRequest(SipServletRequestImpl request, boolean receive)
          Update the sip session state upon sending/receiving a subsequent request Covers JSR 289 Section 6.2.1 along with updateStateOnResponse method
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

sipApplicationSession

protected transient MobicentsSipApplicationSession sipApplicationSession

proxy

protected ProxyImpl proxy

b2buaHelper

protected B2buaHelperImpl b2buaHelper

sipSessionAttributeMap

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

key

protected SipSessionKey key

userPrincipal

protected transient java.security.Principal userPrincipal

executorService

protected transient ThreadPoolQueueExecutor executorService

creationTime

protected long creationTime
Creation time.


lastAccessedTime

protected long lastAccessedTime
Last access time.


routingRegion

protected SipApplicationRoutingRegion routingRegion
Routing region per session/dialog.


stateInfo

protected java.io.Serializable stateInfo
AR state info


state

protected SipSession.State state
Current state of the session, one of INTITIAL, EARLY, ESTABLISHED and TERMINATED.


isValid

protected boolean isValid
Is the session valid.


handlerServlet

protected java.lang.String handlerServlet
The name of the servlet withing this same app to handle all subsequent requests.


subscriberURI

protected URI subscriberURI
Subscriber URI should be set for outbound sessions, from requests created in the container.


outboundInterface

protected transient SipURI outboundInterface
Outbound interface is one of the allowed values in the Servlet Context attribute "javax.servlet.ip.outboundinterfaces" This one is not serialized, it has to be reset by the app on sessionActivated listener method


sessionCreatingDialog

protected javax.sip.Dialog sessionCreatingDialog
We use this for dialog-related requests. In this case the dialog directly corresponds to the session.


sessionCreatingTransaction

protected transient javax.sip.Transaction sessionCreatingTransaction
We use this for REGISTER, where a dialog doesn't exist to carry the session info. In this case the session only spans a single transaction.


ongoingTransactions

protected transient java.util.Set<javax.sip.Transaction> ongoingTransactions

derivedSipSessions

protected transient java.util.concurrent.ConcurrentHashMap<java.lang.String,MobicentsSipSession> derivedSipSessions

sipFactory

protected transient SipFactoryImpl sipFactory

invalidateWhenReady

protected boolean invalidateWhenReady

readyToInvalidate

protected boolean readyToInvalidate

parentSession

protected transient MobicentsSipSession parentSession

localParty

protected transient Address localParty

remoteParty

protected transient Address remoteParty

subscriptions

protected transient java.util.Set<javax.sip.header.EventHeader> subscriptions

originalTransaction

protected transient javax.sip.Transaction originalTransaction

okToByeSentOrReceived

protected transient boolean okToByeSentOrReceived
Constructor Detail

SipSessionImpl

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

createRequest

public SipServletRequest createRequest(java.lang.String method)
Specified by:
createRequest in interface SipSession

getApplicationSession

public SipApplicationSession getApplicationSession()
Specified by:
getApplicationSession in interface SipSession

getAttribute

public java.lang.Object getAttribute(java.lang.String name)
Specified by:
getAttribute in interface SipSession

getAttributeNames

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

getCallId

public java.lang.String getCallId()
Specified by:
getCallId in interface SipSession

getCreationTime

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

getId

public java.lang.String getId()
Specified by:
getId in interface SipSession

getLastAccessedTime

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

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 MobicentsSipSession

getLocalParty

public Address getLocalParty()
Specified by:
getLocalParty in interface SipSession

getRegion

public SipApplicationRoutingRegion getRegion()

Specified by:
getRegion in interface SipSession

getRegionInternal

public SipApplicationRoutingRegion getRegionInternal()

Specified by:
getRegionInternal in interface MobicentsSipSession

setRoutingRegion

public void setRoutingRegion(SipApplicationRoutingRegion routingRegion)
This method allows the application to set the region that the application is in with respect to this SipSession

Specified by:
setRoutingRegion in interface MobicentsSipSession
Parameters:
routingRegion - the region that the application is in

getStateInfo

public java.io.Serializable getStateInfo()
Specified by:
getStateInfo in interface MobicentsSipSession
Returns:
the stateInfo

setStateInfo

public void setStateInfo(java.io.Serializable stateInfo)
Specified by:
setStateInfo in interface MobicentsSipSession
Parameters:
stateInfo - the stateInfo to set

getRemoteParty

public Address getRemoteParty()
Specified by:
getRemoteParty in interface SipSession

getState

public SipSession.State getState()
Specified by:
getState in interface SipSession

getExecutorService

public ThreadPoolQueueExecutor getExecutorService()
Specified by:
getExecutorService in interface MobicentsSipSession

getSubscriberURI

public URI getSubscriberURI()

Specified by:
getSubscriberURI in interface SipSession

invalidate

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

hasOngoingTransaction

protected boolean hasOngoingTransaction()
Removed from the interface in PFD stage so making it protected


isValid

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

removeAttribute

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

setAttribute

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

setHandler

public void setHandler(java.lang.String name)
                throws javax.servlet.ServletException
Specified by:
setHandler in interface SipSession
Throws:
javax.servlet.ServletException

getHandler

public java.lang.String getHandler()
Retrieve the handler associated with this sip session

Specified by:
getHandler in interface MobicentsSipSession
Returns:
the handler associated with this sip session

setSessionCreatingDialog

public void setSessionCreatingDialog(javax.sip.Dialog dialog)
Specified by:
setSessionCreatingDialog in interface MobicentsSipSession
Parameters:
dialog - the dialog to set

getSessionCreatingDialog

public javax.sip.Dialog getSessionCreatingDialog()
Specified by:
getSessionCreatingDialog in interface MobicentsSipSession
Returns:
the dialog

getSipApplicationSession

public MobicentsSipApplicationSession getSipApplicationSession()
Specified by:
getSipApplicationSession in interface MobicentsSipSession

setSipApplicationSession

protected void setSipApplicationSession(MobicentsSipApplicationSession sipApplicationSession)

getSessionCreatingTransaction

public javax.sip.Transaction getSessionCreatingTransaction()
Specified by:
getSessionCreatingTransaction in interface MobicentsSipSession

setSessionCreatingTransaction

public void setSessionCreatingTransaction(javax.sip.Transaction sessionCreatingTransaction)
Specified by:
setSessionCreatingTransaction in interface MobicentsSipSession
Parameters:
sessionCreatingTransaction - the sessionCreatingTransaction to set

isSupervisedMode

public boolean isSupervisedMode()

setSipSubscriberURI

public void setSipSubscriberURI(URI subscriberURI)
Specified by:
setSipSubscriberURI in interface MobicentsSipSession

getSipSubscriberURI

public URI getSipSubscriberURI()
Specified by:
getSipSubscriberURI in interface MobicentsSipSession

getOutboundInterface

public SipURI getOutboundInterface()
Specified by:
getOutboundInterface in interface MobicentsSipSession

onDialogTimeout

public void onDialogTimeout(javax.sip.Dialog dialog)

setState

public void setState(SipSession.State state)
Specified by:
setState in interface MobicentsSipSession

onTerminatedState

public void onTerminatedState()
Specified by:
onTerminatedState in interface MobicentsSipSession

addOngoingTransaction

public void addOngoingTransaction(javax.sip.Transaction transaction)
Add an ongoing tx to the session.

Specified by:
addOngoingTransaction in interface MobicentsSipSession

removeOngoingTransaction

public void removeOngoingTransaction(javax.sip.Transaction transaction)
Remove an ongoing tx to the session.

Specified by:
removeOngoingTransaction in interface MobicentsSipSession

getOngoingTransactions

public java.util.Set<javax.sip.Transaction> getOngoingTransactions()
Specified by:
getOngoingTransactions in interface MobicentsSipSession

updateStateOnResponse

public void updateStateOnResponse(SipServletResponseImpl response,
                                  boolean receive)
Update the sip session state upon sending/receiving a response Covers JSR 289 Section 6.2.1 along with updateStateOnRequest method

Specified by:
updateStateOnResponse in interface MobicentsSipSession
Parameters:
response - the response received/to send
receive - true if the response has been received, false if it is to be sent.

updateStateOnSubsequentRequest

public void updateStateOnSubsequentRequest(SipServletRequestImpl request,
                                           boolean receive)
Update the sip session state upon sending/receiving a subsequent request Covers JSR 289 Section 6.2.1 along with updateStateOnResponse method

Specified by:
updateStateOnSubsequentRequest in interface MobicentsSipSession
Parameters:
request - the subsequent request received/to send
receive - true if the subsequent request has been received, false if it is to be sent.

onReadyToInvalidate

public void onReadyToInvalidate()
This method is called immediately when the conditions for read to invalidate session are met

Specified by:
onReadyToInvalidate in interface MobicentsSipSession

getKey

public SipSessionKey getKey()
Description copied from interface: MobicentsSipSession
get the internal Mobicents Sip Session Key

Specified by:
getKey in interface MobicentsSipSession
Returns:
the key

setKey

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

getProxy

public ProxyImpl getProxy()
Retieves the proxy of the sip session if any

Specified by:
getProxy in interface MobicentsSipSession
Returns:

setProxy

public void setProxy(ProxyImpl proxy)
Set the proxy of the sip session

Specified by:
setProxy in interface MobicentsSipSession

setB2buaHelper

public void setB2buaHelper(B2buaHelperImpl helperImpl)

Specified by:
setB2buaHelper in interface MobicentsSipSession

getB2buaHelper

public B2buaHelperImpl getB2buaHelper()

Specified by:
getB2buaHelper in interface MobicentsSipSession

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.


getUserPrincipal

public java.security.Principal getUserPrincipal()
Specified by:
getUserPrincipal in interface MobicentsSipSession

setUserPrincipal

public void setUserPrincipal(java.security.Principal userPrincipal)
Specified by:
setUserPrincipal in interface MobicentsSipSession

getInvalidateWhenReady

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

isReadyToInvalidate

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

setInvalidateWhenReady

public void setInvalidateWhenReady(boolean arg0)
Specified by:
setInvalidateWhenReady in interface SipSession

setOutboundInterface

public void setOutboundInterface(java.net.InetAddress inetAddress)

Specified by:
setOutboundInterface in interface SipSession

setOutboundInterface

public void setOutboundInterface(java.net.InetSocketAddress inetSocketAddress)

Specified by:
setOutboundInterface in interface SipSession

getServletContext

public javax.servlet.ServletContext getServletContext()

Specified by:
getServletContext in interface SipSession

removeDerivedSipSession

public MobicentsSipSession removeDerivedSipSession(java.lang.String toTag)
Removes the derived sip session identified by the To tag in parameter

Specified by:
removeDerivedSipSession in interface MobicentsSipSession
Parameters:
toTag - the to Tag identifying the sip session to remove
Returns:
the removed derived sip session

findDerivedSipSession

public MobicentsSipSession findDerivedSipSession(java.lang.String toTag)
Find the derived sip session identified by its to tag

Specified by:
findDerivedSipSession in interface MobicentsSipSession
Parameters:
toTag - the to Tag identifying the sip session to remove
Returns:
the derived sip session identified by its to tag or null if none has been found

getDerivedSipSessions

public java.util.Iterator<MobicentsSipSession> getDerivedSipSessions()

Specified by:
getDerivedSipSessions in interface MobicentsSipSession

setParentSession

public void setParentSession(MobicentsSipSession mobicentsSipSession)

Specified by:
setParentSession in interface MobicentsSipSession

setSipSessionAttributeMap

public void setSipSessionAttributeMap(java.util.Map<java.lang.String,java.lang.Object> sipSessionAttributeMap)

Specified by:
setSipSessionAttributeMap in interface MobicentsSipSession

addDerivedSipSessions

public void addDerivedSipSessions(MobicentsSipSession derivedSession)
Add the derived sip session it will be identified by the To tag from its key

Specified by:
addDerivedSipSessions in interface MobicentsSipSession
Parameters:
derivedSession - the derived session to add

getSipSessionAttributeMap

public java.util.Map<java.lang.String,java.lang.Object> getSipSessionAttributeMap()

Specified by:
getSipSessionAttributeMap in interface MobicentsSipSession

setLocalParty

public void setLocalParty(Address localParty)
Specified by:
setLocalParty in interface MobicentsSipSession
Parameters:
localParty - the localParty to set

setRemoteParty

public void setRemoteParty(Address remoteParty)
Specified by:
setRemoteParty in interface MobicentsSipSession
Parameters:
remoteParty - the remoteParty to set

addSubscription

public void addSubscription(SipServletMessageImpl sipServletMessageImpl)
                     throws javax.sip.SipException

Specified by:
addSubscription in interface MobicentsSipSession
Throws:
javax.sip.SipException

removeSubscription

public void removeSubscription(SipServletMessageImpl sipServletMessageImpl)

Specified by:
removeSubscription in interface MobicentsSipSession


Copyright © 2009. All Rights Reserved.