if (targetedRequestInfo != null && targetedRequestInfo.getApplicationName() != null) {
if (theirLog.isLoggable(Level.FINEST)) {
theirLog.log(Level.FINEST, LOGPREFIX + "targeted_request_type",
new Object[] {targetedRequestInfo.getType().name(), targetedRequestInfo.getApplicationName()});
}
return new SipApplicationRouterInfo(targetedRequestInfo.getApplicationName(), region, initialRequest.getRequestURI().toString(), EMPTY_STRING_ARRAY, SipRouteModifier.NO_ROUTE, targetedRequestInfo.getApplicationName());
}
Integer order = new Integer(0);
// Upon first invocation, stateInfo will not yet be set.
if (stateInfo != null){
// only Integer stateInfo supported
try {
order = new Integer(stateInfo.toString());
}
catch (NumberFormatException e){
theirLog.log(Level.SEVERE, LOGPREFIX + "wrongstateinfo");
return null;
}
}
// lookup request method in cache
String method = initialRequest.getMethod();
theirLog.log(Level.INFO, LOGPREFIX + "infolookup", new Object[] { method, order });
// lookup routing info in cache for this method
RouterInfoBean infoBean = null;
HashMap<Integer, RouterInfoBean> infoMap = itsRouterInfoMap.get(method);
if (infoMap == null){
theirLog.log(Level.INFO, LOGPREFIX + "noinfofound", method);
return null; // TODO is this allowed?
} else {
// stateinfo contains the Integer we last put in. Increase the
// Integer by one, lookup the next routing info in cache.
order++;
infoBean = infoMap.get(order);
if (infoBean == null){
theirLog.log(Level.INFO, LOGPREFIX + "noinfofoundforthisorder", new Object[] { method, order });
return null; // TODO is this allowed?
// TODO return appname=null
}
theirLog.log(Level.INFO, LOGPREFIX + "infofound");
}
// Determine subscriber URI
String subId = infoBean.getSubscriberId();
String subUri = null;
if (subId.startsWith("DAR:")) {
// subscriber URI is to be retrieved from request
String header = subId.substring(4).trim();
// (IndexOutOfBounds exception was checked at config-time)
try {
subUri = initialRequest.getAddressHeader(header).getURI().toString();
} catch (ServletParseException e){
theirLog.log(Level.SEVERE, LOGPREFIX + "invalidsubscriberuri", header);
theirLog.log(Level.SEVERE, LOGPREFIX + e.getMessage(), e);
}
}
// Determine route info
String[] routes = new String[] {infoBean.getRouteUri()};
SipRouteModifier modifier =
SipRouteModifier.valueOf(infoBean.getRouteModifier());
// Determine routing region
String regionOutStr = infoBean.getRegion();
SipApplicationRoutingRegionType regionOutType =
SipApplicationRoutingRegionType.valueOf(regionOutStr);
SipApplicationRoutingRegion regionOut =
new SipApplicationRoutingRegion(regionOutStr, regionOutType);
SipApplicationRouterInfo info =
new SipApplicationRouterInfo(
infoBean.getApplicationName(),
regionOut,
subUri,
routes,
modifier,