i am writing a simple timer aspect to instrument all the methods in all the packages that belong my project. But, then the return types of various methods in those classes are different and I am getting this following error:
It only works for setter but not for getter...
Error: applying to joinpoint that doesn't return void
and here is my timeraspect...
@Around("execution(* com.myproject..*(..))") public void log(ProceedingJoinPoint pjp) throws Throwable{ LOG.info("TimerAspect"); String name = pjp.getSignature().getName(); Monitor mon = MonitorFactory.start(name); pjp.proceed(); mon.stop(); LOG.info("TimerAspect Mon" + mon); String printStr = mon.getLabel()+","+mon.getUnits()+","+mon.getLastValue()+","+mon.getHits()+","+mon.getAvg()+","+mon.getTotal()+","+mon.getMin()+","+mon.getMax()+","+mon.getFirstAccess()+","+mon.getLastAccess(); File f = new File("target/stats.csv"); BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(f, true)); bufferedWriter.write(printStr); bufferedWriter.newLine(); bufferedWriter.flush(); bufferedWriter.close(); } Any clue to resolve this is greatly appreciated.
Thanks