Code development platform for open source projects from the European Union institutions

Skip to content
Snippets Groups Projects
spring-context.xml 3.45 KiB
<!--
  ~ Copyright 2017 European Commission | CEF eDelivery
  ~
  ~ Licensed under the EUPL, Version 1.1 or – as soon they will be approved by the European Commission - subsequent versions of the EUPL (the "Licence");
  ~ You may not use this work except in compliance with the Licence.
  ~
  ~ You may obtain a copy of the Licence at:
  ~ https://joinup.ec.europa.eu/software/page/eupl
  ~ or file: LICENCE-EUPL-v1.1.pdf
  ~
  ~ Unless required by applicable law or agreed to in writing, software distributed under the Licence is distributed on an "AS IS" basis,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ See the Licence for the specific language governing permissions and limitations under the Licence.
  -->

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
       http://www.springframework.org/schema/beans/spring-beans.xsd
       http://www.springframework.org/schema/tx
       http://www.springframework.org/schema/tx/spring-tx-4.3.xsd">

    <bean id="configFile" class="eu.europa.ec.cipa.smp.server.util.ConfigFile">
        <constructor-arg type="java.lang.String" value="smp.config.properties"/>
    </bean>

    <bean id="blueCoatEnabled" factory-bean="configFile" factory-method="getString">
        <constructor-arg value="authentication.blueCoat.enabled"/>
    </bean>

    <bean id="encodedSlashesAllowedInUrl" factory-bean="configFile" factory-method="getString">
        <constructor-arg value="encodedSlashesAllowedInUrl"/>
    </bean>

    <!-- TODO: Refactor datasource creation once the application is rewritten into Spring -->
    <bean id="jdbcDriver" factory-bean="configFile" factory-method="getString">
        <constructor-arg value="jdbc.driver"/>
    </bean>
    <bean id="jdbcUrl" factory-bean="configFile" factory-method="getString">
        <constructor-arg value="jdbc.url"/>
    </bean>
    <bean id="jdbcUser" factory-bean="configFile" factory-method="getString">
        <constructor-arg value="jdbc.user"/>
    </bean>
    <bean id="jdbcPass" factory-bean="configFile" factory-method="getString">
        <constructor-arg value="jdbc.password"/>
    </bean>
    <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <property name="driverClassName" ref="jdbcDriver"/>
        <property name="url" ref="jdbcUrl"/>
        <property name="username" ref="jdbcUser"/>
        <property name="password" ref="jdbcPass"/>
    </bean>

    <bean id="smpEntityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
        <property name="persistenceXmlLocation" value="classpath:META-INF/smp-persistence.xml" />
        <property name="dataSource" ref="dataSource"/>
        <property name="packagesToScan" value="eu.europa.ec.cipa.smp.server.data.dbms.model"/>
        <property name="jpaVendorAdapter">
            <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"/>
        </property>
        <property name="jpaProperties">
            <props/>
        </property>
    </bean>

    <tx:annotation-driven transaction-manager="smpTransactionManager"/>
    <bean id="smpTransactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
        <property name="entityManagerFactory" ref="smpEntityManagerFactory"/>
    </bean>

</beans>