<?xml version="1.0"?>

<beans
    default-destroy-method="destroy"
    default-init-method="afterPropertiesSet"
    xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">

  <!--
    NOTE: Current restriction in LR7's handling of external data sources requires us to redefine the
    liferayDataSource bean in our spring configuration.
   -->

  <bean class="com.liferay.portal.dao.jdbc.spring.DataSourceFactoryBean" id="liferayDataSourceImpl">
    <property name="propertyPrefix" value="custom." />
    <property name="properties">
      <props>
        <prop key="custom.jndi.name">jdbc/extDS</prop>
        <prop key="custom.jdbc.default.driverClassName">oracle.jdbc.driver.OracleDriver</prop>
        <prop key="custom.hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</prop>
      </props>
    </property>
  </bean>

  <bean class="org.springframework.jdbc.datasource.LazyConnectionDataSourceProxy" id="liferayDataSource">
    <property name="targetDataSource" ref="liferayDataSourceImpl" />
  </bean>

  <!--
    So our entities are all appropriately tagged with the extDataSource, we'll alias the above
    liferayDataSource so it matches the entities.
   -->

  <alias alias="extDS" name="liferayDataSource" />
</beans>
