blob: 593d38e87d815ce2dfb6e44247495eca6c2fcac9 [file] [log] [blame]
Michael Hanlbd852b82015-11-18 22:17:00 +01001<?xml version="1.0" encoding="UTF-8"?>
2<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
margaretha62055f72017-04-11 19:17:43 +02003 xmlns:p="http://www.springframework.org/schema/p" xmlns:util="http://www.springframework.org/schema/util"
4 xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
margarethaade7d4a2017-07-20 19:53:35 +02005 xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context"
6 xmlns:cache="http://www.springframework.org/schema/cache"
margaretha62055f72017-04-11 19:17:43 +02007 xsi:schemaLocation="http://www.springframework.org/schema/beans
margarethaade7d4a2017-07-20 19:53:35 +02008 http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
9 http://www.springframework.org/schema/tx
10 http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
11 http://www.springframework.org/schema/aop
12 http://www.springframework.org/schema/aop/spring-aop-4.0.xsd
13 http://www.springframework.org/schema/context
14 http://www.springframework.org/schema/context/spring-context-4.0.xsd
15 http://www.springframework.org/schema/util
16 http://www.springframework.org/schema/util/spring-util-4.0.xsd">
Michael Hanlbd852b82015-11-18 22:17:00 +010017
margarethaade7d4a2017-07-20 19:53:35 +020018 <context:component-scan base-package="de.ids_mannheim.korap" />
19 <context:annotation-config />
Michael Hanlbd852b82015-11-18 22:17:00 +010020
margaretha62055f72017-04-11 19:17:43 +020021 <bean id="props"
22 class="org.springframework.beans.factory.config.PropertiesFactoryBean">
23 <property name="ignoreResourceNotFound" value="true" />
24 <property name="locations">
25 <array>
margaretha0c47c652017-04-19 18:44:40 +020026 <value>classpath:kustvakt-test.conf</value>
27 <value>file:./kustvakt-test.conf</value>
margaretha62055f72017-04-11 19:17:43 +020028 </array>
29 </property>
30 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +010031
margarethaade7d4a2017-07-20 19:53:35 +020032 <bean id="placeholders"
33 class="org.springframework.context.support.PropertySourcesPlaceholderConfigurer">
margaretha62055f72017-04-11 19:17:43 +020034 <property name="ignoreResourceNotFound" value="true" />
35 <property name="locations">
36 <array>
margaretha6c2a20f2017-07-24 15:33:01 +020037 <value>classpath:test-jdbc.properties</value>
margarethaade7d4a2017-07-20 19:53:35 +020038 <value>classpath:hibernate.properties</value>
margarethaf18298b2017-09-14 22:14:32 +020039 <value>classpath:kustvakt-test.conf</value>
margaretha62055f72017-04-11 19:17:43 +020040 </array>
41 </property>
42 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +010043
margaretha62055f72017-04-11 19:17:43 +020044 <bean id='cacheManager' class='org.springframework.cache.ehcache.EhCacheCacheManager'
45 p:cacheManager-ref='ehcache' />
Michael Hanlbd852b82015-11-18 22:17:00 +010046
margaretha62055f72017-04-11 19:17:43 +020047 <bean id='ehcache'
48 class='org.springframework.cache.ehcache.EhCacheManagerFactoryBean'
49 p:configLocation='classpath:ehcache.xml' p:shared='true' />
Michael Hanlbd852b82015-11-18 22:17:00 +010050
margaretha62055f72017-04-11 19:17:43 +020051 <!-- props are injected from default-config.xml -->
52 <bean id="kustvakt_config" class="de.ids_mannheim.korap.config.KustvaktConfiguration">
margarethaf68daa62017-09-21 02:11:24 +020053 <constructor-arg name="properties" ref="props" />
margaretha62055f72017-04-11 19:17:43 +020054 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +010055
margaretha6c2a20f2017-07-24 15:33:01 +020056 <bean id="dataSource" class="org.apache.commons.dbcp2.BasicDataSource"
57 lazy-init="true">
58 <property name="driverClassName" value="${jdbc.driverClassName}" />
59 <property name="url" value="${jdbc.url}" />
60 <property name="username" value="${jdbc.username}" />
61 <property name="password" value="${jdbc.password}" />
margaretha514e1412017-10-10 15:54:20 +020062 <property name="maxTotal" value="1" />
63 <property name="maxIdle" value="1" />
margaretha6c2a20f2017-07-24 15:33:01 +020064 <property name="minIdle" value="1" />
65 <property name="maxWaitMillis" value="15000" />
66 <!--<property name="poolPreparedStatements" value="true"/> -->
67 </bean>
68
margaretha514e1412017-10-10 15:54:20 +020069 <!-- use SingleConnection only for testing! -->
margaretha6c2a20f2017-07-24 15:33:01 +020070 <bean id="sqliteDataSource"
margaretha62055f72017-04-11 19:17:43 +020071 class="org.springframework.jdbc.datasource.SingleConnectionDataSource"
margaretha514e1412017-10-10 15:54:20 +020072 lazy-init="true" destroy-method="destroy">
73 <!-- <property name="driverClassName" value="${jdbc.driverClassName}" /> -->
margaretha6c2a20f2017-07-24 15:33:01 +020074 <property name="url" value="${jdbc.url}" />
75 <property name="username" value="${jdbc.username}" />
76 <property name="password" value="${jdbc.password}" />
margaretha514e1412017-10-10 15:54:20 +020077 <!-- Sqlite can only have a single connection -->
margaretha62055f72017-04-11 19:17:43 +020078 <property name="suppressClose">
79 <value>true</value>
80 </property>
margaretha514e1412017-10-10 15:54:20 +020081 </bean>
82
83 <bean id="c3p0DataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
84 destroy-method="close">
85 <property name="driverClass" value="${jdbc.driverClassName}" />
86 <property name="jdbcUrl" value="${jdbc.url}" />
87 <property name="user" value="${jdbc.username}" />
88 <property name="password" value="${jdbc.password}" />
89 <property name="maxPoolSize" value="1" />
90 <property name="minPoolSize" value="1" />
91 <property name="maxStatements" value="1" />
92 <property name="testConnectionOnCheckout" value="true" />
margaretha62055f72017-04-11 19:17:43 +020093 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +010094
margaretha62055f72017-04-11 19:17:43 +020095 <!-- to configure database for sqlite, mysql, etc. migrations -->
96 <bean id="flyway" class="org.flywaydb.core.Flyway" init-method="migrate">
margaretha514e1412017-10-10 15:54:20 +020097 <property name="baselineOnMigrate" value="false" />
98 <property name="locations" value="${jdbc.schemaPath}" />
margaretha6c2a20f2017-07-24 15:33:01 +020099 <property name="dataSource" ref="sqliteDataSource" />
margaretha62055f72017-04-11 19:17:43 +0200100 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +0100101
margaretha62055f72017-04-11 19:17:43 +0200102 <bean id="kustvakt_db" class="de.ids_mannheim.korap.handlers.JDBCClient">
margarethabc9caf42017-09-21 18:52:52 +0200103 <constructor-arg index="0" ref="sqliteDataSource" />
104 <property name="database" value="sqlite" />
margaretha62055f72017-04-11 19:17:43 +0200105 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +0100106
margarethaade7d4a2017-07-20 19:53:35 +0200107 <bean id="entityManagerFactory"
108 class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
109 <property name="dataSource" ref="dataSource" />
110 <property name="packagesToScan" value="de.ids_mannheim.korap.entity" />
111 <property name="jpaVendorAdapter">
112 <bean id="jpaVendorAdapter"
113 class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
114 <property name="databasePlatform" value="${hibernate.dialect}" />
115 </bean>
116 </property>
117 <property name="jpaProperties">
118 <props>
119 <prop key="hibernate.dialect">${hibernate.dialect}</prop>
120 <prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop>
121 <prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
122 <prop key="hibernate.cache.use_query_cache">${hibernate.cache.use_query_cache}</prop>
123 <prop key="hibernate.cache.use_second_level_cache">${hibernate.cache.use_second_level_cache}
124 </prop>
125 <prop key="hibernate.cache.provider_class">${hibernate.cache.provider}</prop>
126 <prop key="hibernate.cache.region.factory_class">${hibernate.cache.region.factory}</prop>
127 <!-- <prop key="net.sf.ehcache.configurationResourceName">classpath:ehcache.xml</prop> -->
128 </props>
129 </property>
margaretha62055f72017-04-11 19:17:43 +0200130 </bean>
Michael Hanle4fc7752016-02-17 11:41:18 +0100131
margarethaade7d4a2017-07-20 19:53:35 +0200132 <tx:annotation-driven proxy-target-class="true"
133 transaction-manager="transactionManager" />
134 <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
135 <property name="entityManagerFactory" ref="entityManagerFactory" />
margaretha62055f72017-04-11 19:17:43 +0200136 </bean>
Michael Hanle4fc7752016-02-17 11:41:18 +0100137
margarethaade7d4a2017-07-20 19:53:35 +0200138 <bean id="transactionTemplate"
139 class="org.springframework.transaction.support.TransactionTemplate">
140 <constructor-arg ref="transactionManager" />
141 </bean>
142
143 <!-- Data access objects -->
144 <bean id="resourceDao" class="de.ids_mannheim.korap.dao.ResourceDao"/>
145 <!-- <bean id="annotationDao" class="de.ids_mannheim.korap.dao.AnnotationDao"/> -->
146
margaretha6c2a20f2017-07-24 15:33:01 +0200147 <!-- Krill -->
148 <bean id="search_krill" class="de.ids_mannheim.korap.web.SearchKrill">
149 <constructor-arg value="${krill.indexDir}"/>
150 </bean>
151
margaretha62055f72017-04-11 19:17:43 +0200152 <bean id="kustvakt_auditing" class="de.ids_mannheim.korap.handlers.JDBCAuditing">
153 <constructor-arg ref="kustvakt_db" />
154 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +0100155
margaretha62055f72017-04-11 19:17:43 +0200156 <bean id="kustvakt_userdb" class="de.ids_mannheim.korap.handlers.EntityDao">
157 <constructor-arg ref="kustvakt_db" />
158 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +0100159
margaretha62055f72017-04-11 19:17:43 +0200160 <bean id="kustvakt_admindb" class="de.ids_mannheim.korap.handlers.AdminDao">
161 <constructor-arg ref="kustvakt_db" />
162 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +0100163
margaretha62055f72017-04-11 19:17:43 +0200164 <bean id="resource_provider" class="de.ids_mannheim.korap.handlers.ResourceDao">
165 <constructor-arg ref="kustvakt_db" />
166 </bean>
Michael Hanlf8fcc7a2016-06-03 17:41:07 +0200167
margaretha62055f72017-04-11 19:17:43 +0200168 <bean id="document_provider" class="de.ids_mannheim.korap.handlers.DocumentDao">
169 <constructor-arg ref="kustvakt_db" />
170 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +0100171
margaretha62055f72017-04-11 19:17:43 +0200172 <bean id="kustvakt_policies" class="de.ids_mannheim.korap.security.ac.PolicyDao">
173 <constructor-arg ref="kustvakt_db" />
174 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +0100175
margaretha62055f72017-04-11 19:17:43 +0200176 <bean name="kustvakt_encryption"
177 class="de.ids_mannheim.korap.interfaces.defaults.KustvaktEncryption">
178 <constructor-arg ref="kustvakt_config" />
179 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +0100180
margaretha62055f72017-04-11 19:17:43 +0200181 <!-- authentication providers to use -->
182 <bean id="api_auth" class="de.ids_mannheim.korap.security.auth.APIAuthentication">
183 <constructor-arg type="de.ids_mannheim.korap.config.KustvaktConfiguration"
184 ref="kustvakt_config" />
185 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +0100186
margaretha62055f72017-04-11 19:17:43 +0200187 <bean id="openid_auth"
188 class="de.ids_mannheim.korap.security.auth.OpenIDconnectAuthentication">
189 <constructor-arg type="de.ids_mannheim.korap.config.KustvaktConfiguration"
190 ref="kustvakt_config" />
191 <constructor-arg
192 type="de.ids_mannheim.korap.interfaces.db.PersistenceClient" ref="kustvakt_db" />
193 </bean>
194
195 <bean id="basic_auth" class="de.ids_mannheim.korap.security.auth.BasicHttpAuth" />
Michael Hanlbd852b82015-11-18 22:17:00 +0100196
197
margaretha62055f72017-04-11 19:17:43 +0200198 <bean id="session_auth"
199 class="de.ids_mannheim.korap.security.auth.SessionAuthentication">
200 <constructor-arg type="de.ids_mannheim.korap.config.KustvaktConfiguration"
201 ref="kustvakt_config" />
202 <constructor-arg type="de.ids_mannheim.korap.interfaces.EncryptionIface"
203 ref="kustvakt_encryption" />
204 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +0100205
margaretha62055f72017-04-11 19:17:43 +0200206 <util:list id="kustvakt_authproviders"
207 value-type="de.ids_mannheim.korap.interfaces.AuthenticationIface">
208 <ref bean="basic_auth" />
209 <ref bean="session_auth" />
210 <ref bean="api_auth" />
211 <ref bean="openid_auth" />
212 </util:list>
Michael Hanlbd852b82015-11-18 22:17:00 +0100213
margarethaade7d4a2017-07-20 19:53:35 +0200214
margaretha62055f72017-04-11 19:17:43 +0200215 <bean id="userdata_details" class="de.ids_mannheim.korap.handlers.UserDetailsDao">
margarethaade7d4a2017-07-20 19:53:35 +0200216 <constructor-arg ref="kustvakt_db" />
margaretha62055f72017-04-11 19:17:43 +0200217 </bean>
margarethaade7d4a2017-07-20 19:53:35 +0200218
margaretha62055f72017-04-11 19:17:43 +0200219 <bean id="userdata_settings" class="de.ids_mannheim.korap.handlers.UserSettingsDao">
margarethaade7d4a2017-07-20 19:53:35 +0200220 <constructor-arg ref="kustvakt_db" />
margaretha62055f72017-04-11 19:17:43 +0200221 </bean>
Michael Hanldaf86602016-05-12 14:31:52 +0200222
margaretha62055f72017-04-11 19:17:43 +0200223 <util:list id="kustvakt_userdata"
224 value-type="de.ids_mannheim.korap.interfaces.db.UserdataDbIface">
225 <ref bean="userdata_details" />
226 <ref bean="userdata_settings" />
227 </util:list>
Michael Hanldaf86602016-05-12 14:31:52 +0200228
margaretha62055f72017-04-11 19:17:43 +0200229 <util:list id="kustvakt_resources"
230 value-type="de.ids_mannheim.korap.interfaces.db.ResourceOperationIface">
231 <ref bean="document_provider" />
232 <ref bean="resource_provider" />
233 </util:list>
Michael Hanlf8fcc7a2016-06-03 17:41:07 +0200234
margaretha62055f72017-04-11 19:17:43 +0200235 <!-- specify type for constructor argument -->
236 <bean id="kustvakt_authenticationmanager"
237 class="de.ids_mannheim.korap.security.auth.KustvaktAuthenticationManager">
238 <constructor-arg
239 type="de.ids_mannheim.korap.interfaces.db.EntityHandlerIface" ref="kustvakt_userdb" />
240 <constructor-arg
241 type="de.ids_mannheim.korap.interfaces.db.AdminHandlerIface" ref="kustvakt_admindb" />
242 <constructor-arg type="de.ids_mannheim.korap.interfaces.EncryptionIface"
243 ref="kustvakt_encryption" />
244 <constructor-arg ref="kustvakt_config" />
245 <constructor-arg type="de.ids_mannheim.korap.interfaces.db.AuditingIface"
246 ref="kustvakt_auditing" />
247 <constructor-arg ref="kustvakt_userdata" />
248 <!-- inject authentication providers to use -->
249 <property name="providers" ref="kustvakt_authproviders" />
250 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +0100251
margaretha62055f72017-04-11 19:17:43 +0200252 <!-- todo: if db interfaces not loaded via spring, does transaction even
253 work then? -->
254 <!-- the transactional advice (i.e. what 'happens'; see the <aop:advisor/>
255 bean below) -->
256 <tx:advice id="txAdvice" transaction-manager="txManager">
257 <!-- the transactional semantics... -->
258 <tx:attributes>
259 <!-- all methods starting with 'get' are read-only -->
260 <tx:method name="get*" read-only="true" rollback-for="KorAPException" />
261 <!-- other methods use the default transaction settings (see below) -->
262 <tx:method name="*" rollback-for="KorAPException" />
263 </tx:attributes>
264 </tx:advice>
Michael Hanlbd852b82015-11-18 22:17:00 +0100265
margaretha62055f72017-04-11 19:17:43 +0200266 <!-- ensure that the above transactional advice runs for any execution of
267 an operation defined by the service interface -->
268 <aop:config>
269 <aop:pointcut id="service"
270 expression="execution(* de.ids_mannheim.korap.interfaces.db.*.*(..))" />
271 <aop:advisor advice-ref="txAdvice" pointcut-ref="service" />
272 </aop:config>
Michael Hanlbd852b82015-11-18 22:17:00 +0100273
margaretha62055f72017-04-11 19:17:43 +0200274 <!-- similarly, don't forget the PlatformTransactionManager -->
275 <bean id="txManager"
276 class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
277 <property name="dataSource" ref="dataSource" />
278 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +0100279</beans>