1 / 40

Spring framework

JPetStore 분석자료 1.0. Spring framework. 작성자 : 김태완. JPetStore 란 ?. JPetStore 어플리케이션은 클린턴 비긴 Clinton Begin 이 만든 iBatis 용 JPetStore 를 기초로 만들어졌다 . 전체 DAO 계층을 포함하고 있으며 Spring, iBatis 를 사용하여 Oracle, MS-SQL, MySQL , PostgreSQL 를 지원한다 . 비즈니스 계층은 전적으로 Spring 으로 관리하고 DAO 계층에 의존한다 .

arav
Download Presentation

Spring framework

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. JPetStore분석자료 1.0 Spring framework 작성자 : 김태완

  2. JPetStore란? • JPetStore어플리케이션은 클린턴 비긴Clinton Begin 이 만든 iBatis용 JPetStore를 기초로 만들어졌다. • 전체 DAO계층을 포함하고 있으며 Spring, iBatis를 사용하여 Oracle, MS-SQL, MySQL, PostgreSQL를 지원한다. 비즈니스 계층은 전적으로 Spring으로 관리하고 DAO계층에 의존한다. • Spring MVC, Struts, Spring Remoting, JAX-RPC도 포함되어 있다.

  3. 구동 및 테스트환경 • Apache Tomcat 5.5 • Eclipse Galileo IDE • JDK 1.6 • My-SQL 5.5 • Spring 2.5.5 • iBatis 2.3 • 본 문서는 JPetStore에서 WebService(Spring Remoting, JAX-RPC)와 관련된 부분과 Struts에 관련된 부분을 제외하고 작성되었다.

  4. 분석순서 • 화면분석 • 환경분석 • 흐름분석 • 소스분석 • DB 분석

  5. 1. 화면분석 • JPetStore의 화면 분석

  6. 메인화면 카테고리 목록 장바구니 로그인 검색

  7. 로그인화면

  8. 회원가입 장바구니에서 나의 관심동물 목록이 보임. 관심동물에 대한 배너정보가 보임.

  9. 상품목록

  10. 세부 상품목록

  11. 상품상세보기

  12. 장바구니

  13. 체크아웃

  14. 결제정보

  15. 배송 주소정보

  16. 주문서 확인

  17. 주문 완료

  18. 개인정보 수정

  19. 나의 구매목록

  20. 2. 환경분석 • Spring 설정파일과 배포서술자에 대한 분석. • iBatis설정에 대한 내용 추가.

  21. Project 구성 DAO interface들 iBatis를 이용한 DAO 구현클래스들 iBatis설정파일들 JavaBean들(직렬화 구현) Business Logic들 JAX-RPC/Axis 웹서비스(확실하지 않음) JAX-RPC/Axis 웹서비스 클라이언트 Spring MVC의 Controller 구현클래스들 Struts의 Action 구현클래스들 JSP 파일들 Spring 설정파일들, 배포서술자, 프로퍼티파일들, iBatis설정파일, 웹서비스 설정파일

  22. Library

  23. 환경설정

  24. 배포서술자 web.xml Root 디렉토리를 절대가 아닌 상대디렉토리로 쓰기 위한 파라미터 Log4J 의 설정파일 위치 Spring의 Context 설정파일 위치 서로 다른 DIspatcherServlet이 공통 빈을 필요로 하는 경우 사용. ContextLoaderListener를 ServletListener로 등록하고 contextConfigLocation컨텍스트파라미터를 이용하여 공통으로 사용될 빈 정보를 담고 있는 설정 파일 목록을 지정. 서블릿의 이름과 클래스를 설정. DispatcherServlet은 WEB-INF/ 디렉토리에 위치한 [서블릿이름]-servlet.xml 파일을 기본 스프링 설정 파일로 사용함.

  25. applicationContext.xml XML Schema 기반의 설정 해당 클래스를 빈으로 등록하면 외부의 프로퍼티 파일에 저장된 정보를 Spring 설정 파일에서 사용할 수 있게 된다. (고유) : 요구값이 부족할 경우 Error를 리턴하도록 작성된 Validator Bean. (고유) : Business Logic의 집합체. 퍼사드 패턴을 이용하여 PetStoreFacade를 구현하고 있음. 각각의 DAO구현체를 DI받는다. PetStoreFacade인터페이스의 모든 메소드를pointcut으로 물고있음. 선언적 트랜잭션. insert* , update* : insert와 update문자가 앞에 붙은 메소드가 수행될 때 트랜잭션이 발동 * : 위의 메소드를 제외한 나머지 메소드가 수행될 때 read-only 형태의 트랜잭션이 발동

  26. dataAccessContext-local.xml DTD기반의 설정. Apache의 Common 라이브러리를 이용하여 커넥션풀을 잡는 dataSource빈을 설정. PropertyPlaceholderConfigurer에서 설정된 외부 프로퍼티 파일에서 해당 값을 로딩. 트랜잭션 관리자. dataSource프로퍼티를 사용하여 전달받은 DataSource로부터 Connection을 가져온 뒤, Connection의 commit(), rollback() 등의 메소드를 이용하여 트랜잭션을 관리 Spring과 iBatis를 쉽게 연동하기 위해 SqlMapClient를 Bean으로 설정시켜주는 클래스. dataSource, configLocation (iBatis설정파일 위치)이 필요함. iBatis를 이용한 각 DAO구현 Bean.

  27. JSP나 HTML 파일과 같이 웹 어플리케이션의 내부 자원을 이용하여 뷰를 생성. 컨트롤러가 지정한 뷰 이름으로부터 실제로 사용될 뷰를 선택 JstlView : JSTL을 사용하여 뷰를 구현 petstore-servlet.xml - 1 URL과 일치하는 이름을 갖는 빈을 컨트롤러로 사용함. 다수의 핸들러매핑을 동시에 설정하게 되면 order 프로퍼티에 적힌 순서대로 실행하며 order 프로퍼티값이 없을 경우 설정 파일에 입력한 순서에 따라 매핑되는 컨트롤러를 검색함. DB연동이나 별도의 처리 없이 뷰 페이지를 바로 보여주고 싶을 경우, 정적인 뷰를 제공하고 싶은 경우에 사용

  28. petstore-servlet.xml - 2 가장 많이 사용되는 HandlerMapping. 패턴 매칭을 이용하여 매핑. 여기서는 보안에 관련된 매핑을 하기 위해 두번째HandlerMapping으로 설정되었슴. 요청 가로채기. 요청을 처리하기 전과 처리한 후에 알맞는 기능을 수행.

  29. Database 설정 with iBatis dataAccessContext-local.xml applicationContext.xml jdbc.properties Next Page

  30. Database 설정 with iBatis sql-map-config.xml Next Page

  31. Database 설정 with iBatis iBatis사용 Example

  32. 3. 흐름분석 • JPetStore의 웹 흐름 분석. • 내부 Model부의 흐름 분석. • 주요 Controller에 대한 세부 분석. • 정확한 흐름이 아닌 이해가 편한 형태로 분석되었음.

  33. JPetStore요청 정리 SignOn확인. SignOnInterceptor설정.

  34. Project 실행 흐름 HandlerMapping 1 BeanNameUrlHandlerMapping Controller org.springframework.samples. jpetstore.web.spring HandlerMapping2 SimpleUrlHandlerMapping 4. 처리 요청 3. 해당 Controller Bean 리턴 5. ModelAndView리턴 (View 이름) 2. Controller 검색 및 요청 1. Request(*.do) DispatcherServlet Client 8. Response 생성 요청 6. View 검색 및 요청 7. View 리턴 ViewResolver InternalResourceViewResolver JSP WEB-INF/jsp/spring

  35. Model부 실행 흐름 Controller DAO 자체처리 처리요청 Transaction with AOP AccountDao AccountFormController SqlMapAccountDao SignonController PetStoreFacade ViewCartController CategoryDao PetStoreImpl ViewCategoryController SqlMapCategoryDao DB처리 OrderFormController ItemDao ModelAndView SqlMapItemDao ... ...

  36. 요청흐름 : 정적인 View 예제http://localhost:8080/jpetstore/shop/index.do 1. petstore-servlet.xml 2. JSP

  37. 요청흐름 : Controller 구현체 예제http://localhost:8080/jpetstore/shop/viewCategory.do?categoryId=FISH 1. petstore-servlet.xml applicationContext.xml Next Page

  38. 요청흐름 : Controller 구현체 예제http://localhost:8080/jpetstore/shop/viewCategory.do?categoryId=FISH Next Page

  39. 요청흐름 : Controller 구현체 예제http://localhost:8080/jpetstore/shop/viewCategory.do?categoryId=FISH 2. PetStoreImpl.class Next Page

  40. 요청흐름 : Controller 구현체 예제http://localhost:8080/jpetstore/shop/viewCategory.do?categoryId=FISH 3. SqlMapCategoryDao.class Category.xml Next Page

More Related