java - Calling a method before or after each @POST or @DELETE request in JAX-RS -
Is there any way or annotation in JADS-RS that allow me to call a method before or after the mailing request method gives . Suppose I have the following service class:
Public class MyService {... @POST @Path ("{id: \\ d +}") @Consumes (MediaType.APPLICATION_JSON) Public Response updateServiceObject (@PathParam ("id") is long id, InputStream) {try {// get service object ... ServiceObject updatedServiceObj = readServiceObject (); // ... and try updating it. Update = getServiceObjectDao (). Update (updatedServiceObj); If (update == 0) {new webappiation exception (answer status NOT_FOUND); } Return Response.ok () Construction (); } Hold (exception e) {new WebApplicationException (Response.Status.BAD_REQUEST); }} @DELETE @ path ("{id: \\ d +}") Public Response Delete Service Service (@PathParam ("id") Long ID) {try {getServiceObjectDao ()} deleteById (id); } Hold (exception e) {new WebApplicationException (Response.Status.BAD_REQUEST); } Return Response.ok () Construction (); }} I would like to add a method logEvent () , which is called the log, which method has been called and which parameter (only Pithaparam Value) was provided. Therefore bee must start before or after each call.
Use aspect oriented programming (AOP)
Comments
Post a Comment