Java 类org.aspectj.lang.annotation.After 实例源码

项目:SpringTutorial    文件:LoggingAdvice.java   
@After("allAppMethodswithin()")
// Try allAppMethodswithin
public void loggingAdvice(JoinPoint jp) {

    System.out.println("JoinPoint  -> " + jp.toString());

    System.out.println("Target  -> " + jp.getTarget());

    if (jp.getTarget() instanceof StatementService) {
        System.out
                .println("logging code inserted after StatementService method execution");
    } else if (jp.getTarget() instanceof PaymentService) {
        System.out
                .println("logging code inserted after PaymentService method execution");
    }

}
项目:whatsmars    文件:SystemLogAspect.java   
@After("controllerAspect()")
    public void doAfter(JoinPoint joinPoint) {

        HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
        // 读取session中的用户
//      User user = SessionUtils.getUserFromSession(request);

//      if(null == user){
//          logger.info("未登录日志不记录");
//          return;
//      }

        try {
            Object[] args = getLogMethodDescription(joinPoint);
            // *========数据库日志=========*//
//          logService.saveLog(user.getId(), user.getAccount(), Integer.valueOf(args[1].toString()),
//                    IpUtils.getIpAddr(request), args[0].toString(),
//                    user.getManufacturerId(), reqDescription(request));

        } catch (Exception e) {
            logger.error(e);
            e.printStackTrace();
        }
    }
项目:simbest-cores    文件:SysOperateInfoAspect.java   
@After("execution(* *..web..*Controller.*(..))")
// 在方法执行之后执行的代码. 无论该方法是否出现异常
public void afterMethod(JoinPoint jp) {     
    Signature signature = jp.getSignature();
    MethodSignature methodSignature = (MethodSignature) signature;
    Method targetMethod = methodSignature.getMethod();
    //Class<? extends Method> clazz = targetMethod.getClass(); 
    if(record){
        if(targetMethod.getAnnotation(LogAudit.class) != null){
            saveOperateLog(targetMethod);
        }
        else if(baseControllerMethodNames.contains(targetMethod.getName())){
            Method parentMethod = baseControllerMethods.get(targetMethod.getName());
            if(parentMethod.getAnnotation(LogAudit.class) != null){
                saveOperateLog(targetMethod);
            }
        }
    }
}
项目:LibZilla    文件:ASupportLoading.java   
/**
 * 关闭对话框
 *
 * @param joinPoint
 * @throws IllegalAccessException
 */
@After("execution(@zilla.libcore.ui.SupportMethodLoading * *(..))")
public void dismissDialog(ProceedingJoinPoint joinPoint) {
    try {
        Object container = joinPoint.getTarget();

        Field[] fields = container.getClass().getFields();
        for (Field field : fields) {
            if (field.getAnnotation(LifeCircleInject.class) != null) {
                if (IDialog.class.isAssignableFrom(field.getType())) {
                    IDialog iDialog = (IDialog) field.get(container);
                    iDialog.dismiss();
                    return;
                }
            }
        }
    } catch (Exception e) {
        Log.e(e.getMessage());
    }
}
项目:spring-vertx-ext    文件:VertxLifecycleAspect.java   
/**
 * When a verticle will be stopped the stop() method will be executed.
 * In this case check if there is a running spring context, if so close it.
 * @param joinPoint the verticle stop method
 */
@After(value = "execution(* io.vertx.core.Verticle+.stop())")
public void afterStop(JoinPoint joinPoint) {
    final Object target = joinPoint.getTarget();
    log.debug("Stop invoked - Terminating spring context for verticle");
    if (target.getClass().isAnnotationPresent(SpringVerticle.class)) {
        if (AnnotationConfigApplicationContext.class.isAssignableFrom(context.getClass())) {
            final ApplicationContext parent = AnnotationConfigApplicationContext.class.cast(context).getParent();
            if (parent == null) {
                AnnotationConfigApplicationContext.class.cast(context).stop();
            } else {
                if (GenericApplicationContext.class.isAssignableFrom(parent.getClass())) {
                    GenericApplicationContext.class.cast(parent).stop();
                }
            }
        }
    }

}
项目:jcabi-aspects    文件:ImmutabilityChecker.java   
/**
 * Catch instantiation and validate class.
 *
 * <p>Try NOT to change the signature of this method, in order to keep
 * it backward compatible.
 * @param point Joint point
 */
@After("initialization((@com.jcabi.aspects.Immutable *).new(..))")
public void after(final JoinPoint point) {
    final Class<?> type = point.getTarget().getClass();
    try {
        this.check(type);
    } catch (final ImmutabilityChecker.Violation ex) {
        throw new IllegalStateException(
            String.format(
                // @checkstyle LineLength (1 line)
                "%s is not immutable, can't use it (jcabi-aspects %s/%s)",
                type,
                Version.CURRENT.projectVersion(),
                Version.CURRENT.buildNumber()
            ),
            ex
        );
    }
}
项目:Surgeon    文件:ReplaceAbleAspect.java   
@After("method()")
public void afterIfNeeded(JoinPoint jPoint) throws Throwable {
    String[] pair = parseNamespaceAndMethodName(jPoint);
    String namespace = pair[0];
    String function = pair[1];

    //invoke after function
    MasterFinder.getInstance().findAndInvoke(namespace, AFTER, function, jPoint.getThis(), jPoint.getArgs());
}
项目:allure-java    文件:AllureJunit4ListenerAspect.java   
@After("execution(org.junit.runner.notification.RunNotifier.new())")
public void addListener(final JoinPoint point) {
    final RunNotifier notifier = (RunNotifier) point.getThis();
    notifier.removeListener(allure);
    notifier.addListener(allure);
}
项目:telemarket-skittle-alley    文件:DrawGuessAspect.java   
/**
 * 判断玩家准备是否要开始游戏
 *
 * @param point 切点
 */
@After(value = "execution(* telemarketer.skittlealley.model.game.drawguess.DrawGuessContext.addPlayer(..))",
        argNames = "point")
public void checkStart(JoinPoint point) {
    DrawGuessContext ctx = (DrawGuessContext) point.getTarget();
    service.checkStart(ctx);
}
项目:lams    文件:AbstractAspectJAdvisorFactory.java   
/**
 * Find and return the first AspectJ annotation on the given method
 * (there <i>should</i> only be one anyway...)
 */
@SuppressWarnings("unchecked")
protected static AspectJAnnotation<?> findAspectJAnnotationOnMethod(Method method) {
    Class<?>[] classesToLookFor = new Class<?>[] {
            Before.class, Around.class, After.class, AfterReturning.class, AfterThrowing.class, Pointcut.class};
    for (Class<?> c : classesToLookFor) {
        AspectJAnnotation<?> foundAnnotation = findAnnotation(method, (Class<Annotation>) c);
        if (foundAnnotation != null) {
            return foundAnnotation;
        }
    }
    return null;
}
项目:training-sample    文件:LogAspect.java   
@After("pointcut()")
public void logAfter(JoinPoint joinPoint) {
    System.out.println("******");
    System.out.println("logAfter() is running!");
    System.out.println("hijacked : " + joinPoint.getSignature().getName());
    System.out.println("******");
}
项目:FragmentRigger    文件:FragmentInjection.java   
@After("onViewCreated()")
public void onViewCreatedProcess(JoinPoint joinPoint) throws Throwable {
  Object puppet = joinPoint.getTarget();
  //Only inject the class that marked by Puppet annotation.
  Object[] args = joinPoint.getArgs();

  Method onCreate = getRiggerMethod("onViewCreated", Object.class, View.class, Bundle.class);
  onCreate.invoke(getRiggerInstance(), puppet, args[0], args[1]);
}
项目:spring4.x-project    文件:LogAspect.java   
@After("annotationPointCut()") //④
public void after(JoinPoint joinPoint) {
    MethodSignature signature = (MethodSignature) joinPoint.getSignature();
    Method method = signature.getMethod();
    Action action = method.getAnnotation(Action.class); 
    System.out.println("注解式拦截 " + action.name()); //⑤
}
项目:hello-spring    文件:LogAspect.java   
@After("annotationPointCut()")
public void after(JoinPoint joinpoint) {
    MethodSignature signature = (MethodSignature) joinpoint.getSignature();
    Method method = signature.getMethod();
    Action action = method.getAnnotation(Action.class);
    System.out.println("注解式拦截 " + action.name());
}
项目:apollo-custom    文件:NamespaceUnlockAspect.java   
@After("@annotation(PreAcquireNamespaceLock) && args(itemId, operator, ..)")
public void requireLockAdvice(long itemId, String operator) {
  Item item = itemService.findOne(itemId);
  if (item == null) {
    throw new BadRequestException("item not exist.");
  }
  tryUnlock(namespaceService.findOne(item.getNamespaceId()));
}
项目:sjk    文件:AppHistory4IndexInterceptor.java   
@After(value = "createAppPointCut() && args(jp)")
public void createHistory(Joinpoint jp) {
    logger.debug("begin createAppPointCut ");
    //
    // App app = null;
    // try {
    // app = (App) jp.proceed();
    // } catch (Throwable e) {
    // logger.error("throwable:", e);
    // }
    // if (app != null) {
    // appHistory4IndexDaoImpl.saveOrUpdate(app.getId());
    // }
}
项目:sjk    文件:AppHistory4IndexInterceptor.java   
@After(value = "updateAppPointcut() && args(jp)")
public void updateHistory(Joinpoint jp) {
    logger.debug("begin updateAppPointcut ");
    // App app = null;
    // try {
    // app = (App) jp.proceed();
    // } catch (Throwable e) {
    // logger.error("throwable:", e);
    // }
    // if (app != null) {
    // appHistory4IndexDaoImpl.saveOrUpdate(app.getId());
    // }
}
项目:LemonKit4Android    文件:LKUIViewAspect.java   
@After("execution(net.lemonsoft.lemonkit.ui.view.LK*.new(..))")
public void lkConstructor(JoinPoint joinPoint) throws Throwable {
    if (!(joinPoint.getTarget() instanceof LKUIView))
        return;
    Object[] args = joinPoint.getArgs();
    LKUIExtensionModel model = new LKUIExtensionModel();
    if (args.length >= 2)
        model = LKUIAttrsParser.parse((View) joinPoint.getTarget(), (AttributeSet) args[1]);
    lkPool.put(getLKKey(joinPoint), model);
    applyLKComplete(model, (LKUIView) joinPoint.getTarget());
}
项目:apollo    文件:NamespaceUnlockAspect.java   
@After("@annotation(PreAcquireNamespaceLock) && args(itemId, operator, ..)")
public void requireLockAdvice(long itemId, String operator) {
  Item item = itemService.findOne(itemId);
  if (item == null) {
    throw new BadRequestException("item not exist.");
  }
  tryUnlock(namespaceService.findOne(item.getNamespaceId()));
}
项目:spring4-understanding    文件:AbstractAspectJAdvisorFactory.java   
/**
 * Find and return the first AspectJ annotation on the given method
 * (there <i>should</i> only be one anyway...)
 */
@SuppressWarnings("unchecked")
protected static AspectJAnnotation<?> findAspectJAnnotationOnMethod(Method method) {
    Class<?>[] classesToLookFor = new Class<?>[] {
            Before.class, Around.class, After.class, AfterReturning.class, AfterThrowing.class, Pointcut.class};
    for (Class<?> c : classesToLookFor) {
        AspectJAnnotation<?> foundAnnotation = findAnnotation(method, (Class<Annotation>) c);
        if (foundAnnotation != null) {
            return foundAnnotation;
        }
    }
    return null;
}
项目:selenium-camp-samples    文件:UserAspect.java   
@After("execution(@org.testng.annotations.Test * com.blogspot.notes.automation.qa.tests..*.*(..))")
public void releaseUser(final JoinPoint joinPoint) {
    getMethodArgByIndex(joinPoint, 0)
            .ifPresent(arg -> getFieldValue(arg, DEFAULT_USER_FIELD_NAME)
                    .onSuccess(value -> getPool().ifPresent(pool ->
                            pool.restore((UsersEntity) value))));
}
项目:menggeqa    文件:DefaultAspect.java   
@After(EXECUTION_NAVIGATION_TO)
public void afterNavigateTo(JoinPoint joinPoint)  throws Throwable {
    try {
        listener.afterNavigateTo(String.valueOf(joinPoint.getArgs()[0]), driver);
    } catch (Throwable t) {
        throw getRootCause(t);
    }
}
项目:menggeqa    文件:DefaultAspect.java   
@After(EXECUTION_NAVIGATION_BACK)
public void afterNavigateBack(JoinPoint joinPoint) throws Throwable {
    try {
        listener.afterNavigateBack(driver);
    } catch (Throwable t) {
        throw getRootCause(t);
    }
}
项目:menggeqa    文件:DefaultAspect.java   
@After(EXECUTION_NAVIGATION_FORWARD)
public void afterNavigateForward(JoinPoint joinPoint) throws Throwable {
    try {
        listener.afterNavigateForward(driver);
    } catch (Throwable t) {
        throw getRootCause(t);
    }
}
项目:menggeqa    文件:DefaultAspect.java   
@After(EXECUTION_NAVIGATION_REFRESH)
public void afterNavigateRefresh(JoinPoint joinPoint) throws Throwable {
    try {
        listener.afterNavigateRefresh(driver);
    } catch (Throwable t) {
        throw getRootCause(t);
    }
}
项目:menggeqa    文件:DefaultAspect.java   
@After(EXECUTION_SEARCH)
public void afterFindBy(JoinPoint joinPoint) throws Throwable {
    try {
        Object target =  joinPoint.getTarget();
        if (!WebElement.class.isAssignableFrom(target.getClass())) {
            listener.afterFindBy((By) castArgument(joinPoint, 0), null, driver);
        } else {
            listener.afterFindBy((By) castArgument(joinPoint, 0),
                (WebElement) castTarget(joinPoint), driver);
        }
    } catch (Throwable t) {
        throw getRootCause(t);
    }
}
项目:menggeqa    文件:DefaultAspect.java   
@After(EXECUTION_CLICK)
public void afterClickOn(JoinPoint joinPoint) throws Throwable {
    try {
        listener.afterClickOn((WebElement) castTarget(joinPoint), driver);
    } catch (Throwable t) {
        throw getRootCause(t);
    }
}
项目:menggeqa    文件:DefaultAspect.java   
@After(EXECUTION_CHANGE_VALUE)
public void afterChangeValueOf(JoinPoint joinPoint) throws Throwable {
    try {
        listener.afterChangeValueOf((WebElement) castTarget(joinPoint), driver);
    } catch (Throwable t) {
        throw getRootCause(t);
    }
}
项目:menggeqa    文件:DefaultAspect.java   
@After(EXECUTION_SCRIPT)
public void afterScript(JoinPoint joinPoint) throws Throwable {
    try {
        listener.afterScript(String.valueOf(joinPoint.getArgs()[0]), driver);
    } catch (Throwable t) {
        throw getRootCause(t);
    }
}
项目:menggeqa    文件:DefaultAspect.java   
@After(EXECUTION_ALERT_ACCEPT)
public void afterAlertAccept(JoinPoint joinPoint) throws Throwable {
    try {
        listener.afterAlertAccept(driver, (Alert) castTarget(joinPoint));
    } catch (Throwable t) {
        throw getRootCause(t);
    }
}
项目:menggeqa    文件:DefaultAspect.java   
@After(EXECUTION_ALERT_DISMISS)
public void afterAlertDismiss(JoinPoint joinPoint) throws Throwable {
    try {
        listener.afterAlertDismiss(driver, (Alert) castTarget(joinPoint));
    } catch (Throwable t) {
        throw getRootCause(t);
    }
}
项目:menggeqa    文件:DefaultAspect.java   
@After(EXECUTION_ALERT_SEND_KEYS)
public void afterAlertSendKeys(JoinPoint joinPoint) throws Throwable {
    try {
        listener.afterAlertSendKeys(driver, (Alert) castTarget(joinPoint),
            String.valueOf(joinPoint.getArgs()[0]));
    } catch (Throwable t) {
        throw getRootCause(t);
    }
}
项目:menggeqa    文件:DefaultAspect.java   
@After(EXECUTION_ALERT_AUTHENTICATION)
public void afterAlertAuthentication(JoinPoint joinPoint) throws Throwable {
    try {
        listener.afterAuthentication(driver, (Alert) castTarget(joinPoint),
            (Credentials) castArgument(joinPoint, 0));
    } catch (Throwable t) {
        throw getRootCause(t);
    }
}
项目:menggeqa    文件:DefaultAspect.java   
@After(EXECUTION_WINDOW_SET_SIZE)
public void afterWindowIsResized(JoinPoint joinPoint) throws Throwable {
    try {
        listener.afterWindowChangeSize(driver, (WebDriver.Window) castTarget(joinPoint),
            (Dimension) castArgument(joinPoint, 0));
    } catch (Throwable t) {
        throw getRootCause(t);
    }
}
项目:menggeqa    文件:DefaultAspect.java   
@After(EXECUTION_WINDOW_SET_POSITION)
public void afterWindowIsMoved(JoinPoint joinPoint) throws Throwable {
    try {
        listener.afterWindowIsMoved(driver, (WebDriver.Window) castTarget(joinPoint),
            (Point) castArgument(joinPoint, 0));
    } catch (Throwable t) {
        throw getRootCause(t);
    }
}
项目:menggeqa    文件:DefaultAspect.java   
@After(EXECUTION_WINDOW_MAXIMIZE)
public void afterMaximization(JoinPoint joinPoint) throws Throwable {
    try {
        listener.afterWindowIsMaximized(driver, (WebDriver.Window) castTarget(joinPoint));
    } catch (Throwable t) {
        throw getRootCause(t);
    }
}
项目:menggeqa    文件:DefaultAspect.java   
@After(EXECUTION_ROTATE)
public void afterRotation(JoinPoint joinPoint) throws Throwable {
    try {
        listener.afterRotation(driver, (ScreenOrientation) castArgument(joinPoint, 0));
    } catch (Throwable t) {
        throw getRootCause(t);
    }
}
项目:menggeqa    文件:DefaultAspect.java   
@After(EXECUTION_CONTEXT)
public void afterSwitchingToContextn(JoinPoint joinPoint) throws Throwable {
    try {
        listener.afterSwitchingToContext(driver, String.valueOf(joinPoint.getArgs()[0]));
    } catch (Throwable t) {
        throw getRootCause(t);
    }
}
项目:Pury    文件:StopProfilingAspect.java   
@After("constructor() || method() || methodWithMultipleAnnotations() || constructorWithMultipleAnnotations()")
public void weaveJoinPoint(JoinPoint joinPoint) throws Throwable {
    if (!Pury.isEnabled()) {
        return;
    }

    ProfilingManager profilingManager = Pury.getProfilingManager();
    for (StageId stageId : getStageIds(joinPoint)) {
        profilingManager.getProfiler(stageId.getProfilerId())
                .stopStage(stageId.getStageName());
    }

}
项目:spring    文件:AbstractAspectJAdvisorFactory.java   
/**
 * Find and return the first AspectJ annotation on the given method
 * (there <i>should</i> only be one anyway...)
 */
@SuppressWarnings("unchecked")
protected static AspectJAnnotation<?> findAspectJAnnotationOnMethod(Method method) {
    Class<?>[] classesToLookFor = new Class<?>[] {
            Before.class, Around.class, After.class, AfterReturning.class, AfterThrowing.class, Pointcut.class};
    for (Class<?> c : classesToLookFor) {
        AspectJAnnotation<?> foundAnnotation = findAnnotation(method, (Class<Annotation>) c);
        if (foundAnnotation != null) {
            return foundAnnotation;
        }
    }
    return null;
}