<?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:context="http://www.springframework.org/schema/context"
       xmlns:p="http://www.springframework.org/schema/p"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xmlns:util="http://www.springframework.org/schema/util"

       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
          http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd
          http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.3.xsd
          http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.3.xsd">

    <!-- Creating Beans with declared with spring annotations -->
    <context:annotation-config  /> 
    <context:component-scan base-package="com.triz.trizservice.service" />
    <context:component-scan base-package="com.triz.trizservice.bean" />
    <context:component-scan base-package="com.triz.util" />
    <context:component-scan base-package="Api" />
    
        
    
    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
        <property name="url" value="${trizstock.jdbc.url}"/>
        <property name="password" value="${trizstock.jdbc.password}"/>
        <property name="driverClassName" value="${trizstock.jdbc.driver}"/>
        <property name="username" value="${trizstock.jdbc.user}"/>
        <property name="defaultAutoCommit" value="false"/>
        <property name="maxActive" value="377" /> 
    </bean>
    
    <bean id="sessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
        <property name="dataSource" ref="dataSource" />
        <property name="packagesToScan" value="com.triz.trizservice.modeles"/>
        <property name="hibernateProperties" >
            <props>
                <prop key="hibernate.dialect">org.hibernate.dialect.PostgreSQL95Dialect</prop>
                <prop key="hibernate.show_sql">false</prop>
                <prop key="hibernate.enable_lazy_load_no_trans">true</prop>
                <!--<prop key="hibernate.current_session_context_class">thread</prop>-->
            </props>
        </property>
    </bean>
    
    <bean id="transactionManager" class="org.springframework.orm.hibernate5.HibernateTransactionManager" p:sessionFactory-ref="sessionFactory"/>
    <bean id="restAuthenticationEntryPoint" class="org.springframework.security.web.authentication.Http403ForbiddenEntryPoint"/>

    <tx:annotation-driven transaction-manager="transactionManagerStock"/>
    
    
</beans>
