org.springframework.aop.support.StaticMethodMatcherPointcut Java Examples

The following examples show how to use org.springframework.aop.support.StaticMethodMatcherPointcut. 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: LogConfiguration.java    From seed with Apache License 2.0 6 votes vote down vote up
@Override
public Pointcut getPointcut() {
    return new StaticMethodMatcherPointcut(){
        @Override
        public boolean matches(Method method, Class<?> targetClass) {
            //若类上面注解了DisableLog,则不打印日志(仅此类,不包括该类中被调用的类)
            if(targetClass.isAnnotationPresent(DisableLog.class)){
                return false;
            }
            //若方法上面注解了DisableLog,则不打印日志
            if(method.isAnnotationPresent(DisableLog.class)){
                return false;
            }
            //若类上面注解了EnableLog,则打印日志
            if(targetClass.isAnnotationPresent(EnableLog.class)){
                return true;
            }
            //若方法上面注解了EnableLog,则打印日志
            if(method.isAnnotationPresent(EnableLog.class)){
                return true;
            }
            //默认的:打印标注了RestController的类、以及ResponseBody的方法,的日志
            return targetClass.isAnnotationPresent(RestController.class) || method.isAnnotationPresent(ResponseBody.class);
        }
    };
}
 
Example #2
Source File: BenchmarkTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
public static Advisor advisor() {
	return new DefaultPointcutAdvisor(
		new StaticMethodMatcherPointcut() {
			@Override
			public boolean matches(Method method, Class<?> targetClass) {
				return method.getParameterCount() == 1 &&
					method.getParameterTypes()[0].equals(Integer.class);
			}
		},
		new TraceAfterReturningAdvice());
}
 
Example #3
Source File: BenchmarkTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
public static Advisor advisor() {
	return new DefaultPointcutAdvisor(
		new StaticMethodMatcherPointcut() {
			@Override
			public boolean matches(Method method, Class<?> targetClass) {
				return method.getReturnType().equals(String.class);
			}
		},
		new TraceBeforeAdvice());
}
 
Example #4
Source File: HandlerMethodAnnotationDetectionTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
private static StaticMethodMatcherPointcut getControllerPointcut() {
	return new StaticMethodMatcherPointcut() {
		@Override
		public boolean matches(Method method, @Nullable Class<?> targetClass) {
			return ((AnnotationUtils.findAnnotation(targetClass, Controller.class) != null) ||
					(AnnotationUtils.findAnnotation(targetClass, RequestMapping.class) != null));
		}
	};
}
 
Example #5
Source File: BenchmarkTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
public static Advisor advisor() {
	return new DefaultPointcutAdvisor(
		new StaticMethodMatcherPointcut() {
			@Override
			public boolean matches(Method method, Class<?> targetClass) {
				return method.getParameterCount() == 1 &&
					method.getParameterTypes()[0].equals(Integer.class);
			}
		},
		new TraceAfterReturningAdvice());
}
 
Example #6
Source File: BenchmarkTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
public static Advisor advisor() {
	return new DefaultPointcutAdvisor(
		new StaticMethodMatcherPointcut() {
			@Override
			public boolean matches(Method method, Class<?> targetClass) {
				return method.getReturnType().equals(String.class);
			}
		},
		new TraceBeforeAdvice());
}
 
Example #7
Source File: HandlerMethodAnnotationDetectionTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
private static StaticMethodMatcherPointcut getControllerPointcut() {
	return new StaticMethodMatcherPointcut() {
		@Override
		public boolean matches(Method method, @Nullable Class<?> targetClass) {
			return ((AnnotationUtils.findAnnotation(targetClass, Controller.class) != null) ||
					(AnnotationUtils.findAnnotation(targetClass, RequestMapping.class) != null));
		}
	};
}
 
Example #8
Source File: BenchmarkTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
public static Advisor advisor() {
	return new DefaultPointcutAdvisor(
		new StaticMethodMatcherPointcut() {
			@Override
			public boolean matches(Method method, Class<?> targetClass) {
				return method.getParameterTypes().length == 1 &&
					method.getParameterTypes()[0].equals(Integer.class);
			}
		},
		new TraceAfterReturningAdvice());
}
 
Example #9
Source File: BenchmarkTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
public static Advisor advisor() {
	return new DefaultPointcutAdvisor(
		new StaticMethodMatcherPointcut() {
			@Override
			public boolean matches(Method method, Class<?> targetClass) {
				return method.getReturnType().equals(String.class);
			}
		},
		new TraceBeforeAdvice());
}
 
Example #10
Source File: HandlerMethodAnnotationDetectionTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
private static StaticMethodMatcherPointcut getControllerPointcut() {
	return new StaticMethodMatcherPointcut() {
		@Override
		public boolean matches(Method method, Class<?> targetClass) {
			return ((AnnotationUtils.findAnnotation(targetClass, Controller.class) != null) ||
					(AnnotationUtils.findAnnotation(targetClass, RequestMapping.class) != null));
		}
	};
}