Skip to content
Snippets Groups Projects
Commit 8f06b0f0 authored by srosse's avatar srosse
Browse files

OO-292: implements discovery of jdbc connection via jdni name

parent 52d43f66
No related branches found
No related tags found
No related merge requests found
...@@ -24,13 +24,13 @@ ...@@ -24,13 +24,13 @@
<!-- EntityManagerFactory --> <!-- EntityManagerFactory -->
<bean id="emf" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"> <bean id="emf" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="persistenceUnitManager" ref="pum"/> <property name="persistenceUnitManager" ref="pum"/>
<property name="jpaProperties" ref="${db.vendor}HibernateProperties"/> <property name="jpaProperties" ref="${db.vendor}_${db.source}_HibernateProperties"/>
</bean> </bean>
<bean id="AuditInterceptor" class="org.olat.core.commons.persistence.AuditInterceptor" /> <bean id="AuditInterceptor" class="org.olat.core.commons.persistence.AuditInterceptor" />
<bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <bean id="txManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="dataSource" ref="${db.vendor}PooledDataSource"/> <property name="entityManagerFactory" ref="emf"/>
</bean> </bean>
<bean id="database" class="org.olat.core.commons.persistence.DBImpl" destroy-method="destroy"> <bean id="database" class="org.olat.core.commons.persistence.DBImpl" destroy-method="destroy">
...@@ -47,7 +47,7 @@ ...@@ -47,7 +47,7 @@
</constructor-arg> </constructor-arg>
</bean> </bean>
<bean id="mysqlHibernateProperties" class="org.olat.core.commons.persistence.DBVendorHibernatePropertiesSimplification"> <bean id="mysql_local_HibernateProperties" class="org.olat.core.commons.persistence.DBVendorHibernatePropertiesSimplification">
<constructor-arg> <constructor-arg>
<props> <props>
<!-- Using datasource of hibernate --> <!-- Using datasource of hibernate -->
...@@ -60,8 +60,19 @@ ...@@ -60,8 +60,19 @@
</constructor-arg> </constructor-arg>
<property name="addMoreProperties" ref="c3p0HibernateProperties" /> <property name="addMoreProperties" ref="c3p0HibernateProperties" />
</bean> </bean>
<bean id="mysql_jndi_HibernateProperties" class="org.olat.core.commons.persistence.DBVendorHibernatePropertiesSimplification">
<constructor-arg>
<props>
<!-- Using datasource of hibernate -->
<prop key="hibernate.connection.datasource">${db.jndi}</prop>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</prop>
</props>
</constructor-arg>
<property name="addMoreProperties" ref="hibernateProps" />
</bean>
<bean id="postgresqlHibernateProperties" class="org.olat.core.commons.persistence.DBVendorHibernatePropertiesSimplification"> <bean id="postgresql_local_HibernateProperties" class="org.olat.core.commons.persistence.DBVendorHibernatePropertiesSimplification">
<constructor-arg> <constructor-arg>
<props> <props>
<prop key="hibernate.connection.driver_class">org.postgresql.Driver</prop> <prop key="hibernate.connection.driver_class">org.postgresql.Driver</prop>
...@@ -73,6 +84,17 @@ ...@@ -73,6 +84,17 @@
</constructor-arg> </constructor-arg>
<property name="addMoreProperties" ref="c3p0HibernateProperties" /> <property name="addMoreProperties" ref="c3p0HibernateProperties" />
</bean> </bean>
<bean id="postgresql_jndi_HibernateProperties" class="org.olat.core.commons.persistence.DBVendorHibernatePropertiesSimplification">
<constructor-arg>
<props>
<!-- Using datasource of hibernate -->
<prop key="hibernate.connection.datasource">${db.jndi}</prop>
<prop key="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</prop>
</props>
</constructor-arg>
<property name="addMoreProperties" ref="hibernateProps" />
</bean>
<bean id="hibernateProps" class="org.olat.core.commons.persistence.DBVendorHibernatePropertiesSimplification"> <bean id="hibernateProps" class="org.olat.core.commons.persistence.DBVendorHibernatePropertiesSimplification">
<constructor-arg> <constructor-arg>
...@@ -140,10 +162,9 @@ ...@@ -140,10 +162,9 @@
<property name="addMoreProperties" ref="hibernateProps" /> <property name="addMoreProperties" ref="hibernateProps" />
</bean> </bean>
<!-- c3p0 pooled JDBC connection --> <!-- c3p0 pooled JDBC connection
<bean id="mysqlPooledDataSource" <bean id="mysql_local_DataSource"
class="com.mchange.v2.c3p0.ComboPooledDataSource" lazy-init="true" destroy-method="close"> class="com.mchange.v2.c3p0.ComboPooledDataSource" lazy-init="true" destroy-method="close">
<!-- connection settings -->
<property name="driverClass"><value>com.mysql.jdbc.Driver</value></property> <property name="driverClass"><value>com.mysql.jdbc.Driver</value></property>
<property name="jdbcUrl"><value>jdbc:mysql://${db.host}:${db.host.port}/${db.name}?useUnicode=true&amp;characterEncoding=UTF-8</value></property> <property name="jdbcUrl"><value>jdbc:mysql://${db.host}:${db.host.port}/${db.name}?useUnicode=true&amp;characterEncoding=UTF-8</value></property>
<property name="user" value="${db.user}" /> <property name="user" value="${db.user}" />
...@@ -155,14 +176,13 @@ ...@@ -155,14 +176,13 @@
<property name="autoCommitOnClose" value="false" /> <property name="autoCommitOnClose" value="false" />
<property name="acquireIncrement" value="2" /> <property name="acquireIncrement" value="2" />
<property name="idleConnectionTestPeriod" value="500" /> <property name="idleConnectionTestPeriod" value="500" />
<!-- property name="hibernate.c3p0.numHelperThreads" value="10" --> <property name="hibernate.c3p0.numHelperThreads" value="10">
<property name="maxAdministrativeTaskTime" value="120" /> <property name="maxAdministrativeTaskTime" value="120" />
</bean> </bean> -->
<!-- c3p0 pooled JDBC connection --> <!-- c3p0 pooled JDBC connection
<bean id="postgresqlPooledDataSource" <bean id="postgresql_local_DataSource"
class="com.mchange.v2.c3p0.ComboPooledDataSource" lazy-init="true" destroy-method="close"> class="com.mchange.v2.c3p0.ComboPooledDataSource" lazy-init="true" destroy-method="close">
<!-- connection settings -->
<property name="driverClass"><value>org.postgresql.Driver</value></property> <property name="driverClass"><value>org.postgresql.Driver</value></property>
<property name="jdbcUrl"><value>jdbc:postgresql://${db.host}:${db.host.port}/${db.name}</value></property> <property name="jdbcUrl"><value>jdbc:postgresql://${db.host}:${db.host.port}/${db.name}</value></property>
<property name="user" value="${db.user}" /> <property name="user" value="${db.user}" />
...@@ -174,28 +194,35 @@ ...@@ -174,28 +194,35 @@
<property name="autoCommitOnClose" value="false" /> <property name="autoCommitOnClose" value="false" />
<property name="acquireIncrement" value="2" /> <property name="acquireIncrement" value="2" />
<property name="idleConnectionTestPeriod" value="500" /> <property name="idleConnectionTestPeriod" value="500" />
<!-- property name="hibernate.c3p0.numHelperThreads" value="10" --> < property name="hibernate.c3p0.numHelperThreads" value="10">
<property name="maxAdministrativeTaskTime" value="120" /> <property name="maxAdministrativeTaskTime" value="120" />
</bean> </bean> -->
<!-- The following dataresources are referenced from the statisticContext.xml and upgradeContext.xml, but are not used in the SessionFactory! <!-- The following dataresources are referenced from the statisticContext.xml and upgradeContext.xml, but are not used in the SessionFactory!
The SessionFactory's DB Connection is configured with the bean "${db.vendor}HibernateProperties".--> The SessionFactory's DB Connection is configured with the bean "${db.vendor}HibernateProperties".-->
<!-- The mysql datasource checks upon startup whether the tables are of type InnoDB, if not it will not start. If you have an other type of transactional tables just switch back the spring config <!-- The mysql datasource checks upon startup whether the tables are of type InnoDB, if not it will not start. If you have an other type of transactional tables just switch back the spring config
to the normal org.springframework.jdbc.datasource.DriverManagerDataSource and the check is gone.--> to the normal org.springframework.jdbc.datasource.DriverManagerDataSource and the check is gone.-->
<bean id="mysqlDataSource" class="org.olat.core.commons.persistence.InnoDBAwareDriverManagerDataSource" lazy-init="true" init-method="init"> <bean id="mysql_local_DataSource" class="org.olat.core.commons.persistence.InnoDBAwareDriverManagerDataSource" lazy-init="true" init-method="init">
<property name="driverClassName"><value>com.mysql.jdbc.Driver</value></property> <property name="driverClassName"><value>com.mysql.jdbc.Driver</value></property>
<property name="url"><value>jdbc:mysql://${db.host}:${db.host.port}/${db.name}?useUnicode=true&amp;characterEncoding=UTF-8</value></property> <property name="url"><value>jdbc:mysql://${db.host}:${db.host.port}/${db.name}?useUnicode=true&amp;characterEncoding=UTF-8</value></property>
<property name="username" value="${db.user}" /> <property name="username" value="${db.user}" />
<property name="password" value="${db.pass}" /> <property name="password" value="${db.pass}" />
<property name="dbVendor" value="${db.vendor}" /> <property name="dbVendor" value="${db.vendor}" />
</bean> </bean>
<bean id="mysql_jndi_DataSource" class="org.springframework.jndi.JndiObjectFactoryBean" lazy-init="true">
<property name="jndiName" value="${db.jndi}"/>
</bean>
<bean id="postgresqlDataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource" lazy-init="true"> <bean id="postgresql_local_DataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource" lazy-init="true">
<property name="driverClassName"><value>org.postgresql.Driver</value></property> <property name="driverClassName"><value>org.postgresql.Driver</value></property>
<property name="url"><value>jdbc:postgresql://${db.host}:${db.host.port}/${db.name}</value></property> <property name="url"><value>jdbc:postgresql://${db.host}:${db.host.port}/${db.name}</value></property>
<property name="username" value="${db.user}" /> <property name="username" value="${db.user}" />
<property name="password" value="${db.pass}" /> <property name="password" value="${db.pass}" />
</bean> </bean>
</beans> <bean id="postgresql_jndi_DataSource" class="org.springframework.jndi.JndiObjectFactoryBean" lazy-init="true">
<property name="jndiName" value="${db.jndi}"/>
</bean>
</beans>
\ No newline at end of file
...@@ -230,7 +230,7 @@ ...@@ -230,7 +230,7 @@
class="org.springframework.jdbc.core.JdbcTemplate"> class="org.springframework.jdbc.core.JdbcTemplate">
<property name="dataSource"> <property name="dataSource">
<ref bean="${db.vendor}DataSource"/> <ref bean="${db.vendor}_${db.source}_DataSource"/>
</property> </property>
</bean> </bean>
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
depends-on="org.olat.core.util.WebappHelper"> depends-on="org.olat.core.util.WebappHelper">
<property name="dbVendor" value="${db.vendor}"/> <property name="dbVendor" value="${db.vendor}"/>
<property name="upgradesDefinitions" ref="databaseUpgrades"/> <property name="upgradesDefinitions" ref="databaseUpgrades"/>
<property name="dataSource" ref="${db.vendor}DataSource"/> <property name="dataSource" ref="${db.vendor}_${db.source}_DataSource"/>
<property name="autoUpgradeDatabase" value="${auto.upgrade.database}" /> <property name="autoUpgradeDatabase" value="${auto.upgrade.database}" />
</bean> </bean>
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
<bean id="olatUpgradeManager.enabled" class="org.olat.upgrade.UpgradeManagerImpl" lazy-init="true" init-method="init" depends-on="folderModule"> <bean id="olatUpgradeManager.enabled" class="org.olat.upgrade.UpgradeManagerImpl" lazy-init="true" init-method="init" depends-on="folderModule">
<property name="dbVendor" value="${db.vendor}"/> <property name="dbVendor" value="${db.vendor}"/>
<property name="upgradesDefinitions" ref="olatupgrades"/> <property name="upgradesDefinitions" ref="olatupgrades"/>
<property name="dataSource" ref="${db.vendor}DataSource"/> <property name="dataSource" ref="${db.vendor}_${db.source}_DataSource"/>
<property name="autoUpgradeDatabase" value="${auto.upgrade.database}" /> <property name="autoUpgradeDatabase" value="${auto.upgrade.database}" />
</bean> </bean>
<bean id="olatUpgradeManager.disabled" class="org.olat.upgrade.UpgradeManagerDummy" init-method="init" lazy-init="true"/> <bean id="olatUpgradeManager.disabled" class="org.olat.upgrade.UpgradeManagerDummy" init-method="init" lazy-init="true"/>
......
...@@ -388,11 +388,19 @@ db.vendor=mysql ...@@ -388,11 +388,19 @@ db.vendor=mysql
db.vendor.values=mysql,postgresql db.vendor.values=mysql,postgresql
db.vendor.values.comment=supported vendors currently include "mysql" and "postgresql", Hsqldb is used for development db.vendor.values.comment=supported vendors currently include "mysql" and "postgresql", Hsqldb is used for development
db.source=local
db.source.values=local,jndi
db.source.values.comment=supports jdbc connections created locally (local) or search them with a jndi name (jndi)
# the server hosting the database # the server hosting the database
db.host=localhost db.host=localhost
db.host.port=3306 db.host.port=3306
db.host.port.values=3306 (mysql default), 5432 (postgresql default) db.host.port.values=3306 (mysql default), 5432 (postgresql default)
# jndi name to find the jdbc connections
db.jndi=
db.jndi.values=java:comp/env/jdbc/OpenOLATDS
db.name=olat db.name=olat
db.user=olat db.user=olat
db.pass=olat db.pass=olat
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment