Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

支持 旧的 Aop 使用方式 主要是注解方式 #183

Open
TAKETODAY opened this issue Nov 1, 2022 · 0 comments
Open

支持 旧的 Aop 使用方式 主要是注解方式 #183

TAKETODAY opened this issue Nov 1, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@TAKETODAY
Copy link
Owner

public class LogAspect {

  @Autowired
  public LogAspect(UserService service) {
    log.debug("{}", service);
  }

  //  public void afterReturning(@Returning Object returnValue) {
  public void afterReturning() {
//        log.debug("LogAspect @AfterReturning returnValue: [{}]", returnValue);
    log.debug("LogAspect @AfterReturning");
  }

  public void afterThrowing(@Throwing Throwable throwable) {
    log.error("LogAspect @AfterThrowing With Msg: [{}]", throwable.getMessage(), throwable);
  }

  public void before(@Annotated Logger logger) {
//	public void before(@Annotated Logger logger, @Argument User user) {
//        log.debug("LogAspect @Before method in class with logger: [{}] , Argument:[{}]", logger.value(), user);
    log.debug("LogAspect @Before method in class with logger: [{}]", logger.value());
  }

  public Object after(@Returning User returnValue, @Arguments Object[] arguments) {
    log.debug("LogAspect @After method in class");
    return returnValue.setIntroduce("女");
  }

  public Object around(@JoinPoint Joinpoint joinpoint) throws Throwable {
    log.debug("LogAspect @Around Before method");
//        int i = 1 / 0;
    Object proceed = joinpoint.proceed();
    log.debug("LogAspect @Around After method");
    return proceed;
  }

}
@TAKETODAY TAKETODAY added the enhancement New feature or request label Mar 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant