private static RoutingState checkRoutingState ( SipServletRequestImpl sipServletRequest , Dialog dialog ) { // 2. Ongoing Transaction Detection - Employ methods of Section 17.2.3 in RFC 3261 //to see if the request matches an existing transaction. //If it does, stop. The request is not an initial request. if ( dialog != null && DialogState . CONFIRMED . equals ( dialog . getState ( ) ) ) { if ( logger . isDebugEnabled ( ) ) { logger . debug ( "checkRoutingState - dialog not null and dialog state is CONFIRMED" ) ; } return RoutingState . SUBSEQUENT ; } // 3. Examine Request Method. If it is CANCEL, BYE, PRACK or ACK, stop. //The request is not an initial request for which application selection occurs. if ( NON_INITIAL_SIP_REQUEST_METHODS . contains ( sipServletRequest . getMethod ( ) ) ) { if ( logger . isDebugEnabled ( ) ) { logger . debug ( "checkRoutingState - sipServletRequest.getMethod() is element of NON_INITIAL_SIP_REQUEST_METHODS, sipServletRequest.getMethod()=" + sipServletRequest . getMethod ( ) ) ; } return RoutingState . SUBSEQUENT ; } // 4. Existing Dialog Detection - If the request has a tag in the To header field, // the container computes the dialog identifier (as specified in section 12 of RFC 3261) // corresponding to the request and compares it with existing dialogs. // If it matches an existing dialog, stop. The request is not an initial request. // The request is a subsequent request and must be routed to the application path // associated with the existing dialog. // If the request has a tag in the To header field, // but the dialog identifier does not match any existing dialogs, // the container must reject the request with a 481 (Call/Transaction Does Not Exist). // Note: When this occurs, RFC 3261 says either the UAS has crashed or the request was misrouted. // In the latter case, the misrouted request is best handled by rejecting the request. // For the Sip Servlet environment, a UAS crash may mean either an application crashed // or the container itself crashed. In either case, it is impossible to route the request // as a subsequent request and it is inappropriate to route it as an initial request. // Therefore, the only viable approach is to reject the request. if ( dialog != null && ! DialogState . EARLY . equals ( dialog . getState ( ) ) ) { if ( logger . isDebugEnabled ( ) ) { logger . debug ( "checkRoutingState - dialog not null and dialog state is not EARLY" ) ; } return RoutingState . SUBSEQUENT ; } // 6. Detection of Requests Sent to Encoded URIs - // Requests may be sent to a container instance addressed to a URI obtained by calling // the encodeURI() method of a SipApplicationSession managed by this container instance. // When a container receives such a request, stop. This request is not an initial request. // Refer to section 15.11.1 Session Targeting and Application Selection //for more information on how a request sent to an encoded URI is handled by the container. //This part will be done in routeIntialRequest since this is where the Session Targeting retrieval is done return RoutingState . INITIAL ; }
Method checking whether or not the sip servlet request in parameter is initial according to algorithm defined in JSR289 Appendix B