Java Code Examples for org.aspectj.lang.reflect.MethodSignature#getDeclaringTypeName()
The following examples show how to use
org.aspectj.lang.reflect.MethodSignature#getDeclaringTypeName() .
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 File: SimplePerformanceMonitor.java From spring-cloud-study with Apache License 2.0 | 6 votes |
@Around("logTime()") public Object timeAround(ProceedingJoinPoint joinPoint) { // 定义返回对象、得到方法需要的参数 Object obj = null; Object[] args = joinPoint.getArgs(); long startTime = System.currentTimeMillis(); try { obj = joinPoint.proceed(args); } catch (Throwable e) { e.printStackTrace(); log.error("统计某方法执行耗时环绕通知出错", e); } // 获取执行的方法名 long endTime = System.currentTimeMillis(); MethodSignature signature = (MethodSignature) joinPoint.getSignature(); String methodName = signature.getDeclaringTypeName() + "." + signature.getName(); // 打印耗时的信息 log.info(String.format("「%s」执行时间为:%d ms",methodName, endTime - startTime)); return obj; }
Example 2
Source File: SimplePerformanceMonitor.java From spring-cloud-study with Apache License 2.0 | 6 votes |
@Around("logTime()") public Object timeAround(ProceedingJoinPoint joinPoint) { // 定义返回对象、得到方法需要的参数 Object obj = null; Object[] args = joinPoint.getArgs(); long startTime = System.currentTimeMillis(); try { obj = joinPoint.proceed(args); } catch (Throwable e) { e.printStackTrace(); log.error("统计某方法执行耗时环绕通知出错", e); } // 获取执行的方法名 long endTime = System.currentTimeMillis(); MethodSignature signature = (MethodSignature) joinPoint.getSignature(); String methodName = signature.getDeclaringTypeName() + "." + signature.getName(); // 打印耗时的信息 log.info(String.format("「%s」执行时间为:%d ms",methodName, endTime - startTime)); return obj; }
Example 3
Source File: TimeInterceptor.java From newblog with Apache License 2.0 | 6 votes |
/** * 环绕通知 * 统计方法执行耗时Around * * @param joinPoint * @return * @throws Throwable */ @Around("execution(* (com.myblog.service.impl.*+&&!com.myblog.service.impl.AsyncServiceImpl).*(..))") public Object timeAround(ProceedingJoinPoint joinPoint) throws Throwable { // 定义返回对象、得到方法需要的参数 Object obj = null; Object[] args = joinPoint.getArgs(); long startTime = System.currentTimeMillis(); // try { obj = joinPoint.proceed(args); // } catch (Throwable e) { // logger.error("统计某方法执行耗时环绕通知出错", e); // } // 获取执行的方法名 long endTime = System.currentTimeMillis(); MethodSignature signature = (MethodSignature) joinPoint.getSignature(); String methodName = signature.getDeclaringTypeName() + "." + signature.getName(); // 打印耗时的信息 this.printExecTime(methodName, startTime, endTime); return obj; }
Example 4
Source File: ControllerAspect.java From SuperBoot with MIT License | 5 votes |
/** * 根据注解判断接口是否限定了特殊访问的角色,配置级别方法级大于类级 * * @param methodSignature 切面对象 * @param token 用户信息 * @return */ public boolean checkAuth(MethodSignature methodSignature, BaseToken token) { //判断方法是否需要权限认证 boolean success = false; AuthRoles cAuth = methodSignature.getMethod().getAnnotation(AuthRoles.class); if (null != cAuth) { success = checkAuthRole(cAuth, token); if (success) { return success; } } //方法校验未通过校验类 if (!success && null == cAuth) { //判断类里所有方法是否全部需要权限认证 cAuth = (AuthRoles) methodSignature.getDeclaringType().getAnnotation(AuthRoles.class); if (null != cAuth) { success = checkAuthRole(cAuth, token); if (success) { return success; } } } //类校验不通过校验授权 if (!success) { //判断用户分配的菜单关联的权限信息 String key = module_id + methodSignature.getDeclaringTypeName() + methodSignature.getName(); //判断用户是否有执行的权限 if (null == redisUtils.getUserResource(token.getUserId())) { throw new BaseException(StatusCode.UNAUTHORIZED); } return redisUtils.getUserResource(token.getUserId()).containsKey(key); } return success; }
Example 5
Source File: ChaosMonkeyBaseAspect.java From chaos-monkey-spring-boot with Apache License 2.0 | 4 votes |
String createSignature(MethodSignature signature) { return signature.getDeclaringTypeName() + "." + signature.getMethod().getName(); }