일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
- jpa
- java
- 그리디
- 알고리즘
- Servlet
- SpringBoot
- 백준
- 스프링 핵심 기능
- db
- 자바
- http
- 인프런
- kotlin
- JDBC
- Proxy
- 스프링
- AOP
- spring
- Android
- 김영한
- QueryDSL
- Greedy
- 스프링 핵심 원리
- Exception
- transaction
- springdatajpa
- JPQL
- Spring Boot
- Thymeleaf
- pointcut
- Today
- Total
목록pointcut (16)
개발자되기 프로젝트
@Retry 애노테이션이 있으면 예외가 발생했을 때 다시 시도해서 문제를 복구한다. 1. @Retry Retry방식을 사용할 때 항상 재시도 횟수가 정해져 있어야 함. @Target(ElementType.METHOD) @Retention(RetentionPolicy.RUNTIME) public @interface Retry { int value() default 3; //Retry는 항상 재시도 횟수가 있어야함.. } 2. RetryAspect @Slf4j @Aspect public class RetryAspect { /* @Around("@annotation(hello.aop.exam.annotation.Retry)") public Object doRetry(ProceedingJoinPoint join..
@Trace 가 메서드에 붙어 있으면 호출 정보가 출력되도록 하자. 1. @Trace @Target(ElementType.METHOD) @Retention(RetentionPolicy.RUNTIME) public @interface Trace { } 2. TraceAspect @Slf4j @Aspect public class TraceAspect { @Before("@annotation(hello.aop.exam.annotation.Trace)") public void doTrace(JoinPoint joinPoint){ Object[] args = joinPoint.getArgs(); log.info("[trace] {}, args={}", joinPoint.getSignature(), args); }..
1. 정의 this : 스프링 빈 객체(스프링 AOP 프록시)를 대상으로 하는 조인 포인트 target : Target 객체(스프링 AOP 프록시가 가르키는 실제 대상)를 대상으로 하는 조인 포인트 2. 설명 this , target 은 다음과 같이 적용 타입 하나를 정확하게 지정해야 한다. this(hello.aop.member.MemberService) target(hello.aop.member.MemberService) * 같은 패턴을 사용할 수 없다. 부모 타입을 허용한다. 3. this vs target 스프링에서 AOP를 적용하면 실제 target 객체 대신에 프록시 객체가 스프링 빈으로 등록된다. this 는 스프링 빈으로 등록되어 있는 프록시 객체를 대상으로 포인트컷을 매칭한다. Targe..
1. bean 스프링 전용 포인트컷 지시자, 빈의 이름으로 지정한다 스프링 빈의 이름으로 AOP 적용 여부를 지정한다. bean(orderService) || bean(*Repository) * 과 같은 패턴을 사용할 수 있다. 2. Test @Slf4j @Service public class OrderService { private final OrderRepository orderRepository; public OrderService(OrderRepository orderRepository) { this.orderRepository = orderRepository; } public void orderItem(String itemId) { log.info("[orderService] 실행"); orde..
1. 정의 @target : 실행 객체의 클래스에 주어진 타입의 애노테이션이 있는 조인 포인트 @within : 주어진 애노테이션이 있는 타입 내 조인 포인트 2.설명 @target , @within 은 다음과 같이 타입에 있는 애노테이션으로 AOP 적용 여부를 판단한다. @target(hello.aop.member.annotation.ClassAop) -->@ClassAop붙은 타입에 AOP 적용됨 @within(hello.aop.member.annotation.ClassAop) -->@ClassAop붙은 타입에 AOP 적용됨 @ClassAop class Target{} 3. @target vs @within @target 인스턴스의 모든 메서드를 조인 포인트로 적용한다. 부모 클래스의 메서드까지 어드..
args : 인자가 주어진 타입의 인스턴스인 조인 포인트로 매칭 기본 문법은 execution 의 args 부분과 같다. 1. execution과 args의 차이점 execution 은 파라미터 타입이 정확하게 매칭되어야 한다. execution 은 클래스에 선언된 정보를 기반으로 판단한다. args 는 부모 타입을 허용한다. args 는 실제 넘어온 파라미터 객체 인스턴스를 보고 판단한다. 2. Argstest @Slf4j public class ArgsTest { Method helloMethod; @BeforeEach public void init() throws NoSuchMethodException { helloMethod = MemberServiceImpl.class.getMethod("hel..
1. 타입 매칭 - 부모 타입 허용 @Test void typeExactMatch(){ pointcut.setExpression("execution(* hello.aop.member.MemberServiceImpl.*(..))"); assertThat(pointcut.matches(helloMethod, MemberServiceImpl.class)).isTrue(); } @Test void typeMatchSuperType(){ pointcut.setExpression("execution(* hello.aop.member.MemberService.*(..))"); assertThat(pointcut.matches(helloMethod, MemberServiceImpl.class)).isTrue(); } ..
1. Annotation @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) public @interface ClassAop { } @Target(ElementType.METHOD) @Retention(RetentionPolicy.RUNTIME) //Runtime때까지 annotation유지 public @interface MethodAop { String value(); } @Target: Indicates the contexts in which an annotation type is applicable. @Retention: Indicates how long annotations with the annotated type are to be r..