servletssiprestcommmobicents-sip-servletssip-servlet

Differences between SipApplicationSession and servletContext


I'm studying Sip Servlet and there is something that it's not clear to me.

With an application server like mobicents, I could have two type of session:

  1. SipSession: is the session linked to the request/response;
  2. SipApplicationSession: is the session that wrap SipSession and (eventually) HttpSession. This should be used to communicate between the web and sip servlet.

Why should we have the second one? If I call:

getServletContext.setAttribute("something", somethingObject);

is this shared with the two servlets, or am I wrong?

The ServletContext is something that wraps the servlet in an application, and so we can communicate across the servlets.

So why should we use SipApplicationSession?

Thanks for answering.


Solution

  • You're right on the concept behind SIPSession and SIPApplicationSession.

    Think of SIPApplicationSession as a meta-session holding up N SIP Session (and HTTPSession if the application is a convergent SIP and HTTP one and uses them). So the attributes in this can be shared across SIP Sessions if you're building a B2BUA (and also WebSession if you include Web in your application) but it is always limited in time to the context of the SIP Session and HTTP Session lifetime.

    ServletContext however is for the lifetime of the application and completely independent of SIP calls or Web requests so you only want to put attributes there that are meant to live longer than that and that you don't want to persist or store in a DataBase.