1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158
| <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
"http://www.springframework.org/dtd/spring-beans.dtd">
<!-- Application context definition for "springapp" DispatcherServlet. -->
<beans>
<!-- Controller for the initial "Hello" page -->
<bean id="springappController" class="web.SpringappController">
</bean>
<!-- Validator and Form Controller for the "add user" page -->
<bean id="addUserValidator" class="bean.UserValidator"/>
<bean id="addUserForm" class="web.UserFormController">
<property name="sessionForm"><value>true</value></property>
<property name="commandName"><value>user</value></property>
<property name="commandClass"><value>bean.User</value></property>
<property name="validator"><ref bean="addUserValidator"/></property>
<property name="formView"><value>addUser</value></property>
<property name="successView"><value>addUser.htm</value></property>
<property name="serviceUser"><ref bean="userServiceTarget"/> </property>
</bean>
<!-- Validator and Form Controller for the "LOGIN" page -->
<bean id="loginValidator" class="bean.LogValidator"/>
<bean id="loginForm" class="web.LoginFormController">
<property name="sessionForm"><value>true</value></property>
<property name="commandName"><value>user</value></property>
<property name="commandClass"><value>bean.User</value></property>
<property name="validator"><ref bean="loginValidator"/></property>
<property name="formView"><value>login</value></property>
<property name="successView"><value>hello.htm</value></property>
</bean>
<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
<property name="basename"><value>messages</value></property>
</bean>
<bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="mappings">
<props>
<prop key="/login.htm">loginForm</prop>
<prop key="/hello.htm">springappController</prop>
<prop key="/addUser.htm">addUserForm</prop>
</props>
</property>
</bean>
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass">
<value>org.springframework.web.servlet.view.JstlView</value>
</property>
<property name="prefix"><value>/WEB-INF/jsp/</value></property>
<property name="suffix"><value>.jsp</value></property>
</bean>
<!-- ========================= Start of PERSISTENCE DEFINITIONS =========================-->
<!-- DataSource Definition -->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName">
<value>com.mysql.jdbc.Driver</value>
</property>
<property name="url">
<value>jdbc:mysql://localhost:3306/j2ee</value>
</property>
<property name="username">
<value>root</value>
</property>
<property name="password">
<value>root</value>
</property>
</bean>
<!-- Hibernate SessionFactory Definition -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="mappingResources">
<list>
<value>hibernate.cfg.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.cglib.use_reflection_optimizer">true</prop>
<prop key="hibernate.cache.provider_class">org.hibernate.cache.HashtableCacheProvider</prop>
</props>
</property>
<property name="dataSource">
<ref bean="dataSource" />
</property>
</bean>
<!-- Spring Data Access Exception Translator Defintion -->
<bean id="jdbcExceptionTranslator" class="org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator">
<property name="dataSource">
<ref bean="dataSource" />
</property>
</bean>
<!-- Hibernate Template Defintion -->
<bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
<property name="jdbcExceptionTranslator">
<ref bean="jdbcExceptionTranslator" />
</property>
</bean>
<!-- Hibernate Transaction Manager Definition -->
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref local="sessionFactory" />
</property>
</bean>
<!-- ========================= Start of DAO DEFINITIONS ========================= -->
<!-- TODO DAO Definition: Hibernate implementation -->
<bean id="userDao" class="dao.UserDaoImpl">
<property name="hibernateTemplate">
<ref bean="hibernateTemplate" />
</property>
</bean>
<!-- ========================= Start of SERVICE DEFINITIONS ========================= -->
<!-- TODO Service Definition -->
<bean id="userServiceTarget" class="service.UserServiceImpl">
<property name="userDao">
<ref local="userDao" />
</property>
</bean>
<!-- Transactional proxy for the TODO Service -->
<bean id="userService" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager">
<ref local="transactionManager" />
</property>
<property name="target">
<ref local="userServiceTarget" />
</property>
<property name="transactionAttributes">
<props>
<prop key="get*">PROPAGATION_REQUIRED,readOnly</prop>
<prop key="save*">PROPAGATION_REQUIRED</prop>
<prop key="update*">PROPAGATION_REQUIRED</prop>
<prop key="delete*">PROPAGATION_REQUIRED</prop>
</props>
</property>
</bean>
</beans> |