List of usage examples for org.aspectj.lang ProceedingJoinPoint getSignature
Signature getSignature();
getStaticPart().getSignature()
returns the same object From source file:org.mingle.pear.aop.RequestPerformance.java
License:Apache License
@Around("performance()") public void around(ProceedingJoinPoint joinPoint) { try {//from w w w .j a va 2 s . co m logger.info("aop around"); long start = System.currentTimeMillis(); joinPoint.proceed(); long end = System.currentTimeMillis(); if ((end = end - start) > (5 * 1000)) throw new HttpRequestTimeoutException(end); logger.info(joinPoint.getSignature() + " took " + end + " milliseconds"); } catch (Throwable e) { e.printStackTrace(); } }
From source file:org.molgenis.metrics.MolgenisTimedAspect.java
License:Apache License
@Around("execution(* (@io.micrometer.core.annotation.Timed *).*(..))") public Object timedClassMethod(ProceedingJoinPoint pjp) throws Throwable { Method method = ((MethodSignature) pjp.getSignature()).getMethod(); return timedProceed(pjp, method.getDeclaringClass().getAnnotation(Timed.class)); }
From source file:org.molgenis.metrics.MolgenisTimedAspect.java
License:Apache License
@Around("execution (@io.micrometer.core.annotation.Timed * *.*(..))") public Object timedMethod(ProceedingJoinPoint pjp) throws Throwable { Method method = ((MethodSignature) pjp.getSignature()).getMethod(); return timedProceed(pjp, method.getAnnotation(Timed.class)); }
From source file:org.nebula.service.logging.MethodLogger.java
License:Apache License
/** * Log methods in a class.//from w w w .j a v a 2 s . c om * * <p>Try NOT to change the signature of this method, in order to keep it backward compatible. * * @param point Joint point * @return The result of call * @throws Throwable If something goes wrong inside */ @Around( // @checkstyle StringLiteralsConcatenation (7 lines) "execution(public * (@org.nebula.service.logging.Loggable *).*(..))" + " && !execution(String *.toString())" + " && !execution(int *.hashCode())" + " && !execution(boolean *.canEqual(Object))" + " && !execution(boolean *.equals(Object))" + " && !cflow(call(org.nebula.service.logging.MethodLogger.new()))") public Object wrapClass(final ProceedingJoinPoint point) throws Throwable { final Method method = MethodSignature.class.cast(point.getSignature()).getMethod(); Object output; if (method.isAnnotationPresent(Loggable.class)) { output = point.proceed(); } else { output = this.wrap(point, method, method.getDeclaringClass().getAnnotation(Loggable.class)); } return output; }
From source file:org.nebula.service.logging.MethodLogger.java
License:Apache License
/** * Log individual methods./*w w w . j ava2 s . co m*/ * * <p>Try NOT to change the signature of this method, in order to keep it backward compatible. * * @param point Joint point * @return The result of call * @throws Throwable If something goes wrong inside */ @Around( // @checkstyle StringLiteralsConcatenation (2 lines) "(execution(* *(..)) || initialization(*.new(..)))" + " && @annotation(org.nebula.service.logging.Loggable)") @SuppressWarnings("PMD.AvoidCatchingThrowable") public Object wrapMethod(final ProceedingJoinPoint point) throws Throwable { final Method method = MethodSignature.class.cast(point.getSignature()).getMethod(); return this.wrap(point, method, method.getAnnotation(Loggable.class)); }
From source file:org.nebula.service.logging.Mnemos.java
License:Apache License
/** * Make a string out of point./* w ww .ja v a 2 s . co m*/ * @param point The point * @param trim Shall we trim long texts? * @param skip Shall we skip details and output just dots? * @return Text representation of it * @since 0.7.19 */ public static String toText(final ProceedingJoinPoint point, final boolean trim, final boolean skip) { return Mnemos.toText(MethodSignature.class.cast(point.getSignature()).getMethod(), point.getArgs(), trim, skip); }
From source file:org.nebulaframework.util.profiling.ProfilingAspect.java
License:Apache License
/** * Advice of Profiling Aspect. Measures and logs the exection * time of advised method./*from w w w . j a v a2s. c o m*/ * * @param pjp {ProceedingJoinPoint} * @return Object result * @throws Throwable if exception occurs */ @Around("profilingPointcut()") public Object profile(ProceedingJoinPoint pjp) throws Throwable { StopWatch sw = new StopWatch(); Log localLog = null; try { // Get Log localLog = LogFactory.getLog(pjp.getTarget().getClass()); // Start StopWatch sw.start(); // Proceed Invocation return pjp.proceed(); } finally { // Stop StopWatch sw.stop(); if (localLog == null) { // If local Log not found, use ProfilingAspect's Log localLog = log; } //Log Stats localLog.debug("[Profiling] " + pjp.getTarget().getClass().getName() + "->" + pjp.getSignature().getName() + "() | " + sw.getLastTaskTimeMillis() + " ms"); } }
From source file:org.nekorp.workflow.desktop.servicio.imp.EditorMonitorImp.java
License:Apache License
public void updateProperty(ProceedingJoinPoint pjp) throws Throwable { Object target = pjp.getTarget(); if (!(target instanceof Metadata)) { String methodName = pjp.getSignature().getName(); String propertyName = StringUtils.substringAfter(methodName, "set"); String primeraLetra = propertyName.charAt(0) + ""; propertyName = primeraLetra.toLowerCase() + StringUtils.substringAfter(propertyName, primeraLetra); Object oldValue = PropertyUtils.getProperty(target, propertyName); if (!oldValue.equals(pjp.getArgs()[0])) { EditorLog log = new EditorLog(); log.setTarget(target);// w w w.j av a 2s . co m log.setProperty(propertyName); log.setOldValue(oldValue); redoLog = new LinkedList<>(); this.addUndo(log); } } pjp.proceed(); }
From source file:org.nekorp.workflow.desktop.view.binding.imp.BindingManagerImp.java
License:Apache License
@Around("modelChange()") public void updateProperty(ProceedingJoinPoint pjp) throws Throwable { //BindingManagerImp.LOGGER.debug("evento:"+pjp.getTarget()); pjp.proceed();//w w w.ja va 2s . c om String methodName = pjp.getSignature().getName(); String propertyName = StringUtils.substringAfter(methodName, "set"); String primeraLetra = propertyName.charAt(0) + ""; propertyName = primeraLetra.toLowerCase() + StringUtils.substringAfter(propertyName, primeraLetra); //TODO to weak code :< processModelUpdate(pjp.getTarget(), propertyName, pjp.getArgs()[0]); }
From source file:org.obiba.mica.core.DebugMethodImpl.java
License:Open Source License
@Around("execution(@org.obiba.mica.core.DebugMethod * *(..)) && @annotation(debugMethodAnnotation)") public Object logDuration(ProceedingJoinPoint joinPoint, DebugMethod debugMethodAnnotation) throws Throwable { logger.debug(String.format("Method called [%s] with params [%s]", joinPoint.getSignature(), Arrays.toString(joinPoint.getArgs()))); return joinPoint.proceed(); }