public void asynchronousDelivery(
     HttpRequest request, HttpResponse response, Response jaxrsResponse) {
   try {
     pushContextObjects(request, response);
     try {
       if (jaxrsResponse != null) writeJaxrsResponse(request, response, jaxrsResponse);
     } catch (Exception e) {
       handleWriteResponseException(request, response, e);
     }
   } finally {
     clearContextData();
   }
 }
 /**
  * Propagate NotFoundException. This is used for Filters
  *
  * @param request
  * @param response
  */
 public void invokePropagateNotFound(HttpRequest request, HttpResponse response)
     throws NotFoundException {
   try {
     pushContextObjects(request, response);
     try {
       Response aborted = preprocess(request);
       if (aborted != null) {
         try {
           writeJaxrsResponse(request, response, aborted);
         } catch (Exception e) {
           handleWriteResponseException(request, response, e);
           return;
         }
         return;
       }
     } catch (Exception e) {
       handleException(request, response, e);
       return;
     }
     ResourceInvoker invoker = null;
     try {
       invoker = getInvoker(request);
     } catch (Exception failure) {
       if (failure instanceof NotFoundException) {
         throw ((NotFoundException) failure);
       } else {
         handleException(request, response, failure);
         return;
       }
     }
     try {
       invoke(request, response, invoker);
     } catch (Failure e) {
       handleException(request, response, e);
       return;
     }
   } finally {
     clearContextData();
   }
 }
 public void invoke(HttpRequest request, HttpResponse response) {
   try {
     pushContextObjects(request, response);
     Response aborted = preprocess(request);
     if (aborted != null) {
       try {
         writeJaxrsResponse(request, response, aborted);
       } catch (Exception e) {
         handleWriteResponseException(request, response, e);
         return;
       }
       return;
     }
     ResourceInvoker invoker = getInvoker(request);
     invoke(request, response, invoker);
   } catch (Failure e) {
     handleException(request, response, e);
     return;
   } finally {
     clearContextData();
   }
 }
  public Response internalInvocation(HttpRequest request, HttpResponse response, Object entity) {
    // be extra careful in the clean up process. Only pop if there was an
    // equivalent push.
    ResteasyProviderFactory.addContextDataLevel();
    boolean pushedBody = false;
    try {
      MessageBodyParameterInjector.pushBody(entity);
      pushedBody = true;
      ResourceInvoker invoker = getInvoker(request);
      if (invoker != null) {
        pushContextObjects(request, response);
        return getResponse(request, response, invoker);
      }

      // this should never happen, since getInvoker should throw an exception
      // if invoker is null
      return null;
    } finally {
      ResteasyProviderFactory.removeContextDataLevel();
      if (pushedBody) {
        MessageBodyParameterInjector.popBody();
      }
    }
  }