* @throws RemoteLockException
*/
private void createSession(SipServletRequestImpl req,
SipApplicationSessionImpl appSess, String handlerName,
URI subscriberURI) {
SipSessionImplBase s = (SipSessionImplBase) req.getSessionImpl();
if (s == null) {
// check if we are spiraling: look up early dialog
String id = DialogSet.createKey(req.getCallId(),
req.getFromImpl().getParameter(AddressImpl.TAG_PARAM));
DialogSet existingDs = DialogSet.getEarlyDialog(id);
if (existingDs != null) {
// spiraling indeed!
req.setDialog(existingDs.createAdditionalDialogFragment());
} else {
// not spiraling
// creates a new sip session and dialog structure
DialogSet ds = new DialogSet(req.getMethod(), req.getCallId(), req.getFromImpl(),
req.getBeKey(), SipFactoryImpl.isDialogCreational(req.getMethod()));
req.setDialog(ds.getInitialDialogFragment());
DialogSet.registerEarlyDialog(req);
}
}
// creates a new sip session
DialogFragment d = req.getDialog();
s = m_SipSessionManager.createSipSession(d.getDialogSet(), req.getToImpl(),
appSess, handlerName);
// Initial request from outside the container.
// So, swap the local-remote.
s.swapLocalRemote();
if (handlerName != null && !handlerName.equals("")) {
TargettedRequestHandler.linkCorrespondingSession(req, s);
}
s.setSubscriberURI(subscriberURI);
req.setSession(s);
final DialogLifeCycle dialogLifeCycle = d.getDialogLifeCycle();
dialogLifeCycle.associateTransaction(req.getTransactionId());