Merge pull request #6 from ogf/connection-pooling

This commit is contained in:
Lorenzo Tilve 2013-06-06 00:42:52 -07:00
commit 556736af39
6 changed files with 75 additions and 16 deletions

View file

@ -32,6 +32,11 @@
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
<!-- datasource for testing -->
<dependency>
<groupId>com.jolbox</groupId>
<artifactId>bonecp</artifactId>
</dependency>
<!-- Spring -->
<dependency>
<groupId>org.springframework</groupId>

View file

@ -7,10 +7,17 @@
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd">
<bean id="dataSourceReal"
class="com.jolbox.bonecp.BoneCPDataSource" destroy-method="close"
p:driverClass="${jdbcDriver.className}" p:jdbcUrl="${testDataSource.url}"
p:username="${testDataSource.user}" p:password="${testDataSource.password}"
p:maxConnectionsPerPartition="10"
p:minConnectionsPerPartition="4"
p:partitionCount="3"/>
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource"
p:driverClassName="${jdbcDriver.className}" p:url="${testDataSource.url}"
p:username="${testDataSource.user}" p:password="${testDataSource.password}" />
class="org.springframework.jdbc.datasource.LazyConnectionDataSourceProxy"
p:targetDataSource-ref="dataSourceReal" />
<!-- Hibernate Session Factory. -->
<bean id="sessionFactory"

View file

@ -427,6 +427,11 @@
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
<!-- datasource for testing -->
<dependency>
<groupId>com.jolbox</groupId>
<artifactId>bonecp</artifactId>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>

View file

@ -7,10 +7,17 @@
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd">
<bean id="dataSourceReal"
class="com.jolbox.bonecp.BoneCPDataSource" destroy-method="close"
p:driverClass="${jdbcDriver.className}" p:jdbcUrl="${testDataSource.url}"
p:username="${testDataSource.user}" p:password="${testDataSource.password}"
p:maxConnectionsPerPartition="10"
p:minConnectionsPerPartition="4"
p:partitionCount="3"/>
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource"
p:driverClassName="${jdbcDriver.className}" p:url="${testDataSource.url}"
p:username="${testDataSource.user}" p:password="${testDataSource.password}" />
class="org.springframework.jdbc.datasource.LazyConnectionDataSourceProxy"
p:targetDataSource-ref="dataSourceReal" />
<!-- Hibernate Session Factory. -->

43
pom.xml
View file

@ -115,9 +115,9 @@
</activation>
<properties>
<!-- JDBC driver properties -->
<jdbcDriver.groupId>postgresql</jdbcDriver.groupId>
<jdbcDriver.groupId>org.postgresql</jdbcDriver.groupId>
<jdbcDriver.artifactId>postgresql</jdbcDriver.artifactId>
<jdbcDriver.version>8.3-603.jdbc4</jdbcDriver.version>
<jdbcDriver.version>9.2-1003-jdbc4</jdbcDriver.version>
<jdbcDriver.className>org.postgresql.Driver</jdbcDriver.className>
<!-- Data source properties -->
<dataSource.url>jdbc:postgresql://localhost/libreplan${libreplan.mode}</dataSource.url>
@ -263,6 +263,13 @@
<version>4.4</version>
<scope>test</scope>
</dependency>
<!-- datasource for testing -->
<dependency>
<groupId>com.jolbox</groupId>
<artifactId>bonecp</artifactId>
<version>0.7.1.RELEASE</version>
<scope>test</scope>
</dependency>
<!-- Easy mock -->
<dependency>
@ -982,11 +989,33 @@
</configuration>
<dependencies>
<dependency>
<groupId>${jdbcDriver.groupId}</groupId>
<artifactId>${jdbcDriver.artifactId}</artifactId>
<version>${jdbcDriver.version}</version>
</dependency>
<dependency>
<groupId>${jdbcDriver.groupId}</groupId>
<artifactId>${jdbcDriver.artifactId}</artifactId>
<version>${jdbcDriver.version}</version>
</dependency>
<!-- connection pooling -->
<dependency>
<groupId>com.jolbox</groupId>
<artifactId>bonecp</artifactId>
<version>0.7.1.RELEASE</version>
</dependency>
<!-- connection pooling dependencies -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.5.5</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.5.5</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>14.0.1</version>
</dependency>
</dependencies>
</plugin>

View file

@ -6,11 +6,17 @@
<New id="libreplan-ds" class="org.mortbay.jetty.plus.naming.Resource">
<Arg>${dataSource.jndiName}</Arg>
<Arg>
<New class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<Set name="driverClassName">${jdbcDriver.className}</Set>
<Set name="url">${dataSource.url}</Set>
<New class="com.jolbox.bonecp.BoneCPDataSource">
<Set name="driverClass">${jdbcDriver.className}</Set>
<Set name="jdbcUrl">${dataSource.url}</Set>
<Set name="username">${dataSource.user}</Set>
<Set name="password">${dataSource.password}</Set>
<Set name="partitionCount">3</Set>
<Set name="minConnectionsPerPartition">5</Set>
<Set name="maxConnectionsPerPartition">100</Set>
<Set name="acquireIncrement">5</Set>
<Set name="idleConnectionTestPeriod">30</Set>
</New>
</Arg>
</New>