List of usage examples for org.aspectj.lang ProceedingJoinPoint proceed
public Object proceed() throws Throwable;
From source file:cs544.aspect.LoggingAspect.java
@Around("execution(public * cs544.bank.service.*.*(..))") public Object measureInvocationTime(ProceedingJoinPoint call) throws Throwable { StopWatch clock = new StopWatch(); clock.start(call.getSignature().getName()); Object retval = call.proceed(); clock.stop();/* ww w . jav a 2s. co m*/ long totaltime = clock.getLastTaskTimeMillis(); System.out.println("Total time to execute: " + call.getSignature().getName() + ": " + totaltime); return retval; }
From source file:cs544.exercise13_1.TraceAdvice.java
@Around("execution (* cs544.exercise13_1.CustomerDAO.save(. .))") public Object tracemethod3(ProceedingJoinPoint call) throws Throwable { StopWatch clock = new StopWatch(""); clock.start(call.toShortString());// w w w.jav a 2 s.co m Object object = call.proceed(); clock.stop(); System.out.println("Time to execute save = " + clock.getTotalTimeMillis() + " ms"); return object; }
From source file:curly.commons.logging.MethodExecutionAspectInterceptor.java
License:Apache License
@Around(value = "execution(* *(..)) && @annotation(loggable)) ", argNames = "joinPoint, loggable") public Object invoke(ProceedingJoinPoint joinPoint, Loggable loggable) throws Throwable { if (executionEnabled) { StopWatch watch = new StopWatch(joinPoint.toShortString()); watch.start();/*from w ww . ja va2 s .c o m*/ try { return joinPoint.proceed(); } finally { watch.stop(); synchronized (this) { if (actuatorEnabled && (gaugeService != null)) { String gagueName = "gauge.execution." + joinPoint.getTarget() + "." + joinPoint.getSignature().getName(); gaugeService.submit(gagueName, watch.getLastTaskTimeMillis()); } log(loggable.value(), joinPoint.getTarget().getClass(), "Executed method {} in {} ms", joinPoint.getSignature().getName(), watch.getLastTaskTimeMillis()); } } } return joinPoint.proceed(); }
From source file:cz.sohlich.workstack.aspect.AuthorizationAspect.java
@Around("execution(* cz.sohlich.workstack.api.TaskResource.*(..))") public Object doBasicProfiling(ProceedingJoinPoint pjp) throws Throwable { Object[] array = pjp.getArgs(); System.out.println(Arrays.toString(array)); // start stopwatch Object retVal = pjp.proceed(); // stop stopwatch return retVal; }
From source file:de.accso.performancetesting.tools.PerformanceLogger.java
License:Apache License
private Object measureTime(ProceedingJoinPoint thisJoinPoint, String tag) throws Throwable { StopWatch sp = new StopWatch(); sp.start();/*from www .j a v a 2s . co m*/ Object result = thisJoinPoint.proceed(); sp.stop(); logger.info(append("durationinmillis", sp.getTotalTimeMillis()).and(append("tag", tag)) .and(append("req_id", CTX_HOLDER.get().reqId)).and(append("url", getCtxUrl())) .and(append("servicename", thisJoinPoint.getTarget().getClass().getCanonicalName() + "." + thisJoinPoint.getSignature().getName())), "Performance"); return result; }
From source file:de.alexandria.cms.frontend.webapp.aop.AopMethodLogger.java
License:Apache License
/** * * Protokolliert die Laufzeit des join points. Das logging ist nur aktiv, wenn {@link #logger} mindestens * debug-Level hat.// ww w . java 2s . co m * * @param call * @return * @throws Throwable */ @Around("methodsToBeLogged()") public Object logMethodDuration(ProceedingJoinPoint call) throws Throwable { // NOSONAR // proceed bentigt das Weiterreichen der Exception (throws Throwable)... Object returnValue; if (logger.isDebugEnabled()) { String targetClassName = call.getTarget().getClass().getName(); String targetMethodName = call.getSignature().getName(); Logger targetLog = LoggerFactory.getLogger(targetClassName); if (targetLog.isDebugEnabled()) { StopWatch clock = new StopWatch(getClass().getName()); try { clock.start(call.toShortString()); returnValue = call.proceed(); } finally { clock.stop(); String msg = createMsgForLogMethodDuration(targetMethodName, clock.getTotalTimeMillis()); targetLog.debug(msg); } } else { returnValue = call.proceed(); } } else { returnValue = call.proceed(); } return returnValue; }
From source file:de.beyondjava.examples.scopes.spring.LoggingAspect.java
License:Open Source License
@Around("execution(public java.lang.String *.getCounter(..))") public Object logBefore(ProceedingJoinPoint joinPoint) throws Throwable { String msg = "(null) -> "; Object target = joinPoint.getTarget(); try {/*from w w w. jav a 2 s . c om*/ Field counterField = target.getClass().getDeclaredField("counter"); int counter = (int) counterField.get(target); msg = String.valueOf(counter) + " -> "; } catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } String s = (String) joinPoint.proceed(); return msg + s; }
From source file:de.bstreit.java.springaop.observablebean.ObservableBeanAspectMixin.java
License:Apache License
/** * /*from w ww. ja v a 2s. com*/ * @param pjp * @throws Throwable * not expected to happen with simple beans! */ @Around("execution (* @de.bstreit.java.springaop.observablebean.ObservableBean *.set*(..))") public void handleSetterInvocation(ProceedingJoinPoint pjp) throws Throwable { // the target is the actual bean, with the set and get methods final Object target = pjp.getTarget(); /* * It seems that aop does not create the mixin unless at least one of the * IObservableBean methods (e.g. addPropertyChangeListener) is actually * called. * * That certainly reduces overhead; we must, however, take into * consideration that in this case, we do not have a * PropertyChangeSupportWithInterface instance and need to call the setter * ourself, by calling pjp.proceed(). */ final boolean mixinExists = weakReferences.containsKey(target); if (mixinExists) { final PropertyChangeSupportWithInterface mixin = weakReferences.get(target); mixin.handleSetterInvocation(pjp); } else { // No listeners at all, simply call setter without firing property change // events pjp.proceed(); } }
From source file:de.bstreit.java.springaop.observablebean.PropertyChangeSupportWithInterface.java
License:Apache License
/** * Retrieve old and new value, invoke setter and finally fire property change * event.//w ww . j a va 2 s.co m * * @param pjp * @throws Throwable */ void handleSetterInvocation(ProceedingJoinPoint pjp) throws Throwable { // the method name is "setPropertyName", hence stripping of the "set" // from the beginning gives us "PropertyName" final String propertyName = pjp.getSignature().getName().substring(3); final Object oldValue = beanWrapper.getPropertyValue(propertyName); final Object newValue = pjp.getArgs()[0]; // perform the setting pjp.proceed(); // fire property change, if no exception occurred pcs.firePropertyChange(propertyName, oldValue, newValue); }
From source file:de.codecentric.batch.metrics.AbstractBatchMetricsAspect.java
License:Apache License
protected Object profileMethod(ProceedingJoinPoint pjp) throws Throwable { StopWatch stopWatch = startStopWatch(); try {/* w ww . ja v a 2 s. c o m*/ return pjp.proceed(); } finally { gaugeService.submit(TIMER_PREFIX + getStepIdentifier() + "." + ClassUtils.getShortName(pjp.getTarget().getClass()) + "." + pjp.getSignature().getName(), getTotalTimeMillis(stopWatch)); } }