sitelink1  
sitelink2  
sitelink3  
extra_vars6  

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd">
<!--
  - Application context definition for JPetStore's data access layer.
  - Accessed by business layer objects defined in "applicationContext.xml"
  - (see web.xml's "contextConfigLocation"). 

이 설정화일은 "applicationContext.xml"에 정의된 비즈니스 레이어 오브젝트들에 의해 참조된다.

  -
  - This version of the data access layer works on a combined database,
  - using a local DataSource with DataSourceTransactionManager. It does not
  - need any JTA support in the container: It will run as-is in plain Tomcat. 

JTA(Java Transaction API) : J2EE 트랜잭션 매니저 (JTS:Java Transaction Service)를
실제 J2EE component(servlet,JSP,EJB..)에서 어떻게 사용할 것인지, 그를 위한 API 들을 정의한 spec.
근데 여기선 데이터베이스 억세스시에 DataSourceTransactionManager와 함께 local DataSource를
사용하고 있어서 container에서 그 어떤 JTA도 필요없다는군.
연동되어 있는 둘 이상의 데이터베이스 집단을  combined database라고 한다.
그 combined database가 JTA를 통해서 접근하게 되는 것이고...

  -->
<beans>
 <!-- ========================= RESOURCE DEFINITIONS ========================= -->
 <!-- Local Apache Commons DBCP DataSource that refers to a combined database -->
 <!-- (see dataAccessContext-jta.xml for an alternative) -->
 <!-- The placeholders are resolved from jdbc.properties through -->
 <!-- the PropertyPlaceholderConfigurer in applicationContext.xml -->
 <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
  <property name="driverClassName" value="${jdbc.driverClassName}"/>
  <property name="url" value="${jdbc.url}"/>
  <property name="username" value="${jdbc.username}"/>
  <property name="password" value="${jdbc.password}"/>
 </bean> 

jdbc.properties에 정의한 DB접속 정보들을 DataSource 화 한다.
jdbc.properties은 열어보면 그냥 URL과 ID랑 PASSWORD가 있을 뿐

 <!-- Transaction manager for a single JDBC DataSource -->
 <!-- (see dataAccessContext-jta.xml for an alternative) -->
 <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
  <property name="dataSource" ref="dataSource"/>
 </bean> 

위에서 생성한 dataSource 참조하여 스프링의 DataSourceTransactionManager가 움직인다.

 <!-- SqlMap setup for iBATIS Database Layer -->
 <bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
  <property name="configLocation" value="WEB-INF/sql-map-config.xml"/>
  <property name="dataSource" ref="dataSource"/>
 </bean> 

SqlMap은 이미 어플리케이션과 Database를 연결하는데 있어서 몰라서는 안되는 OR매핑 프레임웍중의 하나이다.
위에서 생성한 dataSource sql-map-config.xml의 설정을 이용한다.
이를 통해 생성되는 객체의 id는 sqlMapClient이다.


 <!-- ========================= DAO DEFINITIONS: IBATIS IMPLEMENTATIONS ========================= -->

 

 

DAO(Data Access Object)에 대한 정의다. 싱글 데이터베이스이므로 대부분이  빈관리를 위한 sqlMapClient 객체만 참조하고 있다.

 <bean id="accountDao" class="org.springframework.samples.jpetstore.dao.ibatis.SqlMapAccountDao">
  <property name="sqlMapClient" ref="sqlMapClient"/>
 </bean>
 <bean id="categoryDao" class="org.springframework.samples.jpetstore.dao.ibatis.SqlMapCategoryDao">
  <property name="sqlMapClient" ref="sqlMapClient"/>
 </bean>
 <bean id="productDao" class="org.springframework.samples.jpetstore.dao.ibatis.SqlMapProductDao">
  <property name="sqlMapClient" ref="sqlMapClient"/>
 </bean>
 <bean id="itemDao" class="org.springframework.samples.jpetstore.dao.ibatis.SqlMapItemDao">
  <property name="sqlMapClient" ref="sqlMapClient"/>
 </bean>
 <!-- Refers to the combined database here -->
 <!-- (see dataAccessContext-jta.xml for an alternative) -->
 <bean id="orderDao" class="org.springframework.samples.jpetstore.dao.ibatis.SqlMapOrderDao">
  <property name="sqlMapClient" ref="sqlMapClient"/>
  <property name="sequenceDao" ref="sequenceDao"/>
 </bean> 

 

 

 

다른 설정들은 sqlMapClient 객체만 참조하는데 이것은 sequenceDao객체도 참조한다. sequenceDao의 정의는 하단부에 나와있다.

 <!-- OrderDao definition for MS SQL Server -->
 <!-- (to be used instead of the default orderDao) -->
 <!--
 <bean id="orderDao" class="org.springframework.samples.jpetstore.dao.ibatis.MsSqlOrderDao">
  <property name="sqlMapClient" ref="sqlMapClient"/>
  <property name="sequenceDao" ref="sequenceDao"/>
 </bean>
 -->

 

 

 

MS SQL 데이터베이스에서는 orderDao객체 생성시 이것을 이용하라는 것 같다.
클래스가 틀리다. 아마 쿼리의 내용이 다를듯 하다.

 <!-- Refers to the combined database here -->
 <!-- (see dataAccessContext-jta.xml for an alternative) -->
 <bean id="sequenceDao" class="org.springframework.samples.jpetstore.dao.ibatis.SqlMapSequenceDao">
  <property name="sqlMapClient" ref="sqlMapClient"/>
 </bean> 

 

 

 

sqlMapClient객체를 이용하여 생성되는 것인데 orderDao라는 것이 이 DAO를 이용하고  있다.

 <!-- SequenceDao definition for Oracle databases -->
 <!-- (to be used instead of the default sequenceDao) -->
 <!--
 <bean id="sequenceDao" class="org.springframework.samples.jpetstore.dao.ibatis.OracleSequenceDao">
  <property name="sqlMapClient" ref="sqlMapClient"/>
 </bean>
 -->

 

 

 

sequenceDao객체를 생성할때도 DB마다 특성을 탄다. 오라클일땐 이것을 이용한다.

</beans>

 

 

번호 제목 글쓴이 날짜 조회 수
공지 (확인전) [2021.03.12] Eclipse에서 Spring Boot로 JSP사용하기(Gradle) 황제낙엽 2023.12.23 0
공지 [작성중/인프런] 스프링부트 시큐리티 & JWT 강의 황제낙엽 2023.12.20 6
23 Spring프레임워크 소개문서 (2) 황제낙엽 2007.03.22 123
22 Spring프레임워크 소개문서 (1) 황제낙엽 2007.03.22 107
21 Cugain의 샘플프로젝트 jpetstore 분석기 - (1) jpetstore 설치 file 황제낙엽 2007.02.22 123
20 Cugain의 샘플프로젝트 jpetstore 분석기 - (7) PetStoreImpl.java 황제낙엽 2007.05.24 51
19 Cugain의 샘플프로젝트 jpetstore 분석기 - (6) petstore-servlet.xml 분석 황제낙엽 2007.04.27 19
18 Cugain의 샘플프로젝트 jpetstore 분석기 - (5) applicationContext.xml 분석 황제낙엽 2007.04.21 232
17 Cugain의 샘플프로젝트 jpetstore 분석기 - (4) dataAccessContext-jta.xml 분석 황제낙엽 2007.04.21 27
» Cugain의 샘플프로젝트 jpetstore 분석기 - (3) dataAccessContext-local.xml 분석 황제낙엽 2007.04.21 40
15 Cugain의 샘플프로젝트 jpetstore 분석기 - (2) web.xml 분석 황제낙엽 2007.03.20 92
14 IoC (Inversion of Control) 컨테이너에 대한 정리 황제낙엽 2007.02.21 50
13 자바지기 1차 오픈 소스 스터디 문서모음 file 황제낙엽 2007.01.30 46
12 Spring 프레임워크를 이용한 효율적인 개발 전략 1차 황제낙엽 2007.01.30 47
11 Spring framework jpetstore 샘플 분석기 - (6) jpetstore 예제로 살펴보는 Spring MVC와 iBatis 연동 황제낙엽 2007.01.18 48
10 Spring framework jpetstore 샘플 분석기 - (5) jpetstore 에서의 InternalResourceViewResolver 황제낙엽 2007.01.18 17
9 Spring framework jpetstore 샘플 분석기 - (4) jpetstore 에서의 HandlerMapping 황제낙엽 2007.01.18 36
8 Spring framework jpetstore 샘플 분석기 - (3) jpetstore 에서의 Spring MVC 설정 황제낙엽 2007.01.18 13
7 Spring framework jpetstore 샘플 분석기 - (2) jpetstore 에서의 Spring 초기 설정과 IoC 황제낙엽 2007.01.18 18
6 Spring framework jpetstore 샘플 분석기 - (1) jpetstore 설치하기 황제낙엽 2007.01.18 30
5 Spring WebFlow Introduction (웹개발을 직관적으로) 황제낙엽 2006.12.09 555
4 IoC(Inversion of Control)란 무엇인가? 황제낙엽 2006.12.09 93