if (isInitial(request))
{
request.setInitial(true);
SipApplicationRouterInfo routerInfo = null;
SipAppContext appContext = null;
try
{
if (route != null)
{
SipURI uri = (SipURI) route.getURI();
if (RouterInfoUtil.ROUTER_INFO.equals(uri.getUser()))
{
routerInfo = RouterInfoUtil.decode(uri);
route = popLocalRoute(request);
}
if (route != null)
request.setPoppedRoute(route);
}
if (routerInfo == null)
{
routerInfo = ((Server) getServer()).getApplicationRouter().getNextApplication(
request, null, SipApplicationRoutingDirective.NEW, null, null);
}
}
catch (Throwable t)
{
if (!request.isAck())
{
SipResponse response = new SipResponse(
request,
SipServletResponse.SC_SERVER_INTERNAL_ERROR,
"Application router error: " + t.getMessage());
ExceptionUtil.fillStackTrace(response, t);
getConnectorManager().sendResponse(response);
}
return;
}
if (routerInfo != null && routerInfo.getNextApplicationName() != null)
{
boolean handle = handlingRoute(request, routerInfo);
if (handle)
return;
request.setStateInfo(routerInfo.getStateInfo());
request.setRegion(routerInfo.getRoutingRegion());
String s = routerInfo.getSubscriberURI();
if (s != null)
{
try
{
request.setSubscriberURI(URIFactory.parseURI(s));
}
catch (ServletParseException e)
{
Log.debug(e);
}
}
String applicationName = routerInfo.getNextApplicationName();
appContext = (SipAppContext) getContext(applicationName);
Method method = appContext == null ? null : appContext.getSipApplicationKeyMethod();
if (method != null)
{
try
{
String sessionKey = (String) method.invoke(null, request);