Source

encuestame / encuestame-persistence / src / main / resources / spring-test / encuestame-test-hibernate-context.xml

Full commit
<?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"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:ehcache="http://ehcache-spring-annotations.googlecode.com/svn/schema/ehcache-spring"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
       http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
       http://www.springframework.org/schema/aop
       http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
       http://www.springframework.org/schema/tx
       http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
       http://www.springframework.org/schema/context
       http://www.springframework.org/schema/context/spring-context-3.0.xsd
       http://ehcache-spring-annotations.googlecode.com/svn/schema/ehcache-spring http://ehcache-spring-annotations.googlecode.com/svn/schema/ehcache-spring/ehcache-spring-1.1.xsd
       ">

     <bean id="jdbcDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
        <property name="driverClassName" value="${datasource.classname}"/>
        <property name="url" value="${datasource.urldb}"/>
        <property name="username" value="${datasource.userbd}"/>
        <property name="password" value="${datasource.pass}"/>
    </bean>

    <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
        <property name="dataSource" ref="jdbcDataSource"/>
    </bean>

    <bean id="dataSource"
        class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <property name="driverClassName" value="${datasource.classname}" />
        <property name="url" value="${datasource.urldb}" />
        <property name="username" value="${datasource.userbd}" />
        <property name="password" value="${datasource.pass}" />
    </bean>

    <bean id="sessionFactory"
        class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
        <property name="dataSource" ref="dataSource" />
        <property name="annotatedClasses">
            <list>
                <value>org.encuestame.persistence.domain.application.Application</value>
                <value>org.encuestame.persistence.domain.application.ApplicationConnection</value>
                <value>org.encuestame.persistence.domain.Project</value>
                <value>org.encuestame.persistence.domain.Project</value>
                <value>org.encuestame.persistence.domain.GeoPoint</value>
                <value>org.encuestame.persistence.domain.GeoPointType</value>
                <value>org.encuestame.persistence.domain.GeoPointFolder</value>
                <value>org.encuestame.persistence.domain.Client</value>
                <value>org.encuestame.persistence.domain.HashTag</value>
                <value>org.encuestame.persistence.domain.security.Group</value>
                <value>org.encuestame.persistence.domain.security.Permission</value>
                <value>org.encuestame.persistence.domain.security.Account</value>
                <value>org.encuestame.persistence.domain.security.SocialAccount</value>
                <value>org.encuestame.persistence.domain.security.UserAccount</value>
                <value>org.encuestame.persistence.domain.survey.Poll</value>
                <value>org.encuestame.persistence.domain.survey.PollResult</value>
                <value>org.encuestame.persistence.domain.question.Question</value>
                <value>org.encuestame.persistence.domain.question.QuestionAnswer</value>
                <value>org.encuestame.persistence.domain.question.QuestionPattern</value>
                <value>org.encuestame.persistence.domain.question.QuestionDependencies</value>
                <value>org.encuestame.persistence.domain.question.QuestionDependenceSurvey</value>
                <value>org.encuestame.persistence.domain.question.QuestionColettion</value>
                <value>org.encuestame.persistence.domain.question.CatQuestionCategory</value>
                <value>org.encuestame.persistence.domain.survey.SurveyFormat</value>
                <value>org.encuestame.persistence.domain.survey.SurveyGroup</value>
                <value>org.encuestame.persistence.domain.survey.SurveyResult</value>
                <value>org.encuestame.persistence.domain.survey.Survey</value>
                <value>org.encuestame.persistence.domain.survey.SurveySection</value>
                <value>org.encuestame.persistence.domain.tweetpoll.TweetPollSwitch</value>
                <value>org.encuestame.persistence.domain.tweetpoll.TweetPoll</value>
                <value>org.encuestame.persistence.domain.tweetpoll.TweetPollResult</value>
                <value>org.encuestame.persistence.domain.tweetpoll.TweetPollFolder</value>
                <value>org.encuestame.persistence.domain.tweetpoll.TweetPollSavedPublishedStatus</value>
                <value>org.encuestame.persistence.domain.Email</value>
                <value>org.encuestame.persistence.domain.EmailList</value>
                <value>org.encuestame.persistence.domain.EmailSubscribe</value>
                <value>org.encuestame.persistence.domain.survey.SurveyPagination</value>
                <value>org.encuestame.persistence.domain.survey.SurveyFolder</value>
                <value>org.encuestame.persistence.domain.survey.PollFolder</value>
                <value>org.encuestame.persistence.domain.notifications.Notification</value>
                <value>org.encuestame.persistence.domain.Attachment</value>
                <value>org.encuestame.persistence.domain.HashTagHits</value>
                <value>org.encuestame.persistence.domain.dashboard.Dashboard</value>
                <value>org.encuestame.persistence.domain.dashboard.Gadget</value>
                <value>org.encuestame.persistence.domain.dashboard.GadgetProperties</value>
            </list>
        </property>
        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.hbm2ddl.auto">${datasource.hbm2ddl.auto}</prop>
                <prop key="hibernate.dialect">${datasource.dialect}</prop>
                <prop key="hibernate.show_sql">${datasource.showsql}</prop>
                <prop key="hibernate.hbm2ddl.delimiter">${datasource.delimited}</prop>
                <prop key="hibernate.search.default.directory_provider">${datasource.hibernate.search.provider}</prop>
                <prop key="hibernate.search.default.indexBase">${datasource.hibernate.search.store.path}</prop>
                <prop key="hibernate.cache.region.factory_class">net.sf.ehcache.hibernate.EhCacheRegionFactory</prop>
                <prop key="hibernate.cache.use_second_level_cache">true</prop>
                <prop key="hibernate.cache.use_query_cache">true</prop>
            </props>
        </property>
    </bean>

    <bean id="hibernateTemplate" autowire="byName" scope="singleton" class="org.springframework.orm.hibernate3.HibernateTemplate">
        <property name="sessionFactory">
            <ref bean="sessionFactory" />
        </property>
    </bean>

    <!--  Encuestame Transactions Configuration  -->
    <bean id="transactionManager"
        class="org.springframework.orm.hibernate3.HibernateTransactionManager">
        <property name="sessionFactory">
            <ref local="sessionFactory" />
        </property>
    </bean>

    <!-- Scans the classpath of this application for @Repository Daos-->
    <context:component-scan base-package="org.encuestame.persistence.dao" />

    <context:annotation-config/>

   <tx:advice id="txAdvice" transaction-manager="transactionManager">
        <tx:attributes>
            <tx:method name="delete*" propagation="REQUIRED"/>
            <tx:method name="save*"  propagation="REQUIRED"/>
            <tx:method name="update*"  propagation="REQUIRED"/>
            <tx:method name="*"   propagation="SUPPORTS"/>
        </tx:attributes>
    </tx:advice>

    <aop:config>
        <aop:advisor pointcut="execution(* *..org.encuestame.persistence.dao.*.*(..))" advice-ref="txAdvice"/>
    </aop:config>

    <!-- This annotation allow declarative transactions.  -->
    <tx:annotation-driven  transaction-manager="transactionManager"/>

    <!-- configuration encryptor used by the property configurer -->
    <bean id="configurationEncryptor" class="org.jasypt.encryption.pbe.StandardPBEStringEncryptor">
        <property name="config" ref="environmentVariablesConfiguration" />
    </bean>

     <!-- env variables used by configurationEncryptor -->
    <bean id="environmentVariablesConfiguration" class="org.jasypt.encryption.pbe.config.EnvironmentStringPBEConfig">
        <property name="algorithm" value="spring.sec.encrypt.algorithm.key" />
        <property name="passwordEnvName" value="${spring.sec.encrypt.password.key}" />
    </bean>

    <bean id="hibernateStringEncryptor" class="org.jasypt.hibernate.encryptor.HibernatePBEStringEncryptor">
        <property name="registeredName">
        <value>strongHibernateStringEncryptor</value>
        </property>
        <property name="algorithm">
            <value>${spring.sec.encrypt.algorithm.key}</value>
        </property>
        <property name="password">
            <value>${spring.sec.encrypt.password.key}</value>
        </property>
    </bean>

    <import resource="encuestame-test-encrypt-context.xml"/>

    <ehcache:annotation-driven />

     <ehcache:config cache-manager="cacheManager">
        <ehcache:evict-expired-elements interval="60" />
     </ehcache:config>

    <bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean">
        <property name="configLocation"  value="classpath:spring-test/test-ehcache.xml"/>
    </bean>

    <!-- ehcache configuration

    <ehcache:config configLocation="classpath:ehcache.xml" />

     -->
    <!-- Question Dao
    <ehcache:annotations>

        <ehcache:caching id="retrieveQuestionsByName" cacheName="questionCache" />
        <ehcache:caching id="retrieveQuestionById" cacheName="questionCache" />
        <ehcache:caching id="retrieveAnswerById" cacheName="questionCache" />
        <ehcache:flushing id="createQuestion" cacheNames="questionCache" />
    </ehcache:annotations>
    -->
    <!-- Permission Dao
    <ehcache:annotations>

        <ehcache:caching id="loadAllPermissions" cacheName="permissionCache" />
        <ehcache:caching id="loadPermission" cacheName="permissionCache" />
        <ehcache:caching id="getPermissionById" cacheName="permissionCache" />
        <ehcache:flushing id="createPermission" cacheNames="permissionCache" />
    </ehcache:annotations>
    -->
</beans>