org.springframework.aop.AfterReturningAdvice Java Examples

The following examples show how to use org.springframework.aop.AfterReturningAdvice. 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: ResultLogAdvisor.java    From BlogManagePlatform with Apache License 2.0 5 votes vote down vote up
/**
 * AOP切点
 * @author Frodez
 * @date 2019-05-10
 */
@Override
public Advice getAdvice() {
	/**
	 * 打印返回值到日志
	 * @param JoinPoint AOP切点
	 * @author Frodez
	 * @date 2019-01-12
	 */
	return (AfterReturningAdvice) (returnValue, method, args, target) -> log.info("{} 返回值:{}", ReflectUtil.fullName(method), JSONUtil
		.string(returnValue));
}
 
Example #2
Source File: AspectJPrecedenceComparatorTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
private Advisor createSpringAOPAfterAdvice(int order) {
	AfterReturningAdvice advice = new AfterReturningAdvice() {
		@Override
		public void afterReturning(Object returnValue, Method method, Object[] args, Object target) throws Throwable {
		}
	};
	DefaultPointcutAdvisor advisor = new DefaultPointcutAdvisor(this.anyOldPointcut, advice);
	advisor.setOrder(order);
	return advisor;
}
 
Example #3
Source File: AsyncResultLogAdvisor.java    From BlogManagePlatform with Apache License 2.0 5 votes vote down vote up
/**
 * AOP切点
 * @author Frodez
 * @date 2019-05-10
 */
@SuppressWarnings("unchecked")
@Override
public Advice getAdvice() {
	/**
	 * 打印返回值到日志
	 * @param JoinPoint AOP切点
	 * @author Frodez
	 * @date 2019-01-12
	 */
	return (AfterReturningAdvice) (returnValue, method, args, target) -> log.info("{} 返回值:{}", ReflectUtil.fullName(method), JSONUtil
		.string(((ListenableFuture<Result>) returnValue).get()));
}
 
Example #4
Source File: AspectJPrecedenceComparatorTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
private Advisor createSpringAOPAfterAdvice(int order) {
	AfterReturningAdvice advice = new AfterReturningAdvice() {
		@Override
		public void afterReturning(@Nullable Object returnValue, Method method, Object[] args, @Nullable Object target) throws Throwable {
		}
	};
	DefaultPointcutAdvisor advisor = new DefaultPointcutAdvisor(this.anyOldPointcut, advice);
	advisor.setOrder(order);
	return advisor;
}
 
Example #5
Source File: AspectJPrecedenceComparatorTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
private Advisor createSpringAOPAfterAdvice(int order) {
	AfterReturningAdvice advice = new AfterReturningAdvice() {
		@Override
		public void afterReturning(@Nullable Object returnValue, Method method, Object[] args, @Nullable Object target) throws Throwable {
		}
	};
	DefaultPointcutAdvisor advisor = new DefaultPointcutAdvisor(this.anyOldPointcut, advice);
	advisor.setOrder(order);
	return advisor;
}
 
Example #6
Source File: AfterReturningAdviceAdapter.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Override
public boolean supportsAdvice(Advice advice) {
	return (advice instanceof AfterReturningAdvice);
}
 
Example #7
Source File: AfterReturningAdviceAdapter.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Override
public MethodInterceptor getInterceptor(Advisor advisor) {
	AfterReturningAdvice advice = (AfterReturningAdvice) advisor.getAdvice();
	return new AfterReturningAdviceInterceptor(advice);
}
 
Example #8
Source File: AfterReturningAdviceInterceptor.java    From java-technology-stack with MIT License 4 votes vote down vote up
/**
 * Create a new AfterReturningAdviceInterceptor for the given advice.
 * @param advice the AfterReturningAdvice to wrap
 */
public AfterReturningAdviceInterceptor(AfterReturningAdvice advice) {
	Assert.notNull(advice, "Advice must not be null");
	this.advice = advice;
}
 
Example #9
Source File: AfterReturningAdviceAdapter.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Override
public boolean supportsAdvice(Advice advice) {
	return (advice instanceof AfterReturningAdvice);
}
 
Example #10
Source File: AfterReturningAdviceInterceptor.java    From spring-analysis-note with MIT License 4 votes vote down vote up
/**
 * Create a new AfterReturningAdviceInterceptor for the given advice.
 * @param advice the AfterReturningAdvice to wrap
 */
public AfterReturningAdviceInterceptor(AfterReturningAdvice advice) {
	Assert.notNull(advice, "Advice must not be null");
	this.advice = advice;
}
 
Example #11
Source File: AfterReturningAdviceAdapter.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public boolean supportsAdvice(Advice advice) {
	return (advice instanceof AfterReturningAdvice);
}
 
Example #12
Source File: AfterReturningAdviceAdapter.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public MethodInterceptor getInterceptor(Advisor advisor) {
	AfterReturningAdvice advice = (AfterReturningAdvice) advisor.getAdvice();
	return new AfterReturningAdviceInterceptor(advice);
}
 
Example #13
Source File: AfterReturningAdviceInterceptor.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Create a new AfterReturningAdviceInterceptor for the given advice.
 * @param advice the AfterReturningAdvice to wrap
 */
public AfterReturningAdviceInterceptor(AfterReturningAdvice advice) {
	Assert.notNull(advice, "Advice must not be null");
	this.advice = advice;
}
 
Example #14
Source File: AfterReturningAdviceAdapter.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Override
public boolean supportsAdvice(Advice advice) {
	return (advice instanceof AfterReturningAdvice);
}
 
Example #15
Source File: AfterReturningAdviceAdapter.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Override
public MethodInterceptor getInterceptor(Advisor advisor) {
	AfterReturningAdvice advice = (AfterReturningAdvice) advisor.getAdvice();
	return new AfterReturningAdviceInterceptor(advice);
}
 
Example #16
Source File: AfterReturningAdviceInterceptor.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
/**
 * Create a new AfterReturningAdviceInterceptor for the given advice.
 * @param advice the AfterReturningAdvice to wrap
 */
public AfterReturningAdviceInterceptor(AfterReturningAdvice advice) {
	Assert.notNull(advice, "Advice must not be null");
	this.advice = advice;
}
 
Example #17
Source File: AfterReturningAdviceAdapter.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Override
public MethodInterceptor getInterceptor(Advisor advisor) {
	AfterReturningAdvice advice = (AfterReturningAdvice) advisor.getAdvice();
	return new AfterReturningAdviceInterceptor(advice);
}