| <?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:tx="http://www.springframework.org/schema/tx" |
| xmlns:aop="http://www.springframework.org/schema/aop" |
| xsi:schemaLocation=" |
| http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd |
| http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd |
| http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd"> |
| |
| |
| <!-- one option is to use a class from spring that will read the properties file |
| and replaces the ${...} placeholders with the appropriate values --> |
| <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> |
| <property name="locations"> |
| <value>classpath:/settings.properties</value> |
| </property> |
| </bean> |
| |
| <!-- Data Source / DB Settings --> |
| <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> |
| <property name="driverClassName" value="${jdbc.driverClass}"/> |
| <property name="url" value="${jdbc.url}"/> |
| <property name="username" value="${jdbc.username}"/> |
| <property name="password" value="${jdbc.password}"/> |
| </bean> |
| |
| <!-- Transaction manager for a single JDBC DataSource (alternative to JTA) --> |
| <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> |
| <constructor-arg ref="dataSource"/> |
| </bean> |
| <bean id="transactionTemplate" class="org.springframework.transaction.support.TransactionTemplate"> |
| <property name="transactionManager" ref="transactionManager"/> |
| </bean> |
| |
| <!-- @Transactional --> |
| <tx:annotation-driven transaction-manager="transactionManager"/> |
| |
| <!-- Empire-DB classes --> |
| <bean id="driverFactory" class="org.apache.empire.samples.spring.support.EmpireDriverFactory"> |
| <property name="dataSource" ref="dataSource" /> |
| </bean> |
| <bean id="databaseDriver" factory-bean="driverFactory" factory-method="createDriver"> |
| <constructor-arg value="${empire.driver}"/> |
| <constructor-arg value="${empire.schemaname}"/> |
| </bean> |
| <bean id="sampleDatabase" class="org.apache.empire.samples.spring.db.SampleDB"> |
| </bean> |
| |
| <!-- application dao/services --> |
| <bean id="empireApp" class="org.apache.empire.samples.spring.EmpireAppImpl"> |
| <property name="dataSource" ref="dataSource"/> |
| <property name="database" ref="sampleDatabase"/> |
| <property name="databaseDriver" ref="databaseDriver"/> |
| </bean> |
| </beans> |