List of usage examples for org.aspectj.lang ProceedingJoinPoint getArgs
Object[] getArgs();
From source file:org.slc.sli.dal.migration.config.MigrationRunner.java
License:Apache License
@Around(value = "@annotation(annotation)") public Object migrateEntiy(final ProceedingJoinPoint proceedingJoinPoint, final MigrateEntity annotation) throws Throwable { Object obj = proceedingJoinPoint.proceed(); String collectionName = ""; Object[] args = proceedingJoinPoint.getArgs(); if (args.length > 0) { if (args[0] instanceof String) { collectionName = (String) args[0]; }/*from ww w . j a va 2s .co m*/ } if (sliSchemaVersionValidator != null) { return sliSchemaVersionValidator.migrate(collectionName, (Entity) obj, repository); } else { return obj; } }
From source file:org.slc.sli.dal.migration.config.MigrationRunner.java
License:Apache License
@Around(value = "@annotation(annotation)") public Object migrateEntiyCollection(final ProceedingJoinPoint proceedingJoinPoint, final MigrateEntityCollection annotation) throws Throwable { Object obj = proceedingJoinPoint.proceed(); String collectionName = ""; Object[] args = proceedingJoinPoint.getArgs(); if (args.length > 0) { if (args[0] instanceof String) { collectionName = (String) args[0]; }/*from w w w . j a v a 2s . c o m*/ } if (sliSchemaVersionValidator != null) { return sliSchemaVersionValidator.migrate(collectionName, (Iterable<Entity>) obj, repository); } else { return obj; } }
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 {// w ww. ja va 2 s .co 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.slc.sli.dashboard.web.util.ControllerInputValidatorAspect.java
License:Apache License
/** * Around for pointcut defined by controllerMethodInvocation * @param joinPoint// w w w . j av a2s. c o m * @return * @throws Throwable */ @Around("controllerMethodInvocation()") public Object aroundController(ProceedingJoinPoint joinPoint) throws Throwable { MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature(); Annotation[][] annotations = methodSignature.getMethod().getParameterAnnotations(); String[] paramNames = methodSignature.getParameterNames(); Object[] args = joinPoint.getArgs(); for (int i = 0; i < args.length; i++) { if (checkAnnotations(annotations[i])) { validateArg(args[i], paramNames[i]); } } return joinPoint.proceed(args); }
From source file:org.smallmind.web.jersey.aop.ResourceMethodAspect.java
License:Open Source License
@Around(value = "execution(@org.smallmind.web.jersey.aop.ResourceMethod * * (..)) && @annotation(resourceMethod)", argNames = "thisJoinPoint, entityType") public Object aroundEntityTypeMethod(ProceedingJoinPoint thisJoinPoint, ResourceMethod resourceMethod) throws Throwable { try {//from ww w . ja v a 2 s .c o m Object returnValue; if (resourceMethod.validate()) { EntityValidator.validateParameters(thisJoinPoint.getTarget(), ((MethodSignature) thisJoinPoint.getSignature()).getMethod(), thisJoinPoint.getArgs()); } returnValue = thisJoinPoint.proceed(); if (resourceMethod.validate()) { EntityValidator.validateReturnValue(thisJoinPoint.getTarget(), ((MethodSignature) thisJoinPoint.getSignature()).getMethod(), returnValue); } return returnValue; } finally { EntityTranslator.clearEntity(); } }
From source file:org.spf4j.perf.aspects.FileMonitorAspect.java
License:Open Source License
@Around("call(java.io.FileInputStream.new(java.io.File))") public Object fileIS(final ProceedingJoinPoint pjp) throws Throwable { pjp.proceed();/*from w w w.j av a 2 s . c o m*/ return new MeasuredFileInputStream((File) pjp.getArgs()[0], pjp.getSourceLocation().getWithinType(), RECORDER_READ); }
From source file:org.spf4j.perf.aspects.FileMonitorAspect.java
License:Open Source License
@Around("call(java.io.FileOutputStream.new(java.io.File))") public Object fileOS(final ProceedingJoinPoint pjp) throws Throwable { pjp.proceed();/* www . ja v a 2s. c o m*/ return new MeasuredFileOutputStream((File) pjp.getArgs()[0], pjp.getSourceLocation().getWithinType(), RECORDER_WRITE); }
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 {/*from w ww . j a va2 s .c om*/ 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.aop.aspectj.ProceedTests.java
License:Apache License
public Object doubleOrQuits(ProceedingJoinPoint pjp) throws Throwable { int value = ((Integer) pjp.getArgs()[0]).intValue(); pjp.getArgs()[0] = new Integer(value * 2); return pjp.proceed(); }
From source file:org.springframework.aop.aspectj.ProceedTests.java
License:Apache License
public Object captureStringArgumentInAround(ProceedingJoinPoint pjp, String arg) throws Throwable { if (!pjp.getArgs()[0].equals(arg)) { throw new IllegalStateException( "argument is '" + arg + "', " + "but args array has '" + pjp.getArgs()[0] + "'"); }/* w ww.j a va 2 s . com*/ this.lastAroundStringValue = arg; return pjp.proceed(); }