List of usage examples for org.aspectj.lang ProceedingJoinPoint proceed
public Object proceed() throws Throwable;
From source file:$.BizAspect.java
License:Open Source License
/** * .// ww w . j ava 2s .c o m * * @param jionpoint * @return * @throws Throwable */ @Around("bizPointcut() && @annotation(aspectLogger)") public Object aroundAdvice(ProceedingJoinPoint jionpoint, AspectLogger aspectLogger) throws Throwable { /* * . */ long l1 = System.currentTimeMillis(); /* * ??. */ String desc = aspectLogger.value(); /* * ??. */ //boolean discover = aspectLogger.discover(); /* * ???. */ String targetMethodName = jionpoint.getSignature().getName(); /* * ???. */ String targetClassName = jionpoint.getTarget().getClass().getName(); /* * ?. */ Object o = jionpoint.proceed(); /* * ?. */ long l2 = System.currentTimeMillis(); /* * ?. */ StringBuilder aspectMessage = new StringBuilder(); aspectMessage.append("[]:(").append(desc).append("),(").append(targetClassName) .append(".").append(targetMethodName).append("),(").append((l2 - l1)).append("ms)") .append(",?()"); /* * . */ logger.info(aspectMessage.toString()); //Object o = jionpoint.proceed();//??? return o; }
From source file:$.CommonAspect.java
License:Open Source License
/** * .// w ww . j a va2s . c o m * * @param jionpoint * @return * @throws Throwable */ @Around("commonPointcut() && @annotation(aspectLogger)") public Object aroundAdvice(ProceedingJoinPoint jionpoint, AspectLogger aspectLogger) throws Throwable { /* * . */ long l1 = System.currentTimeMillis(); /* * ??. */ String desc = aspectLogger.value(); /* * ???. */ String targetMethodName = jionpoint.getSignature().getName(); /* * ???. */ String targetClassName = jionpoint.getTarget().getClass().getName(); /* * ?. */ Object o = jionpoint.proceed(); /* * ?. */ long l2 = System.currentTimeMillis(); /* * ?. */ StringBuilder aspectMessage = new StringBuilder(); aspectMessage.append("[]:(").append(desc).append("),(").append(targetClassName) .append(".").append(targetMethodName).append("),(").append((l2 - l1)).append("ms)") .append(",?()"); /* * . */ logger.info(aspectMessage.toString()); //Object o = jionpoint.proceed();//??? return o; }
From source file:$.CoreAspect.java
License:Open Source License
/** * .//from w ww. j a v a 2 s. co m * * @param jionpoint * @return * @throws Throwable */ @Around("corePointcut() && @annotation(aspectLogger)") public Object aroundAdvice(ProceedingJoinPoint jionpoint, AspectLogger aspectLogger) throws Throwable { /* * . */ long l1 = System.currentTimeMillis(); /* * ??. */ String desc = aspectLogger.value(); /* * ???. */ String targetMethodName = jionpoint.getSignature().getName(); /* * ???. */ String targetClassName = jionpoint.getTarget().getClass().getName(); /* * ?. */ Object o = jionpoint.proceed(); /* * ?. */ long l2 = System.currentTimeMillis(); /* * ?. */ StringBuilder aspectMessage = new StringBuilder(); aspectMessage.append("[]:(").append(desc).append("),(").append(targetClassName) .append(".").append(targetMethodName).append("),(").append(l2 - l1).append("ms)") .append(",?()"); /* * . */ logger.info(aspectMessage.toString()); //Object o = jionpoint.proceed();//??? return o; }
From source file:$.LogAspect.java
License:Apache License
/** * ?? ProceedingJoinPoint ?. /*from w w w . ja v a2 s. com*/ * ??: ProceedingJoinPoint ???. * , ? */ @Around("pointcutExpression()") public Object aroundMethod(ProceedingJoinPoint pjd) { Object result = null; String methodName = pjd.getSignature().getName(); try { //? System.out.println("The method " + methodName + " begins with " + Arrays.asList(pjd.getArgs())); // result = pjd.proceed(); // System.out.println("The method " + methodName + " ends with " + result); } catch (Throwable e) { // System.out.println("The method " + methodName + " occurs exception:" + e); throw new RuntimeException(e); } //? System.out.println("The method " + methodName + " ends"); return result; }
From source file:ajia.faulttolerance.RetryFaultToleranceAspect.java
License:Apache License
@Around("retryOperation()") public Object retry(final ProceedingJoinPoint pjp) throws Throwable { RetryCallback<Object> worker = new RetryCallback<Object>() { public Object doWithRetry(RetryContext retryContext) throws Exception { try { return pjp.proceed(); } catch (Exception ex) { throw ex; } catch (Error error) { throw error; } catch (Throwable t) { throw new IllegalStateException("Caught throwable that is neither " + "Exception nor Error"); }/*from ww w.jav a2s . c om*/ } }; return retryTemplate.execute(worker); }
From source file:ajia.monitoring.AbstractPerformanceMonitoringAspect.java
License:Apache License
@Around("monitoredOp()&& !within(AbstractPerformanceMonitoringAspect)") public Object monitor(ProceedingJoinPoint pjp) throws Throwable { if (!isEnabled()) { return pjp.proceed(); }/*from www. ja va 2 s . c o m*/ long start = System.nanoTime(); try { return pjp.proceed(); } finally { long complete = System.nanoTime(); logger.log(Level.INFO, "Operation " + pjp.getSignature().toShortString() + " took " + (complete - start) + " nanoseconds"); } }
From source file:ajia.transaction.AbstractTransactionManagementAspect.java
License:Apache License
@Around("transactionalOp()") public Object transact(ProceedingJoinPoint pjp) throws Throwable { TransactionAttributeWithRollbackRules txAttribute = getTransactionAttribute(pjp); TransactionStatus status = transactionManager.getTransaction(txAttribute); try {//from w w w .j a v a2s .co m Object ret = pjp.proceed(); transactionManager.commit(status); return ret; } catch (Throwable ex) { if (txAttribute.rollbackOn(ex)) { transactionManager.rollback(status); } else { transactionManager.commit(status); } throw ex; } }
From source file:anza.stock.utils.AspectLogger.java
@Around("controller()") public Object logAround(ProceedingJoinPoint joinPoint) throws Throwable { long start = System.currentTimeMillis(); try {// www. j a v a 2 s . c om String className = joinPoint.getSignature().getDeclaringTypeName(); String methodName = joinPoint.getSignature().getName(); Object result = joinPoint.proceed(); long elapsedTime = System.currentTimeMillis() - start; System.out.println("Hello from aspect"); return result; } catch (IllegalArgumentException e) { throw e; } }
From source file:aspect.LoggingAspc.java
public Object myAround(ProceedingJoinPoint pjp) { Object returnValue = null;/*w ww .j a va2 s .co m*/ try { System.out.println("before Around"); returnValue = pjp.proceed(); // execute target method System.out.println("After Around Return"); } catch (Throwable E) { System.out.println("After Around Throw"); } System.out.println("After Around Finally"); return returnValue; }
From source file:at.ac.tuwien.infosys.jcloudscale.aspects.CloudObjectAspect.java
License:Apache License
@Around("call(!@at.ac.tuwien.infosys.jcloudscale.annotations.Local (@at.ac.tuwien.infosys.jcloudscale.annotations.CloudObject *).new(..))") public Object createNewCloudObject(ProceedingJoinPoint jp) throws Throwable { // check if we are running in a server context if (JCloudScaleConfiguration.isServerContext()) return jp.proceed(); Class<?> coType = jp.getSignature().getDeclaringType(); Constructor<?> constructor = ((ConstructorSignature) jp.getSignature()).getConstructor(); // check if this is already a CGLib modified class // TODO: it would be more efficient to add this to the pointcut def above if (CgLibUtil.isCGLibEnhancedClass(coType)) return jp.proceed(); return deployCloudObject(coType, jp.getArgs(), constructor); }