전체 글
-
[Spring] After Returning / Throwing Advice프로그래밍 공부/Spring 2021. 5. 5. 14:54
뉴렉처 강사님의 동영상 강의를 정리한 글입니다. After Returning package spring.aop.advice; import java.lang.reflect.Method; import org.springframework.aop.AfterReturningAdvice; public class LogAfterReturningAdvice implements AfterReturningAdvice{ @Override public void afterReturning(Object returnValue, Method method, Object[] args, Object target) throws Throwable { // TODO Auto-generated method stub System.out.print..
-
[Spring] BeforeAdvice 구현하기프로그래밍 공부/Spring 2021. 5. 5. 14:35
뉴렉처 강사님의 동영상 강의를 정리한 글입니다. 간단하게 MethodBeforeAdvice를 구현한 클래스를 사용하여 BeforeAdvice를 구현할 수 있다. LogBeforeAdvice.java package spring.aop.advice; import java.lang.reflect.Method; import org.springframework.aop.MethodBeforeAdvice; public class LogBeforeAdvice implements MethodBeforeAdvice{ @Override public void before(Method method, Object[] args, Object target) throws Throwable { // TODO Auto-generated ..
-
[Spring] 스프링 AOP 구현해보기 - AroundAdvice프로그래밍 공부/Spring 2021. 5. 5. 14:21
뉴렉처 강사님의 동영상 강의를 정리한 글입니다. Advice : 부가 업무 로직을 언제 주 업무 로직에 적용할 지 정의한 것 - Before: 주 업무 로직 실행 전 - After returnning: 주 업무 실행 후 - After throwing: 대상 객체의 메서드가 예외를 발생시킨 경우 - Around: 주 업무 실행 전, 후 xml 파일에서 proxy 만들기 Program.java ApplicationContext context = new ClassPathXmlApplicationContext("spring/aop/setting.xml"); Exam exam = new NewlecExam(1,1,1,1); Exam proxy = (Exam)context.getBean("proxy"); Syste..
-
[Spring] AOP 코드 구현하기프로그래밍 공부/Spring 2021. 5. 5. 13:14
뉴렉처 강사님의 동영상 강의를 정리한 글입니다. Proxy 이용하여 업무 로직, 부가 로직 분리하기 package spring.aop; import java.lang.reflect.Method; import org.springframework.cglib.proxy.InvocationHandler; import org.springframework.cglib.proxy.Proxy; import spring.aop.entity.Exam; import spring.aop.entity.NewlecExam; public class Program { public static void main(String[] args) { Exam exam = new NewlecExam(1,1,1,1); Exam proxy = (Ex..
-
[Spring] AOP란?프로그래밍 공부/Spring 2021. 5. 5. 12:12
뉴렉처 강사님의 동영상 강의를 정리한 글입니다. AOP란? : Aspect Oriented Programming Object Oriented Programming: 사용자가 원하는 업무 기반의 로직을 프로그래밍 한 것 사용자가 요구한 업무를 개발하기 위해 개발자, 운영자, 관리자가 넣은 코드. 사용자는 모르는 부가적인 코드 즉, 관점에 따라 프로그래밍을 달리하게 됨 (객체 지향 프로그래밍보다 더 큰 개념) Concern Primary Concern: 관점에 해당되는 것 중에 주 관심사(주 업무 로직)에 해당하는 것 Cross-cutting Concern: 개발자, 운영자가 주 업무 로직을 개발하기 위해 넣은 부가적인 로직 AOP 구현 방식 : 주 업무 로직이 아닌 부가 로직을 Core Concern에 직..
-
[Spring] Java Configuration프로그래밍 공부/Spring 2021. 5. 5. 11:37
뉴렉처 강사님의 동영상 강의를 정리한 글입니다. xml으로 작성된 configuration 파일을 java 파일로 바꾸기 1. 설정을 위한 자바 파일: @Configuration 2. componentScan: @ComponentScan("spring.di.ui") //setting.xml + 여러 패키지를 컴포넌트 스캔하고 싶은 경우 @ComponentScan({"spring.di.ui", "spring.di.entity"}) 3. bean 객체 생성 setting.xml //setting.xml config.java @Bean public Exam exam(){ return new NewlecExam(); } 일반적인 메서드가 아닌 컨테이너에 객체를 담아주는 역할 - exam이라는 id로 컨테이너에 ..
-
[Spring] @Component의 종류와 시멘틱 @Component프로그래밍 공부/Spring 2021. 4. 30. 22:48
뉴렉처 강사님의 동영상 강의를 정리한 글입니다. 기본 값 설정을 위한 @Value 어노테이션 @Component 어노테이션으로 생성되는 객체의 값을 설정해주기 위한 어노테이션이다. 다음과 같이 사용한다. NewlecExam.java @Component("exam2") public class NewlecExam implements Exam { @Value("20") private int kor; @Value("30") private int eng; private int math; private int com; public NewlecExam() { } } MVC 애플리케이션을 제작할 때 각 객체(Component)의 역할을 알기 쉽게 하기 위해(의미를 분명하게 하기 위해) @Controller, @Serv..