List of usage examples for org.aspectj.lang ProceedingJoinPoint proceed
public Object proceed() throws Throwable;
From source file:com.github.inspektr.audit.AuditTrailManagementAspect.java
License:Apache License
@Around(value = "@annotation(audit)", argNames = "audit") public Object handleAuditTrail(final ProceedingJoinPoint joinPoint, final Audit audit) throws Throwable { final AuditActionResolver auditActionResolver = this.auditActionResolvers.get(audit.actionResolverName()); final AuditResourceResolver auditResourceResolver = this.auditResourceResolvers .get(audit.resourceResolverName()); String currentPrincipal = null; String[] auditResource = new String[] { null }; String action = null;/*from w w w. j a v a 2 s. c om*/ Object retVal = null; try { retVal = joinPoint.proceed(); currentPrincipal = this.auditPrincipalResolver.resolveFrom(joinPoint, retVal); auditResource = auditResourceResolver.resolveFrom(joinPoint, retVal); action = auditActionResolver.resolveFrom(joinPoint, retVal, audit); return retVal; } catch (final Exception e) { currentPrincipal = this.auditPrincipalResolver.resolveFrom(joinPoint, e); auditResource = auditResourceResolver.resolveFrom(joinPoint, e); action = auditActionResolver.resolveFrom(joinPoint, e, audit); throw e; } finally { executeAuditCode(currentPrincipal, auditResource, joinPoint, retVal, action, audit); } }
From source file:com.github.kopylec.rapidjdbc.SQLAspect.java
@Around("target(repository) && execution(* *(..)) && @annotation(query)") public Object executeSQLQuery(Repository repository, ProceedingJoinPoint joinPoint, Query query) throws Throwable { PreparedStatement statement = null; try {//from ww w . j a va 2 s . c om statement = prepareStatement(query.value(), joinPoint.getArgs()); LOGGER.debug("Executing SQL query \"{}\" with parameters {}", query.value(), Arrays.toString(joinPoint.getArgs())); repository.setResultSet(statement.executeQuery()); return joinPoint.proceed(); } catch (RapidJDBCException ex) { throw ex; } catch (Exception ex) { throw new RapidJDBCException("Error executing query \"" + query.value() + "\" with parameters " + Arrays.toString(joinPoint.getArgs()), ex); } finally { repository.closeResultSet(); closeResources(statement); } }
From source file:com.github.kopylec.rapidjdbc.SQLAspect.java
@Around("target(repository) && execution(* *(..)) && @annotation(update)") public Object executeSQLUpdate(Repository repository, ProceedingJoinPoint joinPoint, Update update) throws Throwable { PreparedStatement statement = null; try {//from w ww . j a v a 2 s . c o m statement = prepareStatement(update.value(), joinPoint.getArgs()); Object result = joinPoint.proceed(); LOGGER.debug("Executing SQL update \"{}\" with parameters {}", update.value(), Arrays.toString(joinPoint.getArgs())); statement.executeUpdate(); return result; } catch (RapidJDBCException ex) { throw ex; } catch (Exception ex) { throw new RapidJDBCException("Error executing update \"" + update.value() + "\" with parameters " + Arrays.toString(joinPoint.getArgs()), ex); } finally { closeResources(statement); } }
From source file:com.github.mrstampy.gameboot.processor.GameBootProcessorAspect.java
License:Open Source License
/** * Metrics./*from www . ja v a 2 s . co m*/ * * @param pjp * the pjp * @return the object * @throws Throwable * the throwable */ @Around("this(com.github.mrstampy.gameboot.processor.GameBootProcessor) && execution(com.github.mrstampy.gameboot.messages.Response *.*(..))") public Object metrics(ProceedingJoinPoint pjp) throws Throwable { Optional<Context> ctx = helper.startTimer(PROCESS_TIMER); try { Response r = (Response) pjp.proceed(); if (r == null) return null; switch (r.getResponseCode()) { case FAILURE: helper.incr(FAILED_REQUESTS); break; case ALERT: helper.incr(ALERT_REQUESTS); break; case INFO: helper.incr(INFO_REQUESTS); break; case SUCCESS: helper.incr(SUCCESS_REQUESTS); break; case WARNING: helper.incr(WARNING_REQUESTS); break; default: break; } return r; } finally { helper.stopTimer(ctx); } }
From source file:com.github.piasy.aopdemolib.TraceAspect.java
License:Open Source License
@Around("methodToTrace() || constructorToTrace()") public Object trace(ProceedingJoinPoint joinPoint) throws Throwable { MethodSignature signature = (MethodSignature) joinPoint.getSignature(); String className = signature.getDeclaringType().getSimpleName(); String methodName = signature.getName(); long start = System.nanoTime(); Object result = joinPoint.proceed(); long stop = System.nanoTime(); Log.d(className + "::" + methodName, "" + (stop - start)); PrintWriter writer = new PrintWriter( new FileOutputStream(new File(Environment.getExternalStorageDirectory(), "reflect.log"), true)); writer.println(className + "::" + methodName + (stop - start)); writer.close();//from w ww .j av a2 s .com return result; }
From source file:com.github.rozidan.springboot.logger.LoggerInterceptor.java
License:Apache License
public Object logMethod(ProceedingJoinPoint joinPoint, Loggable loggable) throws Throwable { long start = System.nanoTime(); WarnPoint warnPoint = null;/*from ww w . j a v a 2 s. com*/ Object returnVal = null; if (isLevelEnabled(joinPoint, loggable) && loggable.warnOver() >= 0) { warnPoint = new WarnPoint(joinPoint, loggable, start); warnPoints.add(warnPoint); } if (loggable.entered()) { log(loggable.value(), formatter.enter(joinPoint, loggable), joinPoint, loggable); } try { returnVal = joinPoint.proceed(); long nano = System.nanoTime() - start; if (isOver(nano, loggable)) { log(LogLevel.WARN, formatter.warnAfter(joinPoint, loggable, returnVal, nano), joinPoint, loggable); } else { log(loggable.value(), formatter.after(joinPoint, loggable, returnVal, nano), joinPoint, loggable); } return returnVal; } catch (Throwable ex) { if (contains(loggable.ignore(), ex)) { log(LogLevel.ERROR, formatter.error(joinPoint, loggable, System.nanoTime() - start, ex), joinPoint, loggable); } else { log(formatter.error(joinPoint, loggable, System.nanoTime() - start, ex), joinPoint, loggable, ex); } throw ex; } finally { if (warnPoint != null) { warnPoints.remove(warnPoint); } } }
From source file:com.github.szberes.spring.examples.aop.aspects.AspectForMethodExecution.java
License:Apache License
@Around("execution(* com.github.szberes.spring.examples.aop.advised.classes.MyClass.doNothing())") public void aroundDoNothing(ProceedingJoinPoint joinPoint) { LOGGER.info("Around: " + joinPoint); try {/*from w w w . j a v a2 s .c o m*/ joinPoint.proceed(); } catch (Throwable throwable) { throwable.printStackTrace(); } LOGGER.info("Around advice done: " + joinPoint); }
From source file:com.github.tddts.jet.config.aspect.ProfilingAnnotationAspect.java
License:Apache License
@Around("@annotation(com.github.tddts.jet.config.spring.annotations.Profiling)") public Object annotationPointcut(ProceedingJoinPoint joinPoint) throws Throwable { long time = System.currentTimeMillis(); Object value = joinPoint.proceed(); long duration = (System.currentTimeMillis() - time) / 1000; long minutes = (duration % (60 * 60)) / 60; long seconds = duration % 60; logger.debug(joinPoint.getSignature().getDeclaringType().getSimpleName() + "." + joinPoint.getSignature().getName() + "() execution time is: " + minutes + " m. " + seconds + " s."); return value; }
From source file:com.github.tddts.jet.config.aspect.RestClientAnnotationAspect.java
License:Apache License
@Around("restClientMethodPointcut()") public Object restClientErrorHandlingAspect(ProceedingJoinPoint joinPoint) throws Throwable { try {//from w w w . ja v a 2 s.c om return joinPoint.proceed(); } catch (HttpStatusCodeException e) { return new RestResponse(e); } }
From source file:com.github.tddts.jet.config.aspect.RetryAnnotationAspect.java
License:Apache License
@Around("restClientMethodRetryPointcut()") public Object restClientRetryHandlingAspect(ProceedingJoinPoint joinPoint) throws Throwable { Method method = SpringUtil.getMethod(joinPoint); Retry retry = method.getAnnotation(Retry.class); int count = retry.retries(); int timeout = retry.timeout(); RestResponse response = (RestResponse) joinPoint.proceed(); while (count > 0 && response.hasError()) { Thread.sleep(timeout);//from ww w. j av a2 s . co m response = (RestResponse) joinPoint.proceed(); count--; } return response; }