Skip to content
This repository has been archived by the owner on Jan 21, 2021. It is now read-only.

Commit

Permalink
Create persistence configs for couch and postges to allow one choose …
Browse files Browse the repository at this point in the history
…database

Signed-off-by: Samuel Githengi <samuel.githengi@gmail.com>
  • Loading branch information
githengi committed Mar 9, 2018
1 parent 6014fa0 commit ebbb0e0
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 14 deletions.
17 changes: 3 additions & 14 deletions opensrp-core/src/main/resources/applicationContext-opensrp.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,11 @@
<util:properties id="opensrp" location="classpath:/opensrp.properties" />

<context:annotation-config />
<context:component-scan base-package="org.opensrp" />

<bean id="opensrpDatabaseConnector" class="org.ektorp.impl.StdCouchDbConnector">
<constructor-arg value="${couchdb.db.opensrp}" />
<constructor-arg ref="couchDbInstance" />
</bean>

<bean id="opensrpMCTSDatabaseConnector" class="org.ektorp.impl.StdCouchDbConnector">
<constructor-arg value="${couchdb.db.mcts}" />
<constructor-arg ref="couchDbInstance" />
</bean>
<bean id="statsdAgent" class="org.motechproject.metrics.impl.LoggingAgentBackendImpl" />
<bean id="opensrpErrorTraceDatabaseConnector" class="org.ektorp.impl.StdCouchDbConnector">
<constructor-arg value="${couchdb.db.error}" />
<constructor-arg ref="couchDbInstance" />
</bean>

<import resource="persistence_couchdb.xml"/>
<!-- <import resource="persistence_postgress.xml"/> -->

<task:scheduler id="applicationScheduler" pool-size="10" />

Expand Down
27 changes: 27 additions & 0 deletions opensrp-core/src/main/resources/persistence_couchdb.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<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"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">

<context:component-scan base-package="org.opensrp">
<context:exclude-filter type="regex"
expression="org\.opensrp\.repository\.postgres\..*" />
</context:component-scan>

<bean id="opensrpDatabaseConnector" class="org.ektorp.impl.StdCouchDbConnector">
<constructor-arg value="${couchdb.db.opensrp}" />
<constructor-arg ref="couchDbInstance" />
</bean>

<bean id="opensrpMCTSDatabaseConnector" class="org.ektorp.impl.StdCouchDbConnector">
<constructor-arg value="${couchdb.db.mcts}" />
<constructor-arg ref="couchDbInstance" />
</bean>

<bean id="opensrpErrorTraceDatabaseConnector" class="org.ektorp.impl.StdCouchDbConnector">
<constructor-arg value="${couchdb.db.error}" />
<constructor-arg ref="couchDbInstance" />
</bean>

</beans>
43 changes: 43 additions & 0 deletions opensrp-core/src/main/resources/persistence_postgres.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8"?>
<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"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">

<context:component-scan base-package="org.opensrp">
<context:exclude-filter type="regex"
expression="org\.opensrp\.repository\.couch\..*" />
</context:component-scan>


<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="org.postgresql.Driver" />
<property name="url" value="jdbc:postgresql://localhost:5432/opensrp" />
<property name="username" value="opensrp_admin" />
<property name="password" value="admin" />
</bean>

<tx:annotation-driven transaction-manager="transactionManager" />
<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean>

<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="typeAliasesPackage" value="org.opensrp.domain" />
<property name="mapperLocations"
value="classpath*:org/opensrp/resositories/postgress/mapper/xml/*.xml" />
</bean>

<bean id="sqlSession" class="org.mybatis.spring.SqlSessionTemplate">
<constructor-arg index="0" ref="sqlSessionFactory" />
</bean>

<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="org.opensrp.repository.postgres.mapper" />
</bean>
</beans>

0 comments on commit ebbb0e0

Please sign in to comment.