title: Calling a method before or after each @POST or @DELETE request in JAX-RS
body: <p>Is there any method or annotation in JAX-RS that allows me to call a method before or after the matching request method is executed. Lets assume I have the following service class:</p>
  
  <pre><code>public class MyService {
  
      ...
  
      @POST
      @Path("{id : \\d+}")
      @Consumes(MediaType.APPLICATION_JSON)
      public Response updateServiceObject(@PathParam("id") long id, InputStream is) {
          try {
              // Fetch the service object ...
              ServiceObject updatedServiceObj = readServiceObject(is);
  
              // ... and try to update it.
              updated = getServiceObjectDao().update(updatedServiceObj);
  
              if (updated == 0) {
                  throw new WebApplicationException(Response.Status.NOT_FOUND);
              }
  
              return Response.ok().build();
          } catch (Exception e) {
              throw new WebApplicationException(Response.Status.BAD_REQUEST);
          }
      }
  
      @DELETE
      @Path("{id : \\d+}")
      public Response deleteServiceObject(@PathParam("id") long id) {
          try {
              getServiceObjectDao().deleteById(id);
          } catch (Exception e) {
              throw new WebApplicationException(Response.Status.BAD_REQUEST);
          }
  
          return Response.ok().build();
      }
  }
  </code></pre>
  
  <p>I would like to add a method <code>logEvent()</code>, which logs which method has been called and which parameters (just @PathParam values) had been provided. So it has to bee invoked before or after each call.</p>