Response Filtering
JSR-359 defines annotations for filtering responses. The defined annotations are @ProvisionalResponse, @SuccessResponse, @RedirectResponse, and @ErrorResponse. These annotations use the SIP meta-annotation @SipResponseRange to specify the response code range.
Table 3-1 lists the Response annotations and their associated response ranges.
Table 3-1 Response Range Annotations
| Annotation | Response Range Begin | Response Range End | 
|---|---|---|
| 
                               @ProvisionalResponse  | 
                           
                               101  | 
                           
                               199  | 
                        
| 
                               @SuccessResponse  | 
                           
                               200  | 
                           
                               299  | 
                        
| 
                               @RedirectResponse  | 
                           
                               300  | 
                           
                               399  | 
                        
| 
                               @ErrorResponse  | 
                           
                               400  | 
                           
                               699  | 
                        
Example 3-2 shows the usage of a response range annotation.
Example 3-2 Response Range Annotation
@SuccessResponse
public void handleSuccessResponse(SipServletResponse response) {
  //...
}
To further filter responses, a POJO may combine both a method specific annotation and a Response Filter annotation. Example 3-3 shows how to handle success responses for INVITE messages.
Example 3-3 Combining Annotations
@Invite @SuccessResponse
public void handleInviteSuccessResponse(SipServletResponse response) {
  //...
}
It is also possible to specify multiple response filter annotations to a Java method, allowing application developers to handle multiple ranges using the same annotation. Example 3-4 shows how to handle multiple response ranges.
Example 3-4 Multiple Response Range Annotations
@Invite @ProvisionalResponse @SuccessResponse
public void handleInviteSuccessResponse(SipServletResponse response) {
  //...
}@BranchResponse Annotation
An application can use the built-in SipPredicate, @BranchResponse, to associate an intermediate final response that arrives on a ProxyBranch with a Java method in a SIP Servlet POJO.
Example 3-5 shows the @BranchResponse definition.
Example 3-5 @BranchResponse Definition
@Retention(RUNTIME)
@Target({METHOD})
@SipPredicate(BranchResponse.Predicate.class)
public @interface BranchResponse {
  class Predicate implements
  javax.servlet.sip.Predicate<SipServletResponse> {
    @Override
    public boolean apply(final SipServletResponse response) {
      return response.isBranchResponse();
    }
  }