package tools;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;
@Aspect
@Component
public class Audience {
private long startTime;
@Pointcut("execution(** concert.Performance.perform(..))")
public void performance() {
}
@Before("performance()")
public void silenceCellPhones() {
System.out.println("Silencing cell phones");
}
@Before("performance()")
public void takeSeats() {
System.out.println("Taking seats");
}
@AfterReturning("performance()")
public void applause() {
System.out.println("CLAP CLAP CLAP");
}
@AfterThrowing(value = "performance()", throwing = "throwable")
public void demandRefund(Throwable throwable){
System.out.println("Demanding a refund. " + throwable);
}
}
评论
登录后参与技术讨论,分享你的经验与见解。
登录 / 注册暂无评论