java - How to get an Object from Reast Easy Preprocessor to PostProcessor? -


i have scenario need implement mechanism show in log time taken rest api execute. planning have preprocessorinterceptor containing

long starttime = system.currenttimemillis()

and in postprocessinterceptor endtime , planning subtract starttime endtime. how can starttime in postprocessinterceptor ?

using containerrequestfilter , containerresponsefilter add property request:

@provider @prematching public class timerrequestfilter implements containerrequestfilter {      @override     public void filter(containerrequestcontext requestcontext) throws ioexception {         requestcontext.setproperty("starttime", system.currenttimemillis());             }  }  @provider public class timerresponsefilter implements containerresponsefilter {      private static final logger log = loggerfactory.getlogger(timerresponsefilter.class);      @override     public void filter(containerrequestcontext requestcontext, containerresponsecontext responsecontext) throws ioexception {         long starttime = (long) requestcontext.getproperty("foo.bar.starttime");         log.info("execution took {}ms", system.currenttimemillis() - starttime);     }  } 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -