List of usage examples for org.aspectj.lang ProceedingJoinPoint toShortString
String toShortString();
From source file:org.slc.sli.dashboard.util.ExecutionTimeLogger.java
License:Apache License
@Around(value = "@annotation(annotation)") public Object log(final ProceedingJoinPoint proceedingJoinPoint, final LogExecutionTime annotation) throws Throwable { final long startTime = System.nanoTime(); try {// ww w . j a va 2 s. c o m return proceedingJoinPoint.proceed(); } finally { if (ProceedingJoinPoint.METHOD_CALL.equals(proceedingJoinPoint.getKind())) { LOGGER.info(">>>>>" + TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startTime) + " ms " + proceedingJoinPoint.toShortString() + "," + Arrays.asList(proceedingJoinPoint.getArgs())); } } }
From source file:org.spf4j.perf.aspects.PerformanceMonitorAspect.java
License:Open Source License
@Around(value = "execution(@org.spf4j.annotations.PerformanceMonitor * *(..)) && @annotation(annot)", argNames = "pjp,annot") public Object performanceMonitoredMethod(final ProceedingJoinPoint pjp, final PerformanceMonitor annot) throws Throwable { final long start = System.currentTimeMillis(); Object result = pjp.proceed(); final long elapsed = System.currentTimeMillis() - start; MeasurementRecorderSource mrs = REC_SOURCES.getUnchecked(annot.recorderSource()); mrs.getRecorder(pjp.toLongString()).record(elapsed); final long warnThresholdMillis = annot.warnThresholdMillis(); if (elapsed > warnThresholdMillis) { final long errorThresholdMillis = annot.errorThresholdMillis(); if (elapsed > errorThresholdMillis) { LOG.error("Execution time {} ms for {} exceeds error threshold of {} ms, arguments {}", elapsed, pjp.toShortString(), errorThresholdMillis, pjp.getArgs()); } else {/* w w w . jav a 2 s . c o m*/ LOG.warn("Execution time {} ms for {} exceeds warning threshold of {} ms, arguments {}", elapsed, pjp.toShortString(), warnThresholdMillis, pjp.getArgs()); } } else { if (annot.defaultInfoLog()) { LOG.info("Execution time {} ms for {}, arguments {}", elapsed, pjp.toShortString(), pjp.getArgs()); } else { LOG.debug("Execution time {} ms for {}, arguments {}", elapsed, pjp.toShortString(), pjp.getArgs()); } } return result; }
From source file:org.springframework.samples.petclinic.monitoring.CallMonitoringAspect.java
License:Apache License
@Around("@annotation(Monitored)") public Object invoke(ProceedingJoinPoint joinPoint) throws Throwable { if (this.enabled) { StopWatch sw = new StopWatch(joinPoint.toShortString()); sw.start("invoke"); try {/*from www . j ava 2 s . co m*/ return joinPoint.proceed(); } finally { sw.stop(); synchronized (this) { this.callCount++; this.accumulatedCallTime += sw.getTotalTimeMillis(); } } } else { return joinPoint.proceed(); } }
From source file:org.taverna.server.master.utils.CallTimeLogger.java
License:Apache License
/** * The timer for this aspect. The wrapped invocation will be timed, and a * log message written if the configured threshold is exceeded. * //from w w w. ja v a 2 s . c o m * @param call * The call being wrapped. * @return The result of the call. * @throws Throwable * If anything goes wrong with the wrapped call. * @see System#nanoTime() */ @Around("@annotation(org.taverna.server.master.utils.CallTimeLogger.PerfLogged)") public Object time(ProceedingJoinPoint call) throws Throwable { long fore = nanoTime(); try { return call.proceed(); } finally { long aft = nanoTime(); long elapsed = aft - fore; if (elapsed > threshold) log.info(format("call to %s took %.3fms", call.toShortString(), elapsed / 1000000.0)); } }
From source file:podd.dataaccess.hibernate.DeadlockInterceptor.java
License:Open Source License
private void logRetry(ProceedingJoinPoint pjp, int numRetries, HibernateException throwable) { StringBuffer buffer = new StringBuffer(); buffer.append("Operation ").append(pjp.toShortString()).append(" failed on ").append(throwable.getClass()) .append(" with parameters: ["); final Object[] arguments = pjp.getArgs(); for (Object obj : arguments) { if (null != obj) { buffer.append(obj.toString()).append(", "); }/*from w w w. ja v a 2 s . c o m*/ } final int start = buffer.lastIndexOf(", "); if (start >= 0) { buffer.delete(start, start + 2); } buffer.append("]. Retrying ").append(numRetries).append(" out of ").append(retry).append(" times."); logger.warn(buffer.toString()); }
From source file:sernet.gs.server.RuntimeLogger.java
License:Open Source License
public Object logRuntime(final ProceedingJoinPoint call) throws Throwable { Object returnValue;// ww w .j a v a2 s . com if (LOG.isDebugEnabled()) { final String targetClassName = call.getTarget().getClass().getName(); final String simpleTargetClassName = call.getTarget().getClass().getSimpleName(); final String targetMethodName = call.getSignature().getName(); final Logger targetLog = Logger.getLogger(targetClassName); if (targetLog.isDebugEnabled()) { final StopWatch clock = new StopWatch(getClass().getName()); try { clock.start(call.toShortString()); returnValue = call.proceed(); } finally { clock.stop(); final StringBuffer sb = new StringBuffer("Laufzeit "); sb.append(simpleTargetClassName).append(".").append(targetMethodName).append(": "); sb.append(clock.getTotalTimeMillis()); targetLog.debug(sb.toString()); } } else { returnValue = call.proceed(); } } else { returnValue = call.proceed(); } return returnValue; }