All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.rave.jpa-applicationContext.xml Maven / Gradle / Ivy

There is a newer version: 0.23
Show newest version
<?xml version="1.0" encoding="UTF-8"?>
<!--
  Licensed to the Apache Software Foundation (ASF) under one
  or more contributor license agreements.  See the NOTICE file
  distributed with this work for additional information
  regarding copyright ownership.  The ASF licenses this file
  to you under the Apache License, Version 2.0 (the
  "License"); you may not use this file except in compliance
  with the License.  You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing,
  software distributed under the License is distributed on an
  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  KIND, either express or implied.  See the License for the
  specific language governing permissions and limitations
  under the License.
  -->
<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:tx="http://www.springframework.org/schema/tx"
       xmlns:p="http://www.springframework.org/schema/p"
       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/tx http://www.springframework.org/schema/tx/spring-tx.xsd
        http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd">

    <!-- make the the portal.properties props available to autowire injectors, location of the properties can
     be overridden by setting a system property "portal.override.properties" -->
    <bean id="portalPropertyPlaceholder" class="org.apache.rave.util.OverridablePropertyPlaceholderConfigurer">
        <property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE"/>
        <property name="systemPropertyName" value="portal.override.properties"/>
        <property name="location" value="classpath:portal.properties"/>
    </bean>

    <!-- bean post-processor for JPA annotations -->
    <context:annotation-config/>

    <!-- enable the use of the @AspectJ style of Spring AOP -->
    <aop:aspectj-autoproxy/>

    <!-- rave-common component base-package scan (maybe move to a separate common-applicationContext.xml?) -->
    <context:component-scan base-package="org.apache.rave.service"/>
    <context:component-scan base-package="org.apache.rave.synchronization"/>

    <!-- rave-core component base-package scan -->
    <context:component-scan base-package="org.apache.rave.portal.model"/>
    <context:component-scan base-package="org.apache.rave.portal.repository"/>

    <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
        <property name="entityManagerFactory" ref="entityManagerFactory"/>
    </bean>

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

    <bean id="entityManagerFactory"
          class="org.apache.rave.persistence.jpa.PopulatedLocalContainerEntityManagerFactory">
        <property name="populator" ref="dataSourcePopulator"/>
        <property name="loadTimeWeaver">
            <bean class="org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver"/>
        </property>
        <property name="persistenceUnitName" value="ravePersistenceUnit"/>
        <property name="dataSource" ref="dataSource"/>
        <property name="jpaVendorAdapter">
            <bean class="org.springframework.orm.jpa.vendor.OpenJpaVendorAdapter"
                  p:databasePlatform="${portal.jpaVendorAdapter.databasePlatform}"
                  p:database="${portal.jpaVendorAdapter.database}"
                  p:showSql="${portal.jpaVendorAdapter.showSql}"/>
        </property>
        <property name="jpaDialect">
            <bean class="${portal.jpaDialect}"/>
        </property>
        <property name="jpaPropertyMap">
            <map>
                <entry key="openjpa.Log" value="${portal.openjpa.Log}"/>
                <entry key="openjpa.RuntimeUnenhancedClasses" value="${portal.openjpa.RuntimeUnenhancedClasses}"/>
                <entry key="openjpa.jdbc.SynchronizeMappings" value="${portal.openjpa.jdbc.SynchronizeMappings}"/>
                <entry key="openjpa.jdbc.MappingDefaults" value="${portal.openjpa.jdbc.MappingDefaults}"/>
            </map>
        </property>
    </bean>

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

    <!-- Password encoding -->
    <bean class="org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder" id="passwordEncoder">
        <!--<constructor-arg index="0" value="10"/>-->
    </bean>

    <!-- email settings -->
    <bean id="emailServiceMailMessage" class="org.springframework.mail.SimpleMailMessage">
        <property name="from" value="${portal.mail.sender}"/>
        <property name="replyTo" value="${portal.mail.replyto}"/>
    </bean>

    <bean id="freemarkerMailConfiguration" class="org.springframework.ui.freemarker.FreeMarkerConfigurationFactoryBean">
        <property name="templateLoaderPath" value="/WEB-INF/mailtemplates"/>
    </bean>
    <bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
        <property name="host" value="${portal.mail.host}"/>
        <property name="password" value="${portal.mail.password}"/>
        <property name="username" value="${portal.mail.username}"/>
        <property name="port" value="${portal.mail.port}"/>
        <property name="protocol" value="${portal.mail.protocol}"/>
        <!-- NOTE: if using Gmail, you'll need following properties-->
        <!--<property name="javaMailProperties">
            <props>
                <prop key="mail.smtp.auth">true</prop>
                <prop key="mail.smtp.starttls.enable">true</prop>
                <prop key="mail.smtp.timeout">8500</prop>
            </props>
        </property>-->
    </bean>
    <!--
    NOTE: to use mail session you'll need to configure following within catalina_home/conf/context.xml
    <Resource name="mail/Session" auth="Container" type="javax.mail.Session" mail.smtp.host="my.mail.host"/>

    Further, activation & mail jars needs to be placed within catalina_home/lib folder
    -->
    <!--
    <bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
        <property name="session" ref="mailSession"/>
    </bean>
    <bean id="mailSession" class="org.springframework.jndi.JndiObjectFactoryBean">
        <property name="jndiName" value="java:comp/env/mail/Session"/>
    </bean>
    -->

    <bean id="restTemplate" class="org.springframework.web.client.RestTemplate" />

    <bean id="staticContentCache" class="org.apache.rave.service.impl.DefaultStaticContentFetcherService">
        <constructor-arg ref="restTemplate"/>
        <constructor-arg>
            <list>
                <!-- example of a Static Content source that doesn't have any string token placeholders in its content body
                <bean class="org.apache.rave.model.StaticContent">
                    <constructor-arg index="0" value="standardCompanyHeader"/>
                    <constructor-arg index="1" value="${company.header.host}/content/standard_header.html"/>
                    <constructor-arg index="2">
                        <null/>
                    </constructor-arg>
                </bean>
                -->
                <!-- example of a Static Content source that has string token placeholders
                <bean class="org.apache.rave.model.StaticContent">
                    <constructor-arg index="0" value="environmentSpecificContent"/>
                    <constructor-arg index="1" value="${company.header.host}/content/footer.html"/>
                    <constructor-arg index="2">
                        <map>
                            <entry key="\{supportEmail\}" value="${raveproperty.supportemail}"/>
                            <entry key="\{productVersion\}" value="${raveproperty.version}"/>
                        </map>
                    </constructor-arg>
                </bean>
                -->
            </list>
        </constructor-arg>
    </bean>

    <!-- example on how to setup a Spring Timer to refresh the Static Content cache at a fixed interval
    <bean id="refreshStaticContentCacheScheduledTask" class="org.springframework.scheduling.timer.ScheduledTimerTask">
        <property name="delay" value="5000"/>
        <property name="period" value="300000"/>
        <property name="timerTask">
            <bean class="org.springframework.scheduling.timer.MethodInvokingTimerTaskFactoryBean"
                  p:targetObject-ref="staticContentCache" p:targetMethod="refreshAll"/>
        </property>
    </bean>
    <bean id="timerFactory" class="org.springframework.scheduling.timer.TimerFactoryBean">
        <property name="daemon" value="true"/>
        <property name="scheduledTimerTasks">
            <list>
                <ref local="refreshStaticContentCacheScheduledTask"/>
            </list>
        </property>
    </bean>
    -->
</beans>




© 2015 - 2025 Weber Informatics LLC | Privacy Policy