blob: 7b85090babf6225a90d32f06c95e66b44ff94a23 [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>
margaretha1f106f62017-10-18 22:27:30 +020038 <value>file:./test-jdbc.properties</value>
margarethaf6d5a822017-10-19 19:51:20 +020039 <value>classpath:test-hibernate.properties</value>
margarethaf18298b2017-09-14 22:14:32 +020040 <value>classpath:kustvakt-test.conf</value>
margaretha62055f72017-04-11 19:17:43 +020041 </array>
42 </property>
43 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +010044
margaretha62055f72017-04-11 19:17:43 +020045 <bean id='cacheManager' class='org.springframework.cache.ehcache.EhCacheCacheManager'
46 p:cacheManager-ref='ehcache' />
Michael Hanlbd852b82015-11-18 22:17:00 +010047
margaretha62055f72017-04-11 19:17:43 +020048 <bean id='ehcache'
49 class='org.springframework.cache.ehcache.EhCacheManagerFactoryBean'
50 p:configLocation='classpath:ehcache.xml' p:shared='true' />
Michael Hanlbd852b82015-11-18 22:17:00 +010051
margaretha62055f72017-04-11 19:17:43 +020052 <!-- props are injected from default-config.xml -->
53 <bean id="kustvakt_config" class="de.ids_mannheim.korap.config.KustvaktConfiguration">
margarethaf68daa62017-09-21 02:11:24 +020054 <constructor-arg name="properties" ref="props" />
margaretha62055f72017-04-11 19:17:43 +020055 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +010056
margaretha6c2a20f2017-07-24 15:33:01 +020057 <bean id="dataSource" class="org.apache.commons.dbcp2.BasicDataSource"
58 lazy-init="true">
59 <property name="driverClassName" value="${jdbc.driverClassName}" />
60 <property name="url" value="${jdbc.url}" />
61 <property name="username" value="${jdbc.username}" />
62 <property name="password" value="${jdbc.password}" />
margaretha318fec32017-10-24 12:11:58 +020063 <property name="maxTotal" value="4" />
margaretha514e1412017-10-10 15:54:20 +020064 <property name="maxIdle" value="1" />
margaretha6c2a20f2017-07-24 15:33:01 +020065 <property name="minIdle" value="1" />
66 <property name="maxWaitMillis" value="15000" />
67 <!--<property name="poolPreparedStatements" value="true"/> -->
68 </bean>
69
margaretha514e1412017-10-10 15:54:20 +020070 <!-- use SingleConnection only for testing! -->
margaretha6c2a20f2017-07-24 15:33:01 +020071 <bean id="sqliteDataSource"
margaretha62055f72017-04-11 19:17:43 +020072 class="org.springframework.jdbc.datasource.SingleConnectionDataSource"
margaretha318fec32017-10-24 12:11:58 +020073 lazy-init="true">
margaretha514e1412017-10-10 15:54:20 +020074 <!-- <property name="driverClassName" value="${jdbc.driverClassName}" /> -->
margaretha6c2a20f2017-07-24 15:33:01 +020075 <property name="url" value="${jdbc.url}" />
76 <property name="username" value="${jdbc.username}" />
77 <property name="password" value="${jdbc.password}" />
margaretha514e1412017-10-10 15:54:20 +020078 <!-- Sqlite can only have a single connection -->
margaretha62055f72017-04-11 19:17:43 +020079 <property name="suppressClose">
80 <value>true</value>
81 </property>
margaretha514e1412017-10-10 15:54:20 +020082 </bean>
83
84 <bean id="c3p0DataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
85 destroy-method="close">
86 <property name="driverClass" value="${jdbc.driverClassName}" />
87 <property name="jdbcUrl" value="${jdbc.url}" />
88 <property name="user" value="${jdbc.username}" />
89 <property name="password" value="${jdbc.password}" />
margaretha318fec32017-10-24 12:11:58 +020090 <property name="maxPoolSize" value="4" />
margaretha514e1412017-10-10 15:54:20 +020091 <property name="minPoolSize" value="1" />
92 <property name="maxStatements" value="1" />
93 <property name="testConnectionOnCheckout" value="true" />
margaretha62055f72017-04-11 19:17:43 +020094 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +010095
margaretha62055f72017-04-11 19:17:43 +020096 <!-- to configure database for sqlite, mysql, etc. migrations -->
97 <bean id="flyway" class="org.flywaydb.core.Flyway" init-method="migrate">
margarethaf6d5a822017-10-19 19:51:20 +020098 <!-- drop existing tables and create new tables -->
99 <property name="validateOnMigrate" value="true" />
100 <property name="cleanOnValidationError" value="true" />
101
margaretha514e1412017-10-10 15:54:20 +0200102 <property name="baselineOnMigrate" value="false" />
103 <property name="locations" value="${jdbc.schemaPath}" />
margaretha6c2a20f2017-07-24 15:33:01 +0200104 <property name="dataSource" ref="sqliteDataSource" />
margaretha318fec32017-10-24 12:11:58 +0200105 <!-- <property name="dataSource" ref="dataSource" /> -->
margaretha62055f72017-04-11 19:17:43 +0200106 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +0100107
margaretha62055f72017-04-11 19:17:43 +0200108 <bean id="kustvakt_db" class="de.ids_mannheim.korap.handlers.JDBCClient">
margaretha318fec32017-10-24 12:11:58 +0200109 <!-- <constructor-arg index="0" ref="dataSource" /> -->
margarethabc9caf42017-09-21 18:52:52 +0200110 <constructor-arg index="0" ref="sqliteDataSource" />
margaretha318fec32017-10-24 12:11:58 +0200111 <property name="database" value="${jdbc.database}" />
margaretha62055f72017-04-11 19:17:43 +0200112 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +0100113
margarethaade7d4a2017-07-20 19:53:35 +0200114 <bean id="entityManagerFactory"
115 class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
margaretha318fec32017-10-24 12:11:58 +0200116 <!-- <property name="dataSource" ref="dataSource" /> -->
117 <property name="dataSource" ref="sqliteDataSource" />
margarethaade7d4a2017-07-20 19:53:35 +0200118 <property name="packagesToScan" value="de.ids_mannheim.korap.entity" />
119 <property name="jpaVendorAdapter">
120 <bean id="jpaVendorAdapter"
121 class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
122 <property name="databasePlatform" value="${hibernate.dialect}" />
123 </bean>
124 </property>
125 <property name="jpaProperties">
126 <props>
127 <prop key="hibernate.dialect">${hibernate.dialect}</prop>
128 <prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop>
129 <prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
130 <prop key="hibernate.cache.use_query_cache">${hibernate.cache.use_query_cache}</prop>
131 <prop key="hibernate.cache.use_second_level_cache">${hibernate.cache.use_second_level_cache}
132 </prop>
133 <prop key="hibernate.cache.provider_class">${hibernate.cache.provider}</prop>
134 <prop key="hibernate.cache.region.factory_class">${hibernate.cache.region.factory}</prop>
135 <!-- <prop key="net.sf.ehcache.configurationResourceName">classpath:ehcache.xml</prop> -->
136 </props>
137 </property>
margaretha62055f72017-04-11 19:17:43 +0200138 </bean>
Michael Hanle4fc7752016-02-17 11:41:18 +0100139
margarethaade7d4a2017-07-20 19:53:35 +0200140 <tx:annotation-driven proxy-target-class="true"
141 transaction-manager="transactionManager" />
142 <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
143 <property name="entityManagerFactory" ref="entityManagerFactory" />
margaretha62055f72017-04-11 19:17:43 +0200144 </bean>
Michael Hanle4fc7752016-02-17 11:41:18 +0100145
margarethaade7d4a2017-07-20 19:53:35 +0200146 <bean id="transactionTemplate"
147 class="org.springframework.transaction.support.TransactionTemplate">
148 <constructor-arg ref="transactionManager" />
149 </bean>
150
151 <!-- Data access objects -->
152 <bean id="resourceDao" class="de.ids_mannheim.korap.dao.ResourceDao"/>
153 <!-- <bean id="annotationDao" class="de.ids_mannheim.korap.dao.AnnotationDao"/> -->
154
margaretha6c2a20f2017-07-24 15:33:01 +0200155 <!-- Krill -->
156 <bean id="search_krill" class="de.ids_mannheim.korap.web.SearchKrill">
157 <constructor-arg value="${krill.indexDir}"/>
158 </bean>
159
margaretha62055f72017-04-11 19:17:43 +0200160 <bean id="kustvakt_auditing" class="de.ids_mannheim.korap.handlers.JDBCAuditing">
161 <constructor-arg ref="kustvakt_db" />
162 </bean>
margaretha894a7d72017-11-08 19:24:20 +0100163
164 <bean id="kustvakt_response"
165 class="de.ids_mannheim.korap.web.utils.KustvaktResponseHandler">
166 <constructor-arg index="0" name="iface" ref="kustvakt_auditing"/>
167 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +0100168
margaretha62055f72017-04-11 19:17:43 +0200169 <bean id="kustvakt_userdb" class="de.ids_mannheim.korap.handlers.EntityDao">
170 <constructor-arg ref="kustvakt_db" />
171 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +0100172
margaretha62055f72017-04-11 19:17:43 +0200173 <bean id="kustvakt_admindb" class="de.ids_mannheim.korap.handlers.AdminDao">
174 <constructor-arg ref="kustvakt_db" />
175 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +0100176
margaretha62055f72017-04-11 19:17:43 +0200177 <bean id="resource_provider" class="de.ids_mannheim.korap.handlers.ResourceDao">
178 <constructor-arg ref="kustvakt_db" />
179 </bean>
Michael Hanlf8fcc7a2016-06-03 17:41:07 +0200180
margaretha62055f72017-04-11 19:17:43 +0200181 <bean id="document_provider" class="de.ids_mannheim.korap.handlers.DocumentDao">
182 <constructor-arg ref="kustvakt_db" />
183 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +0100184
margaretha62055f72017-04-11 19:17:43 +0200185 <bean id="kustvakt_policies" class="de.ids_mannheim.korap.security.ac.PolicyDao">
186 <constructor-arg ref="kustvakt_db" />
187 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +0100188
margaretha62055f72017-04-11 19:17:43 +0200189 <bean name="kustvakt_encryption"
190 class="de.ids_mannheim.korap.interfaces.defaults.KustvaktEncryption">
191 <constructor-arg ref="kustvakt_config" />
192 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +0100193
margaretha62055f72017-04-11 19:17:43 +0200194 <!-- authentication providers to use -->
margaretha4de41192017-11-15 11:47:11 +0100195 <!-- <bean id="api_auth" class="de.ids_mannheim.korap.authentication.APIAuthentication">
196 <constructor-arg type="de.ids_mannheim.korap.config.KustvaktConfiguration"
197 ref="kustvakt_config" />
198 </bean> -->
199 <bean id="ldap_auth" class="de.ids_mannheim.korap.authentication.LdapAuth3">
margaretha62055f72017-04-11 19:17:43 +0200200 <constructor-arg type="de.ids_mannheim.korap.config.KustvaktConfiguration"
201 ref="kustvakt_config" />
202 </bean>
margaretha4de41192017-11-15 11:47:11 +0100203
margaretha62055f72017-04-11 19:17:43 +0200204 <bean id="openid_auth"
margaretha139d0f72017-11-14 18:56:22 +0100205 class="de.ids_mannheim.korap.authentication.OpenIDconnectAuthentication">
margaretha62055f72017-04-11 19:17:43 +0200206 <constructor-arg type="de.ids_mannheim.korap.config.KustvaktConfiguration"
207 ref="kustvakt_config" />
208 <constructor-arg
209 type="de.ids_mannheim.korap.interfaces.db.PersistenceClient" ref="kustvakt_db" />
210 </bean>
211
margaretha139d0f72017-11-14 18:56:22 +0100212 <bean id="basic_auth" class="de.ids_mannheim.korap.authentication.BasicHttpAuth" />
Michael Hanlbd852b82015-11-18 22:17:00 +0100213
214
margaretha62055f72017-04-11 19:17:43 +0200215 <bean id="session_auth"
margaretha139d0f72017-11-14 18:56:22 +0100216 class="de.ids_mannheim.korap.authentication.SessionAuthentication">
margaretha62055f72017-04-11 19:17:43 +0200217 <constructor-arg type="de.ids_mannheim.korap.config.KustvaktConfiguration"
218 ref="kustvakt_config" />
219 <constructor-arg type="de.ids_mannheim.korap.interfaces.EncryptionIface"
220 ref="kustvakt_encryption" />
221 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +0100222
margaretha62055f72017-04-11 19:17:43 +0200223 <util:list id="kustvakt_authproviders"
224 value-type="de.ids_mannheim.korap.interfaces.AuthenticationIface">
225 <ref bean="basic_auth" />
margaretha4de41192017-11-15 11:47:11 +0100226 <ref bean="ldap_auth" />
margaretha62055f72017-04-11 19:17:43 +0200227 <ref bean="session_auth" />
margaretha4de41192017-11-15 11:47:11 +0100228 <!-- <ref bean="api_auth" /> -->
margaretha62055f72017-04-11 19:17:43 +0200229 <ref bean="openid_auth" />
230 </util:list>
Michael Hanlbd852b82015-11-18 22:17:00 +0100231
margarethaade7d4a2017-07-20 19:53:35 +0200232
margaretha62055f72017-04-11 19:17:43 +0200233 <bean id="userdata_details" class="de.ids_mannheim.korap.handlers.UserDetailsDao">
margarethaade7d4a2017-07-20 19:53:35 +0200234 <constructor-arg ref="kustvakt_db" />
margaretha62055f72017-04-11 19:17:43 +0200235 </bean>
margarethaade7d4a2017-07-20 19:53:35 +0200236
margaretha62055f72017-04-11 19:17:43 +0200237 <bean id="userdata_settings" class="de.ids_mannheim.korap.handlers.UserSettingsDao">
margarethaade7d4a2017-07-20 19:53:35 +0200238 <constructor-arg ref="kustvakt_db" />
margaretha62055f72017-04-11 19:17:43 +0200239 </bean>
Michael Hanldaf86602016-05-12 14:31:52 +0200240
margaretha62055f72017-04-11 19:17:43 +0200241 <util:list id="kustvakt_userdata"
242 value-type="de.ids_mannheim.korap.interfaces.db.UserdataDbIface">
243 <ref bean="userdata_details" />
244 <ref bean="userdata_settings" />
245 </util:list>
Michael Hanldaf86602016-05-12 14:31:52 +0200246
margaretha62055f72017-04-11 19:17:43 +0200247 <util:list id="kustvakt_resources"
248 value-type="de.ids_mannheim.korap.interfaces.db.ResourceOperationIface">
249 <ref bean="document_provider" />
250 <ref bean="resource_provider" />
251 </util:list>
Michael Hanlf8fcc7a2016-06-03 17:41:07 +0200252
margaretha62055f72017-04-11 19:17:43 +0200253 <!-- specify type for constructor argument -->
254 <bean id="kustvakt_authenticationmanager"
margaretha139d0f72017-11-14 18:56:22 +0100255 class="de.ids_mannheim.korap.authentication.KustvaktAuthenticationManager">
margaretha62055f72017-04-11 19:17:43 +0200256 <constructor-arg
257 type="de.ids_mannheim.korap.interfaces.db.EntityHandlerIface" ref="kustvakt_userdb" />
258 <constructor-arg
259 type="de.ids_mannheim.korap.interfaces.db.AdminHandlerIface" ref="kustvakt_admindb" />
260 <constructor-arg type="de.ids_mannheim.korap.interfaces.EncryptionIface"
261 ref="kustvakt_encryption" />
262 <constructor-arg ref="kustvakt_config" />
263 <constructor-arg type="de.ids_mannheim.korap.interfaces.db.AuditingIface"
264 ref="kustvakt_auditing" />
265 <constructor-arg ref="kustvakt_userdata" />
266 <!-- inject authentication providers to use -->
267 <property name="providers" ref="kustvakt_authproviders" />
268 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +0100269
margaretha62055f72017-04-11 19:17:43 +0200270 <!-- todo: if db interfaces not loaded via spring, does transaction even
271 work then? -->
272 <!-- the transactional advice (i.e. what 'happens'; see the <aop:advisor/>
273 bean below) -->
274 <tx:advice id="txAdvice" transaction-manager="txManager">
275 <!-- the transactional semantics... -->
276 <tx:attributes>
277 <!-- all methods starting with 'get' are read-only -->
278 <tx:method name="get*" read-only="true" rollback-for="KorAPException" />
279 <!-- other methods use the default transaction settings (see below) -->
280 <tx:method name="*" rollback-for="KorAPException" />
281 </tx:attributes>
282 </tx:advice>
Michael Hanlbd852b82015-11-18 22:17:00 +0100283
margaretha62055f72017-04-11 19:17:43 +0200284 <!-- ensure that the above transactional advice runs for any execution of
285 an operation defined by the service interface -->
286 <aop:config>
287 <aop:pointcut id="service"
288 expression="execution(* de.ids_mannheim.korap.interfaces.db.*.*(..))" />
289 <aop:advisor advice-ref="txAdvice" pointcut-ref="service" />
290 </aop:config>
Michael Hanlbd852b82015-11-18 22:17:00 +0100291
margaretha62055f72017-04-11 19:17:43 +0200292 <!-- similarly, don't forget the PlatformTransactionManager -->
293 <bean id="txManager"
294 class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
295 <property name="dataSource" ref="dataSource" />
296 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +0100297</beans>