728x90 Spring153 스프링 Part2 AOP 강좌 06강 _ After Returning / Throwing 어드바이스 구현하기 before 실행 주업무 실행(정상 작동) 주업무 실행(오류) afterReturning실행 afterThrowing실행 setting.xml kor값이 100을 넘지 않으므로 오류 발생하지 않고 afterReturning정상 출력 setting.xml kor값이 101로 100을 넘었으므로 NewlecExam.java total()메서드에 의해 오류 발생하여 afterThrowing실행 package spring.aop; import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; import java.lang.reflect.Proxy; import org.springframework.context.ApplicationCont.. 2022. 1. 2. 스프링 Part2 AOP 강좌 05강 _ BeforeAdvice 구현하기 package spring.aop; import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; import java.lang.reflect.Proxy; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; import spring.aop.entity.Exam; import spring.aop.entity.N.. 2022. 1. 2. 스프링 Part2 AOP 강좌 04강 _ 스프링으로 AOP 구현해보기-AroundAdvice Exam target = (Exam)context.getBean("target"); 변수명을 proxy로 두면 주업무+보조업무를 실행하게 되고 target으로 두고 실행하면 주업무만 실행하게 된다. package spring.aop; import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; import java.lang.reflect.Proxy; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springfram.. 2022. 1. 2. 스프링 Part2 AOP 강좌 03강 - 순수 자바로 AOP 구현해보기 클래스 생성 https://www.youtube.com/watch?v=pr2dwdf_03k&list=PLq8wAnVUcTFUHYMzoV2RoFoY2HDTKru3T&index=20 2022. 1. 2. 스프링 Part2 AOP 강좌 02강 _ AOP 자바 코드 이해하기 위는 과거 방식인데 AOP는 소스코드가 없더라도 구현 가능하다 좌측은 보조업무 우측은 주업무 2021. 12. 28. 스프링 Part2 AOP 강좌 01강 - AOP(Aspect Oriented Programming) 이란? AOP는 스프링과 상관없는 방법론이다. 관점지향 객체 지향보다 더 큰 업무 사용자가 요청한 주 업무(core업무)가 있고 개발자 혹은 운영자가 넣는 부가업무가 있다. 즉 사용자 관점과 개발자 혹은 운영자 관점이 있다. 보조업무에 해당하는 로그처리, 보안처리, 트랜잭션처리 등은 주업무 시작 전, 후에 실행된다. 예전엔 직접 소스에 주석을 달고 지우는 등 작업을 했다 이제 쉽게 보조업무 사이에 주업무를 넣었다 뺏다 하기 위해 나온 것이 AOP 중앙에 저게 프락시? AOP가 스프링으로도 구현 가능하지만 자바만으로도 구현가능하다. 그 후 스프링으로 하면 어떤 차이가 있는지 알아보자. https://www.youtube.com/watch?v=y2JkXjOocZ4&list=PLq8wAnVUcTFUHYMzoV2RoF.. 2021. 12. 28. 스프링 강의 17강 _ XML Configuration을 Java Configuration으로 변경하기 XML파일에 남은 건 뿐이다. @Bean이 컨테이너에 담아 준다. 기능함수가 아니라 컨테이너에서 저런 이름을 가지고 존재하게 된다. exam()은 Id명이기 때문에 명사형태 그대로 써준다. getExam()이런식으로 쓰지 않는다. 클래스 추가 이렇게 만들고 나서 어노테이션 방식 쓸지 xml 방식 쓸지는 우리가 선택하면 된다. ApplicationContext context = new ClassPathXmlApplicationContext("spring/di/setting.xml"); 을 뭘 쓰냐에 따라 결정된다. 이 방식대로 하면 xml을 쓰는 방식이고 ApplicationContext context =new AnnotationConfigApplicationContext(NewlecDiConfig.cla.. 2021. 12. 28. 이전 1 ··· 17 18 19 20 21 22 다음 728x90