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

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -