org.aspectj.lang.annotation.After Java Examples

The following examples show how to use org.aspectj.lang.annotation.After. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: OneBlog   Author: zhangyd-c   File: FreemarkerSharedVariableMonitorAspects.java    License: GNU General Public License v3.0 6 votes vote down vote up
@After("pointcut()")
public void after(JoinPoint joinPoint) {
    Map config = configService.getConfigs();
    if (null == config) {
        log.error("config为空");
        return;
    }
    Long updateTime = ((Date) config.get(ConfigKeyEnum.UPDATE_TIME.getKey())).getTime();
    if (updateTime == configLastUpdateTime) {
        log.debug("config表未更新");
        return;
    }
    log.debug("config表已更新,重新加载config到shared variable");
    configLastUpdateTime = updateTime;
    try {
        configuration.setSharedVariable("config", config);
    } catch (TemplateModelException e) {
        e.printStackTrace();
    }
}
 
Example #2
Source Project: kieker   Author: kieker-monitoring   File: AbstractAspect.java    License: Apache License 2.0 6 votes vote down vote up
@After("monitoredOperation() && notWithinKieker()")
public void afterOperation(final StaticPart jpStaticPart) {
	if (!CTRLINST.isMonitoringEnabled()) {
		return;
	}

	final String operationSignature = this.signatureToLongString(jpStaticPart.getSignature());
	if (!CTRLINST.isProbeActivated(operationSignature)) {
		return;
	}

	final int stackIndex = this.currentStackIndex.get().decrementValue();
	if (stackIndex == 1) {
		TRACEREGISTRY.unregisterTrace();
	}
}
 
Example #3
Source Project: layui-admin   Author: gameloft9   File: ControllerAOP.java    License: MIT License 6 votes vote down vote up
/**
 * 应用日志存储
 * */
@After("operLogCut() && @annotation(operLog)")
public void logAdvisor(BizOperLog operLog){
	log.info("进入操作日志切面");
	// 添加记录日志
	HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();

	UserTest user = (UserTest)SecurityUtils.getSubject().getPrincipal();
	String userid = user.getId();// 操作员ID
	String loginName = user.getLoginName();
	String ipAddr = IPUtil.getIpAddr(request);// 访问段ip

	//从注解中获取操作类型和备注
	String opertype =  operLog.operType().getValue();
	String memo = operLog.memo();
	sysOperLogServiceImpl.insertOperLog(userid,loginName,ipAddr,opertype,memo);
	log.info("记录操作日志成功");
}
 
Example #4
Source Project: bonita-ui-designer   Author: bonitasoft   File: RepositoryAspect.java    License: GNU General Public License v2.0 5 votes vote down vote up
@After("execution(* org.bonitasoft.web.designer.repository.Repository+.updateLastUpdateAndSave(..)) ")
public void postSaveAndUpdateDate(JoinPoint joinPoint) {
    try {
        handler.postSave(filePath(joinPoint));
    } catch (ResourceNotFoundException e) {
        throw new RepositoryException("An error occured while proceeding post save action.", e);
    }
}
 
Example #5
Source Project: kieker   Author: kieker-monitoring   File: SynchronizedAspect.java    License: Apache License 2.0 5 votes vote down vote up
@After("lock() && args(lock) && notWithinKieker()")
public final void afterMonitorEntry(final Object lock) {
	if (!CTRLINST.isMonitoringEnabled()) {
		return;
	}
	final TraceMetadata trace = TRACEREGISTRY.getTrace();
	if (trace != null) { // ignore monitorEntry if not inside of a trace!
		final long traceId = trace.getTraceId();
		final int orderId = trace.getNextOrderId();
		CTRLINST.newMonitoringRecord(new MonitorEntryEvent(TIME.getTime(), traceId, orderId, System.identityHashCode(lock)));
	}
}
 
Example #6
Source Project: Spring   Author: iooifun   File: AfterAdvice.java    License: Apache License 2.0 5 votes vote down vote up
@After("execution(* *(..))")
public void exiting(JoinPoint joinPoint) {
	afterCalled = true;
	log.info("exiting " + joinPoint.getSignature());
	for (Object arg : joinPoint.getArgs()) {
		log.info("Arg : " + arg);
	}
}
 
Example #7
Source Project: Goku.Framework.CoreUI   Author: nbfujx   File: LoggerAspect.java    License: MIT License 5 votes vote down vote up
@After("execution(* com.goku.coreui.**.controller..*.*(..))")
public void After(JoinPoint point){
    Object target = point.getTarget();
    //this.logger.info(target.toString());
    String method = point.getSignature().getName();
    //this.logger.info(method);
    Class<?>[] classz = target.getClass().getInterfaces();
    Class<?>[] parameterTypes = ((MethodSignature) point.getSignature())
            .getMethod().getParameterTypes();
    try {
        Method m = classz[0].getMethod(method, parameterTypes);
        if (m != null && m.isAnnotationPresent(LoggerInfo.class)) {
            LoggerInfo loggerinfo = m.getAnnotation(LoggerInfo.class);
            Subject subject = SecurityUtils.getSubject();
            //this.logger.info("oper:"+loggerinfo.Name()+"|"+"method"+ loggerinfo.Method());
            SysLog syslog=new SysLog();
            String uuid = UUID.randomUUID().toString().replaceAll("-", "");
            syslog.setId(uuid);
            syslog.setUsername((String) subject.getPrincipal());
            syslog.setIp(subject.getSession().getHost());
            syslog.setOperation(loggerinfo.Name());
            syslog.setMethod(loggerinfo.Method());
            syslog.setParams(JSON.toJSONString (point.getArgs()));
            syslog.setCreateDate(new Date());
            syslogmapper.insert(syslog);
        }

    } catch (Exception e) {
       // e.printStackTrace();
    }
}
 
Example #8
Source Project: Mykit   Author: sunshinelyz   File: Interceptor.java    License: Apache License 2.0 5 votes vote down vote up
@After("aspect()")
public void doAfter(JoinPoint joinPoint) {
    System.out.println("===========执行后置通知==============");
    if(log.isInfoEnabled()){
        log.info("after " + joinPoint);
    }
}
 
Example #9
Source Project: Shiro-Action   Author: zhaojun1998   File: LoginLogAspect.java    License: MIT License 5 votes vote down vote up
@After("loginLogPointCut()")
public void recordLoginLog(JoinPoint joinPoint) {
    // 获取登陆参数
    Object[] args = joinPoint.getArgs();
    User user = (User) args[0];

    Subject subject = SecurityUtils.getSubject();

    String ip = IPUtils.getIpAddr();
    loginLogService.addLog(user.getUsername(), subject.isAuthenticated(), ip);
}
 
Example #10
Source Project: pybbs   Author: tomoya92   File: RedisCachePlugin.java    License: GNU Affero General Public License v3.0 5 votes vote down vote up
@After("co.yiiu.pybbs.hook.UserServiceHook.delRedisUser()")
public void userDelRedisUser(JoinPoint joinPoint) {
  User user = (User) joinPoint.getArgs()[0];
  redisService.delString(String.format(RedisKeys.REDIS_USER_ID_KEY, user.getId()));
  redisService.delString(String.format(RedisKeys.REDIS_USER_USERNAME_KEY, user.getUsername()));
  redisService.delString(String.format(RedisKeys.REDIS_USER_TOKEN_KEY, user.getToken()));
  redisService.delString(String.format(RedisKeys.REDIS_USER_MOBILE_KEY, user.getMobile()));
  redisService.delString(String.format(RedisKeys.REDIS_USER_EMAIL_KEY, user.getEmail()));
}
 
Example #11
Source Project: SpringBoot-Base-System   Author: jxnu-liguobin   File: WebLogAspect.java    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * 授权修改之后调用
 * 
 * @author 梦境迷离.
 * @time 上午9:32:02
 * @version V1.0
 *
 */
@After(value = "shiroAop()")
public void afterGrant(JoinPoint point) {
	int id = (int) point.getArgs()[0];
	log.info("第一个参数是用户id:{}", id);
	RealmSecurityManager rsm = (RealmSecurityManager) SecurityUtils.getSecurityManager();
	MyRealm realm = (MyRealm) rsm.getRealms().iterator().next();
	realm.clearCachedAuthorization(id);
}
 
Example #12
Source Project: SpringBoot-Base-System   Author: jxnu-liguobin   File: WebLogAspect.java    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * 使用@After在切入点结尾处切入内容
 * 
 * @author 梦境迷离
 * @time 下午4:37:17.
 */
@After(value = "webLog()")
public void doAfter(JoinPoint joinPoint) {
	// 处理完请求,返回内容
	log.info("FINISH : " + joinPoint.getClass());

}
 
Example #13
Source Project: Tracker   Author: Liberuman   File: ViewClickedEventAspect.java    License: MIT License 5 votes vote down vote up
@After("execution(* android.view.View.OnClickListener.onClick(android.view.View))")
public void viewClicked(final ProceedingJoinPoint joinPoint) {
	/**
	 * 保存点击事件
	 */
	Context context = getContext(joinPoint.getThis());
	try {
		joinPoint.proceed();
	} catch (Throwable e) {
		e.printStackTrace(System.err);
	}
}
 
Example #14
Source Project: biliob_backend   Author: Jannchie   File: CheckExecutingAspect.java    License: MIT License 5 votes vote down vote up
@After("checkExecuting()")
public void doAfter(JoinPoint jp) {
    String methodName = jp.getSignature().getName();
    if (executing.remove(methodName)) {
        logger.debug("[END] {} {}", methodName, Thread.currentThread());
    }
}
 
Example #15
Source Project: pybbs   Author: tomoya92   File: ElasticSearchPlugin.java    License: GNU Affero General Public License v3.0 5 votes vote down vote up
@After("co.yiiu.pybbs.hook.IndexedServiceHook.batchDeleteIndex()")
public void batchDeleteIndex(JoinPoint joinPoint) {
    if (elasticSearchService.instance() != null) {
        List<Topic> topics = topicMapper.selectList(null);
        List<Integer> ids = topics.stream().map(Topic::getId).collect(Collectors.toList());
        elasticSearchService.bulkDeleteDocument("topic", ids);
    }
}
 
Example #16
Source Project: Surgeon   Author: TangXiaoLv   File: ReplaceAbleAspect.java    License: Apache License 2.0 5 votes vote down vote up
@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());
}
 
Example #17
Source Project: pybbs   Author: tomoya92   File: ElasticSearchPlugin.java    License: GNU Affero General Public License v3.0 5 votes vote down vote up
@After("co.yiiu.pybbs.hook.IndexedServiceHook.indexAllTopic()")
public void indexAllTopic() {
    if (elasticSearchService.instance() != null) {
        List<Topic> topics = topicMapper.selectList(null);
        Map<String, Map<String, Object>> sources = topics.stream().collect(Collectors.toMap(key -> String.valueOf(key
                .getId()), value -> {
            Map<String, Object> map = new HashMap<>();
            map.put("title", value.getTitle());
            map.put("content", value.getContent());
            return map;
        }));
        elasticSearchService.bulkDocument("topic", sources);
    }
}
 
Example #18
Source Project: allure-java   Author: allure-framework   File: AllureAspectJ.java    License: Apache License 2.0 5 votes vote down vote up
@After("anyAssertCreation()")
public void logAssertCreation(final JoinPoint joinPoint) {
    final String actual = joinPoint.getArgs().length > 0
            ? ObjectUtils.toString(joinPoint.getArgs()[0])
            : "<?>";
    final String uuid = UUID.randomUUID().toString();
    final String name = String.format("assertThat \'%s\'", actual);

    final StepResult result = new StepResult()
            .setName(name)
            .setStatus(Status.PASSED);

    getLifecycle().startStep(uuid, result);
    getLifecycle().stopStep(uuid);
}
 
Example #19
Source Project: lams   Author: lamsfoundation   File: AbstractAspectJAdvisorFactory.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example #20
Source Project: OkDeepLink   Author: jjerry   File: DeepLinkServiceProcessor.java    License: Apache License 2.0 5 votes vote down vote up
private MethodSpec generateInitMethod(List<AddressElement> addressElements) {

        CodeBlock.Builder initializer = CodeBlock.builder();
        for (AddressElement element : addressElements) {
            List<String> deepLinkPaths = element.getDeepLinkPaths();
            if (!element.isPathsEmpty()) {
                for (String deepLinkPath : deepLinkPaths) {
                    TypeMirror activityTypeMirror = element.getActivityTypeMirror();
                    TypeMirror supportTypeMirror = elements.getTypeElement(ACTIVITY).asType();
                    if (activityTypeMirror != null) {
                        if (!types.isSubtype(activityTypeMirror, supportTypeMirror)) {
                            logger.error(Activity.class.getName() + " only support class which extends " + ACTIVITY, element.getElement());
                        }
                    }
                    ClassName activityClassName = element.getActivityClassName();
                    if (activityClassName != null) {
                        initializer.add("$T.addAddress(new $T($S, $T.class));\n",
                                DEEP_LINK_CLIENT, DEEP_LINK_ENTRY, deepLinkPath, activityClassName);
                    }
                }
            }

        }
        MethodSpec.Builder initMethod = MethodSpec.methodBuilder("init")
                .addModifiers(Modifier.PUBLIC)
                .addAnnotation(AnnotationSpec.builder(After.class).addMember("value", "$S", "execution(* " + INIT_METHOD_NAME + ")").build())
                .addCode(initializer.build());

        return initMethod.build();
    }
 
Example #21
Source Project: pybbs   Author: tomoya92   File: ElasticSearchPlugin.java    License: GNU Affero General Public License v3.0 5 votes vote down vote up
@After("co.yiiu.pybbs.hook.IndexedServiceHook.indexTopic()")
public void indexTopic(JoinPoint joinPoint) {
    if (elasticSearchService.instance() != null) {
        Object[] args = joinPoint.getArgs();
        Map<String, Object> source = new HashMap<>();
        source.put("title", args[1]);
        source.put("content", args[2]);
        elasticSearchService.createDocument("topic", (String) args[0], source);
    }
}
 
Example #22
Source Project: apollo   Author: ctripcorp   File: NamespaceUnlockAspect.java    License: Apache License 2.0 5 votes vote down vote up
@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()));
}
 
Example #23
Source Project: spring4-understanding   Author: langtianya   File: AbstractAspectJAdvisorFactory.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example #24
Source Project: pybbs   Author: tomoya92   File: RedisCachePlugin.java    License: GNU Affero General Public License v3.0 5 votes vote down vote up
@After("co.yiiu.pybbs.hook.UserServiceHook.delRedisUser()")
public void userDelRedisUser(JoinPoint joinPoint) {
    User user = (User) joinPoint.getArgs()[0];
    redisService.delString(String.format(RedisKeys.REDIS_USER_ID_KEY, user.getId()));
    redisService.delString(String.format(RedisKeys.REDIS_USER_USERNAME_KEY, user.getUsername()));
    redisService.delString(String.format(RedisKeys.REDIS_USER_TOKEN_KEY, user.getToken()));
    redisService.delString(String.format(RedisKeys.REDIS_USER_MOBILE_KEY, user.getMobile()));
    redisService.delString(String.format(RedisKeys.REDIS_USER_EMAIL_KEY, user.getEmail()));
}
 
Example #25
Source Project: spring-analysis-note   Author: Vip-Augus   File: AbstractAspectJAdvisorFactoryTests.java    License: MIT License 4 votes vote down vote up
@After("execution(* echo(*))")
public void invoked() {
	++afterCount;
}
 
Example #26
Source Project: spring-analysis-note   Author: Vip-Augus   File: ConfigurationClassAspectIntegrationTests.java    License: MIT License 4 votes vote down vote up
@After("execution(* java.lang.Runnable.*(..))")
public void after(JoinPoint joinPoint) {
	count++;
}
 
Example #27
Source Project: spring-analysis-note   Author: Vip-Augus   File: AspectJTest.java    License: MIT License 4 votes vote down vote up
@After("test()")
public void afterTest() {
	System.out.println("after Test");
}
 
Example #28
Source Project: spring-boot-demo   Author: smltq   File: Agent.java    License: MIT License 4 votes vote down vote up
@After("IService()")
public void after() {
    System.out.println(agent + "交钥匙");
}
 
Example #29
Source Project: open-capacity-platform   Author: open-capacity-platform   File: DataSourceAspect.java    License: Apache License 2.0 4 votes vote down vote up
@After("@annotation(ds)")
public void restoreDataSource(JoinPoint point, DataSource ds) {
    logger.debug("Revert DataSource : {transIdo} > {}", ds.name(), point.getSignature());
    DataSourceHolder.clearDataSourceKey();
}
 
Example #30
Source Project: spring-examples   Author: HaydiKodlayalim   File: ServiceAspect.java    License: GNU General Public License v3.0 4 votes vote down vote up
@After("execution(* com.haydikodlayalim.aop.service.*.*(..))")
public void mesajVerMetodundanSonra(JoinPoint joinPoint) {
    System.out.println("Mesaj ver metodundan sonra parametre yakalandi param: " + joinPoint.getArgs()[0]);
    System.out.println(joinPoint.getSignature());
}