}
String sasId = SipApplicationSessionUtil.createSasId(sipApplicationKey, m_Ctx.getAppName(), null);
// There is a key now look for an existing SAS
SipApplicationSessionImpl ref = null;
try {
ref = m_SipSessionManager.findSipApplicationSession(sasId);
if ((ref != null) && !ref.isValid()) {
m_SipSessionManager.removeSipApplicationSession(ref);
ref = null;
}
} catch (RemoteLockException ex) {
throw new RemoteLockRuntimeException(ex);
}
if (ref != null) { // There is a cached value to be recycled
return ref;
}
// Need to create a new SAS and store it
SipApplicationSessionImpl sas = m_SipSessionManager.createSipApplicationSession(sasId, m_Ctx.getSipApplicationListeners());
sas.setShouldBePersisted(); // on a SAS created by key we want to persist
return sas;
}