<?xml version="1.0" encoding="UTF-8"?>
<!--
  - Application context definition for JPetStore's data access layer.
  - Accessed by business layer objects defined in "applicationContext.xml"
  - (see web.xml's "contextConfigLocation").
  -
  - This version of the data access layer works on two databases (main/order),
  - using JNDI DataSources with JtaTransactionManager. It obviously depends on
  - JTA support in the container, and on pre-configured container DataSources.
 

JTA는 두 데이터베이스(main과 order)를 접속하는데, JtaTransactionManager과 함께 JNDI DataSources를 사용한다.

  -
  - This version also uses the "jndi:" namespace introduced in Spring 2.0
  - to configured JNDI referenced objects.
  -->
<beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:jee="http://www.springframework.org/schema/jee"
      xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
           http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.0.xsd">
 <!-- ========================= RESOURCE DEFINITIONS ========================= -->
 <!-- Main JNDI DataSource for J2EE environments -->
 <!-- Refers to the main database, containing product and account data -->
 <!-- (see dataAccessContext-local.xml for an alternative) -->
    <jee:jndi-lookup id="dataSource" jndi-name="java:comp/env/jdbc/jpetstore"/>   

J2EE 환경에 대한 메인 JNDI DataSource 이다. 메인이 되는 정보(상품과 계정) 데이터베이스를 참조할 것이다.

 <!-- Additional JNDI DataSource for J2EE environments -->
 <!-- Refers to the order database, containing order data -->
 <!-- (see dataAccessContext-local.xml for an alternative) -->
    <jee:jndi-lookup id="orderDataSource" jndi-name="java:comp/env/jdbc/jpetstore-order"/> 

J2EE 환경에 대한 부가적인 JNDI DataSource 이다. 주문정보를 담고 있는 주문 데이터베이스를 참조하게 된다.

 <!-- Transaction manager that delegates to JTA (for a transactional JNDI DataSource) -->
 <!-- Necessary here due to the need for distributed transactions across two databases -->
 <!-- (see dataAccessContext-local.xml for an alternative) -->
 <bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager"/> 

JNDI DataSource의 Transaction 처리를 위해 JTA에게 그 부분을 위임한단다.
JTA가 두 데이터베이스의 분산 트랜잭션을 보장해준다는 거군.

 <!-- 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"/>
 </bean> 

local과 다름없어 보인다. 단지 JNDI를 이용하기 때문에 dataSource가 없다.
web.xml 화일의 맨 밑의 하단부를 보면 <resource-ref>태그로 "jdbc/jpetstore"와 "jdbc/jpetstore-order"가 정의되어 있다.


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

 

복수 데이터베이스이기 때문에 DAO들에 대한 설정시 JNDI에서 찾아낸 dataSource와 빈관리를 위한 sqlMapClient를 참조한다.

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

 

 

이 부분에서 조금 다르다. dataSource를 orderDataSource로 이용하고 있다.

 <!-- 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="dataSource" ref="orderDataSource"/>
  <property name="sqlMapClient" ref="sqlMapClient"/>
  <property name="sequenceDao" ref="sequenceDao"/>
 </bean>
 -->
 <!-- Refers to the order database here -->
 <!-- (see dataAccessContext-local.xml for an alternative) -->
 <bean id="sequenceDao" class="org.springframework.samples.jpetstore.dao.ibatis.SqlMapSequenceDao">
  <property name="dataSource" ref="orderDataSource"/>
  <property name="sqlMapClient" ref="sqlMapClient"/>
 </bean> 

 

 

sequenceDao 에 대한 정의는 설정화일에서 찾을 수 없는 것 같다.

 <!-- 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="dataSource" ref="orderDataSource"/>
  <property name="sqlMapClient" ref="sqlMapClient"/>
 </bean>
 -->
</beans>
 

 

번호 제목 글쓴이 날짜 조회 수
공지 [작성중/인프런] 스프링부트 시큐리티 & JWT 강의 황제낙엽 2023.12.20 5083
84 @ConfigurationProperties 사용하기 황제낙엽 2025.10.23 1617
83 Spring Boot 에서 서버 로직의 역할별 애노테이션 구분 황제낙엽 2025.10.13 1411
82 (확인전) [2021.03.12] Eclipse에서 Spring Boot로 JSP사용하기(Gradle) file 황제낙엽 2023.12.23 2817
81 Spring Boot PetClinic Sample Application 황제낙엽 2023.12.21 2575
80 Eclipse, Spring Boot, Gradle, SVN 레거시(2019) 시스템 유지보수 환경 구축 file 황제낙엽 2023.11.14 1732
79 [시리즈 강좌] 스프링부트로 웹서비스 구축하기 황제낙엽 2023.07.13 1691
78 Spring Boot에서의 RESTful API 모듈 file 황제낙엽 2020.04.16 1896
77 [POST] Spring MVC 구조 분석 황제낙엽 2024.01.17 2053
76 Spring Framework 에서 사용하는 annotation 황제낙엽 2024.01.17 2093
75 Spring MVC configuration file 황제낙엽 2024.01.17 2041
74 [스프링 시큐리티 OAuth2] 강의 자료와 학습용 소스 file 황제낙엽 2024.01.15 1595
73 OAuth 2.0 Resource Server - Spring Security OAuth2.0 황제낙엽 2023.12.27 2016
72 Spring, JSP, Gradle, Eclipse 환경 구축[2] - 샘플 프로젝트 file 황제낙엽 2023.12.24 1922
71 Spring, JSP, Gradle, Eclipse 환경 구축[1] - 레퍼런스 조사 황제낙엽 2023.12.23 2056
70 spring-security-samples 황제낙엽 2023.12.22 1800
69 [Bard] Spring 과 Spring Boot의 차이 file 황제낙엽 2023.12.21 1803
68 Spring 과 Spring Boot의 차이 file 황제낙엽 2020.05.26 2308
67 Spring Security OAuth2.0 파헤치기 황제낙엽 2019.09.05 2079
66 Spring Security OAuth2구현 file 황제낙엽 2019.09.05 2208
65 Spring Security OAuth 황제낙엽 2019.09.05 2442