새로운 아키텍쳐 개발이 완료되어 올려봅니다.
컨트롤러는 struts2, 모델은 spring2.5를 사용해 보았습니다.
주로 보셔야 할 부분은 xml관련 부분이겠죠.
spring2를 사용하고자 하시는 분에게 도움이 되었으면 좋겠네요.
우선 설정관련 파일부터 올립니다.
경로가 특이한 파일은 주석에 경로를 포함하였으니 조심하세요
/////////////////////////////////////////////////////
// web.xml
/////////////////////////////////////////////////////
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<display-name>tmdic</display-name>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml /WEB-INF/dataAccessContext.xml</param-value>
</context-param>
<filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.FilterDispatcher
</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<session-config>
<session-timeout>30</session-timeout>
</session-config>
<filter>
<filter-name>struts</filter-name>
<filter-class>
org.apache.struts2.dispatcher.FilterDispatcher
</filter-class>
<init-param>
<param-name>struts.i18n.encoding</param-name>
<param-value>euc-kr</param-value>
</init-param>
</filter>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
</web-app>
/////////////////////////////////////////////////////
// applicationContext.xml
/////////////////////////////////////////////////////
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
<!-- ========================= BUSINESS OBJECT DEFINITIONS ======================== -->
<bean id="board" class="core.board.BoardImpl">
<property name="boardDAO" ref="boardDAO" />
</bean>
<bean id="ajax" class="core.ajax.AjaxImpl">
<property name="boardDAO" ref="boardDAO" />
</bean>
<!-- ========================= ASPECT CONFIGURATION ======================== -->
<aop:config>
<aop:advisor pointcut="execution(* *..IBoard.*(..))" advice-ref="txAdvice"/>
<aop:advisor pointcut="execution(* *..IAjax.*(..))" advice-ref="txAdvice"/>
</aop:config>
<tx:advice id="txAdvice">
<tx:attributes>
<tx:method name="insert*" propagation="REQUIRED" />
<tx:method name="update*" propagation="REQUIRED" />
<tx:method name="delete*" propagation="REQUIRED" />
<tx:method name="get*" read-only="true" />
</tx:attributes>
</tx:advice>
</beans>
/////////////////////////////////////////////////////
// dataAccessContext.xml
/////////////////////////////////////////////////////
<?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">
<beans>
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="oracle.jdbc.pool.OracleConnectionPoolDataSource"/>
<property name="url" value="jdbc:oracle:thin:@127.0.0.1:1521:XE"/>
<property name="username" value="test"/>
<property name="password" value="test"/>
</bean>
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"/>
</bean>
<!-- ========================= DAO DEFINITIONS ======================== -->
<bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
<property name="configLocation" value="WEB-INF/sql-map-config.xml"/>
</bean>
<bean id="boardDAO" class="core.board.BoardDAO">
<property name="dataSource" ref="dataSource"/>
<property name="sqlMapClient" ref="sqlMapClient"/>
</bean>
</beans>
/////////////////////////////////////////////////////
// sql-map-config.xml
/////////////////////////////////////////////////////
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMapConfig PUBLIC "-//iBATIS.com//DTD SQL Map Config 2.0//EN"
"http://www.ibatis.com/dtd/sql-map-config-2.dtd">
<sqlMapConfig>
<sqlMap resource="core/board/BoardDAO.xml"/>
</sqlMapConfig>
/////////////////////////////////////////////////////
// WEB-INF/classes/log4j.properties
/////////////////////////////////////////////////////
log4j.rootLogger=INFO, stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=[%d{yyyy-MM-dd HH\:mm\:ss}] - %C.%M() Line %L \: %m %n
log4j.logger.java.sql.Connection=DEBUG
log4j.logger.java.sql.Statement=DEBUG
log4j.logger.java.sql.PreparedStatement=DEBUG
/////////////////////////////////////////////////////
// WEB-INF/classes/struts.properties
/////////////////////////////////////////////////////
struts.i18n.reload=true
struts.configuration.xml.reload=true
/////////////////////////////////////////////////////
// WEB-INF/classes/struts.xml
/////////////////////////////////////////////////////
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<constant name="struts.enable.DynamicMethodInvocation" value="true" />
<constant name="struts.devMode" value="true" />
<include file="board.xml" />
<include file="ajax.xml" />
</struts>
/////////////////////////////////////////////////////
// WEB-INF/classes/board.xml
/////////////////////////////////////////////////////
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<package name="board" namespace="/board" extends="struts-default">
<global-results>
<result name="Exception">/exception.jsp</result>
</global-results>
<global-exception-mappings>
<exception-mapping exception="java.lang.Exception"
result="Exception" />
</global-exception-mappings>
<action name="*" method="{1}" class="web.board.BoardAction">
<interceptor-ref name="servlet-config" />
<interceptor-ref name="exception" />
<result name="mgr_ready">/board/BoardMgr.jsp</result>
<result name="searchBoard_success">/board/BoardList.jsp</result>
<result name="viewBoard_success">/board/BoardView.jsp</result>
<result name="insert_ready">/board/BoardInsert.jsp</result>
<result name="update_ready">/board/BoardUpdate.jsp</result>
</action>
<action name="defaultAction">
<result>/WrongAction.jsp</result>
</action>
</package>
</struts>
댓글 없음:
댓글 쓰기