프로그래밍 공부
-
Servlet 프로그램 만들기프로그래밍 공부/Servlet과 JSP 2021. 5. 18. 22:27
뉴렉처 강사님의 동영상 강의를 정리한 글입니다. Servlet 서버 어플리케이션을 만들기 위한 것. 서버 어플리케이션은 기능별로 코드나 나뉘어 있다. -> 모든 기능이 함께 쓰이는 것이 아닌 필요에 따라 쓰이는 기능이 다르기 때문이다. 자바에서 main 함수를 생성하여 코드를 동작하듯, servlet에서 service 함수를 생성하여 기능을 동작하도록 한다. Servlet은 WAS에 의해 load가 되고 실행된다. 클래스 명은 상관없지만, 약속되어 있는 인터페이스, 추상클래스 명에 따라 서블릿을 참조하게 된다. (ex. HttpServlet) 웹 서버와 WAS는 URL과 매핑된 Servlet 코드를 찾아 실행해주는 역할을 한다. 따라서 사용자가 Servlet class를 요청하는 것이 아니라 url을 통..
-
[Spring] 간소화된 Advisor프로그래밍 공부/Spring 2021. 5. 5. 17:00
뉴렉처 강사님의 동영상 강의를 정리한 글입니다. 간소화된 Advisor : point cut과 advisor를 합친 것. 따로 생성 해줄 필요 없이 한 번에 생성 가능 NameMatchMethodPointcutAdvisor total avg mappedNames를 이용하여 weaving 하고 싶은 메서드를 여러 개 줄 수 있음. 도 가능함 RegexpMethodPointcutAdvisor .*to.* 정규식을 이용하여 메서드 이름을 전달 할 수 있음
-
[Spring] Point Cut프로그래밍 공부/Spring 2021. 5. 5. 15:59
뉴렉처 강사님의 동영상 강의를 정리한 글입니다. weaving(뜨개질) : 부가 로직을 호출하고 부가 로직 실행 중에 주 업무가 실행되는 것을 말함 JoinPoint : 부가 로직이 대상으로 삼는 주 업무 메서드. 부가 로직에서 연결해야 할 포인트 점이 되는 곳 Pointcuts 기본적으로 proxy는 target class의 모든 메서드를 JoinPoint로 생각한다. 특정 메서드만 weaving 하기 위해서는 별도의 정보가 필요하다. 이것을 point cuts라고 한다. Advice 별로 pointcut을 사용할 수 있다. Advice를 pointcut과 연결해주는 Advisor - Point cut 생성: mappedName property에 weaving 하고 싶은 method를 넣는다 - Adv..
-
[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..