Created
October 1, 2012 13:39
-
-
Save gonfva/3811852 to your computer and use it in GitHub Desktop.
Crash course to Spring MVC with transactions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<beans xmlns="http://www.springframework.org/schema/beans" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" | |
xmlns:jee="http://www.springframework.org/schema/jee" xmlns:jdbc="http://www.springframework.org/schema/jdbc" | |
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop" | |
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd | |
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd | |
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee.xsd | |
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd | |
http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsd | |
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd"> | |
<!-- Scan the the domain package for Spring repositories and services --> | |
<context:component-scan base-package="gfv.homework.spcapitaliq.quotes.domain" /> | |
<context:property-placeholder location="classpath:spring.properties" /> | |
<bean id="mySessionFactory" | |
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"> | |
<property name="dataSource" ref="datasource" /> | |
<property name="annotatedClasses"> | |
<list> | |
<value>gfv.homework.spcapitaliq.quotes.domain.StockQuote</value> | |
</list> | |
</property> | |
<property name="hibernateProperties"> | |
<props> | |
<prop key="hibernate.dialect">org.hibernate.dialect.HSQLDialect</prop> | |
<prop key="hibernate.show_sql">true</prop> | |
<prop key="hibernate.hbm2ddl.auto">create</prop> | |
<prop key="hibernate.connection.autocommit">true</prop> | |
</props> | |
</property> | |
</bean> | |
<!-- bean id="daoInMemory" class="gfv.homework.spcapitaliq.quotes.domain.StockDaoInMemoryImpl"/ --> | |
<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> | |
<bean id="proxy" class="gfv.homework.spcapitaliq.quotes.domain.Proxy"> | |
<property name="active" value="${http.proxySet}" /> | |
<property name="host" value="${http.proxyHost}" /> | |
<property name="port" value="${http.proxyPort}" /> | |
<property name="user" value="${http.proxyUser}" /> | |
<property name="password" value="${http.proxyPassword}" /> | |
</bean> | |
<bean id="qqserviceYahoo" | |
class="gfv.homework.spcapitaliq.quotes.domain.QuoteQueryServiceYahooImpl"> | |
<property name="proxy" ref="proxy" /> | |
<property name="timeout" value="${api.timeout}" /> | |
<property name="apiService" value="${api.urlService}" /> | |
</bean> | |
<bean id="txManager" | |
class="org.springframework.orm.hibernate3.HibernateTransactionManager"> | |
<property name="sessionFactory" ref="mySessionFactory" /> | |
<property name="dataSource" ref="datasource"/> | |
</bean> | |
<tx:annotation-driven transaction-manager="txManager"/> | |
<bean id="traderService" class="gfv.homework.spcapitaliq.quotes.domain.TraderServiceImpl"> | |
</bean> | |
</beans> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<beans xmlns="http://www.springframework.org/schema/beans" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" | |
xmlns:mvc="http://www.springframework.org/schema/mvc" | |
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd | |
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd | |
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd"> | |
<context:component-scan base-package="gfv.homework.spcapitaliq.quotes.web" /> | |
<mvc:annotation-driven /> | |
<bean | |
class="org.springframework.web.servlet.view.InternalResourceViewResolver"> | |
<property name="prefix" value="/WEB-INF/views/" /> | |
<property name="suffix" value=".jsp"></property> | |
</bean> | |
</beans> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5"> | |
<display-name>Quote query and persisting</display-name> | |
<context-param> | |
<param-name>contextConfigLocation</param-name> | |
<param-value>/WEB-INF/spring-business-context.xml</param-value> | |
</context-param> | |
<listener> | |
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> | |
</listener> | |
<servlet> | |
<servlet-name>Spring MVC Servlet</servlet-name> | |
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> | |
<init-param> | |
<param-name>contextConfigLocation</param-name> | |
<param-value>/WEB-INF/spring-mvc-context.xml</param-value> | |
</init-param> | |
</servlet> | |
<filter> | |
<filter-name>hibernateFilter</filter-name> | |
<filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class> | |
<init-param> | |
<param-name>sessionFactoryBeanName</param-name> | |
<param-value>mySessionFactory</param-value> | |
</init-param> | |
</filter> | |
<filter-mapping> | |
<filter-name>hibernateFilter</filter-name> | |
<url-pattern>/*</url-pattern> | |
</filter-mapping> | |
<servlet-mapping> | |
<servlet-name>Spring MVC Servlet</servlet-name> | |
<url-pattern>/</url-pattern> | |
</servlet-mapping> | |
</web-app> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment