blob: 5d3f9e959129e557cc24be9e623b7ff980640173 [file] [log] [blame]
Michael Hanlca740d72015-06-16 10:04:58 +02001<?xml version="1.0" encoding="UTF-8"?>
2<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
margaretha14503cd2017-09-08 15:35:24 +02003 xmlns:p="http://www.springframework.org/schema/p"
4 xmlns:util="http://www.springframework.org/schema/util"
5 xmlns:aop="http://www.springframework.org/schema/aop"
6 xmlns:tx="http://www.springframework.org/schema/tx"
7 xmlns="http://www.springframework.org/schema/beans"
8 xmlns:context="http://www.springframework.org/schema/context"
margaretha543f2002017-07-14 00:27:15 +02009 xmlns:cache="http://www.springframework.org/schema/cache"
10 xsi:schemaLocation="http://www.springframework.org/schema/beans
11 http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
12 http://www.springframework.org/schema/tx
13 http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
14 http://www.springframework.org/schema/aop
15 http://www.springframework.org/schema/aop/spring-aop-4.0.xsd
16 http://www.springframework.org/schema/context
17 http://www.springframework.org/schema/context/spring-context-4.0.xsd
18 http://www.springframework.org/schema/util
19 http://www.springframework.org/schema/util/spring-util-4.0.xsd">
20
21 <context:component-scan base-package="de.ids_mannheim.korap" />
22 <context:annotation-config />
23
margarethaade7d4a2017-07-20 19:53:35 +020024 <!-- <bean id="test" class="de.ids_mannheim.korap.web.Test">
25 <property name="config" ref="kustvakt_config" />
26 </bean> -->
27
margaretha543f2002017-07-14 00:27:15 +020028 <bean id="props"
29 class="org.springframework.beans.factory.config.PropertiesFactoryBean">
30 <property name="ignoreResourceNotFound" value="true" />
31 <property name="locations">
32 <array>
33 <value>classpath:kustvakt.conf</value>
34 <value>file:./kustvakt.conf</value>
35 </array>
36 </property>
37 </bean>
38
39 <bean id="placeholders"
40 class="org.springframework.context.support.PropertySourcesPlaceholderConfigurer">
41 <property name="ignoreResourceNotFound" value="true" />
42 <property name="locations">
43 <array>
margarethaaecee1b2018-02-20 14:44:21 +010044 <value>classpath:properties/jdbc.properties</value>
margarethaea68a0a2017-09-21 03:09:49 +020045 <value>file:./jdbc.properties</value>
margarethaaecee1b2018-02-20 14:44:21 +010046 <value>classpath:properties/mail.properties</value>
47 <value>file:./mail.properties</value>
48 <value>classpath:properties/hibernate.properties</value>
49
margarethaade7d4a2017-07-20 19:53:35 +020050 <value>classpath:kustvakt.conf</value>
margaretha14503cd2017-09-08 15:35:24 +020051 <value>file:./kustvakt.conf</value>
margaretha543f2002017-07-14 00:27:15 +020052 </array>
53 </property>
54 </bean>
55
56 <bean id='cacheManager' class='org.springframework.cache.ehcache.EhCacheCacheManager'
57 p:cacheManager-ref='ehcache' />
58
59 <bean id='ehcache'
60 class='org.springframework.cache.ehcache.EhCacheManagerFactoryBean'
61 p:configLocation='classpath:ehcache.xml' p:shared='true' />
62
63 <!-- props are injected from default-config.xml -->
margaretha56e8e552017-12-05 16:31:21 +010064 <bean id="kustvakt_config" class="de.ids_mannheim.korap.config.FullConfiguration">
margarethaf68daa62017-09-21 02:11:24 +020065 <constructor-arg name="properties" ref="props" />
margaretha543f2002017-07-14 00:27:15 +020066 </bean>
67
68 <!--class="org.apache.commons.dbcp2.BasicDataSource" -->
69 <!-- org.springframework.jdbc.datasource.SingleConnectionDataSource -->
70 <bean id="dataSource" class="org.apache.commons.dbcp2.BasicDataSource"
71 lazy-init="true">
72 <property name="driverClassName" value="${jdbc.driverClassName}" />
73 <property name="url" value="${jdbc.url}" />
74 <property name="username" value="${jdbc.username}" />
75 <property name="password" value="${jdbc.password}" />
76 <!-- relevant for single connection datasource and sqlite -->
77 <!-- <property name="suppressClose"> <value>true</value> </property> -->
78 <!--<property name="initialSize" value="2"/> -->
79 <property name="maxTotal" value="4" />
80 <property name="maxIdle" value="2" />
81 <property name="minIdle" value="1" />
82 <property name="maxWaitMillis" value="15000" />
83 <!--<property name="poolPreparedStatements" value="true"/> -->
84 </bean>
85
86 <bean id="sqliteDataSource"
87 class="org.springframework.jdbc.datasource.SingleConnectionDataSource"
88 lazy-init="true">
89 <property name="driverClassName" value="${jdbc.driverClassName}" />
90 <property name="url" value="${jdbc.url}" />
91 <property name="username" value="${jdbc.username}" />
92 <property name="password" value="${jdbc.password}" />
margarethae6c711b2018-02-06 21:55:04 +010093 <property name="connectionProperties">
94 <props>
95 <prop key="date_string_format">yyyy-MM-dd HH:mm:ss</prop>
96 </props>
97 </property>
98
margaretha543f2002017-07-14 00:27:15 +020099 <!-- relevant for single connection datasource and sqlite -->
100 <property name="suppressClose">
101 <value>true</value>
102 </property>
103 <!--<property name="initialSize" value="2"/> -->
104 <!--<property name="poolPreparedStatements" value="true"/> -->
105 </bean>
106
107 <!-- to configure database for sqlite, mysql, etc. migrations -->
108 <bean id="flyway" class="org.flywaydb.core.Flyway" init-method="migrate">
margarethaf6d5a822017-10-19 19:51:20 +0200109 <property name="baselineOnMigrate" value="true" />
margarethaecbe72d2017-07-26 17:13:32 +0200110 <!-- <property name="validateOnMigrate" value="false" /> -->
111 <!-- <property name="cleanOnValidationError" value="true" /> -->
margaretha543f2002017-07-14 00:27:15 +0200112 <property name="locations" value="${jdbc.schemaPath}" />
margaretha894a7d72017-11-08 19:24:20 +0100113 <!-- <property name="dataSource" ref="dataSource" /> -->
114 <property name="dataSource" ref="sqliteDataSource" />
margaretha543f2002017-07-14 00:27:15 +0200115 </bean>
margarethaf18298b2017-09-14 22:14:32 +0200116
117
margaretha543f2002017-07-14 00:27:15 +0200118 <bean id="kustvakt_db" class="de.ids_mannheim.korap.handlers.JDBCClient">
119 <constructor-arg index="0" ref="dataSource" />
120 <!-- deprecated property -->
121 <property name="database" value="${jdbc.database}" />
122 </bean>
123
124 <bean id="entityManagerFactory"
125 class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
margaretha894a7d72017-11-08 19:24:20 +0100126 <!-- <property name="dataSource" ref="dataSource" /> -->
127 <property name="dataSource" ref="sqliteDataSource" />
128
margaretha543f2002017-07-14 00:27:15 +0200129 <property name="packagesToScan" value="de.ids_mannheim.korap.entity" />
130 <property name="jpaVendorAdapter">
131 <bean id="jpaVendorAdapter"
132 class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
133 <property name="databasePlatform" value="${hibernate.dialect}" />
134 </bean>
135 </property>
136 <property name="jpaProperties">
137 <props>
138 <prop key="hibernate.dialect">${hibernate.dialect}</prop>
139 <prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop>
140 <prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
141 <prop key="hibernate.cache.use_query_cache">${hibernate.cache.use_query_cache}</prop>
142 <prop key="hibernate.cache.use_second_level_cache">${hibernate.cache.use_second_level_cache}
143 </prop>
144 <prop key="hibernate.cache.provider_class">${hibernate.cache.provider}</prop>
145 <prop key="hibernate.cache.region.factory_class">${hibernate.cache.region.factory}</prop>
146 <!-- <prop key="net.sf.ehcache.configurationResourceName">classpath:ehcache.xml</prop> -->
147 </props>
148 </property>
149 </bean>
150
151 <tx:annotation-driven proxy-target-class="true"
152 transaction-manager="transactionManager" />
margaretha894a7d72017-11-08 19:24:20 +0100153
margaretha543f2002017-07-14 00:27:15 +0200154 <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
155 <property name="entityManagerFactory" ref="entityManagerFactory" />
156 </bean>
157
158 <bean id="transactionTemplate"
159 class="org.springframework.transaction.support.TransactionTemplate">
160 <constructor-arg ref="transactionManager" />
161 </bean>
162
margarethaade7d4a2017-07-20 19:53:35 +0200163 <!-- Data access objects -->
164 <bean id="resourceDao" class="de.ids_mannheim.korap.dao.ResourceDao"/>
165 <!-- <bean id="annotationDao" class="de.ids_mannheim.korap.dao.AnnotationDao"/> -->
166
167 <!-- Krill -->
168 <bean id="search_krill" class="de.ids_mannheim.korap.web.SearchKrill">
169 <constructor-arg value="${krill.indexDir}"/>
margaretha543f2002017-07-14 00:27:15 +0200170 </bean>
171
margaretha56e8e552017-12-05 16:31:21 +0100172
173 <bean id="kustvakt_rewrite" class="de.ids_mannheim.korap.rewrite.FullRewriteHandler">
174 <constructor-arg ref="kustvakt_config" />
175 </bean>
176
margaretha543f2002017-07-14 00:27:15 +0200177 <bean id="kustvakt_auditing" class="de.ids_mannheim.korap.handlers.JDBCAuditing">
178 <constructor-arg ref="kustvakt_db" />
179 </bean>
180
margaretha894a7d72017-11-08 19:24:20 +0100181 <bean id="kustvakt_response"
margaretha56e8e552017-12-05 16:31:21 +0100182 class="de.ids_mannheim.korap.web.FullResponseHandler">
margaretha894a7d72017-11-08 19:24:20 +0100183 <constructor-arg index="0" name="iface" ref="kustvakt_auditing"/>
184 </bean>
185
margaretha543f2002017-07-14 00:27:15 +0200186 <bean id="kustvakt_userdb" class="de.ids_mannheim.korap.handlers.EntityDao">
187 <constructor-arg ref="kustvakt_db" />
188 </bean>
189
190 <bean id="kustvakt_admindb" class="de.ids_mannheim.korap.handlers.AdminDao">
191 <constructor-arg ref="kustvakt_db" />
192 </bean>
193
194 <bean id="resource_provider" class="de.ids_mannheim.korap.handlers.ResourceDao">
195 <constructor-arg ref="kustvakt_db" />
196 </bean>
197
198 <bean id="document_provider" class="de.ids_mannheim.korap.handlers.DocumentDao">
199 <constructor-arg ref="kustvakt_db" />
200 </bean>
201
202 <bean id="kustvakt_policies" class="de.ids_mannheim.korap.security.ac.PolicyDao">
203 <constructor-arg ref="kustvakt_db" />
204 </bean>
205
206 <bean name="kustvakt_encryption"
207 class="de.ids_mannheim.korap.interfaces.defaults.KustvaktEncryption">
208 <constructor-arg ref="kustvakt_config" />
209 </bean>
210
211 <!-- authentication providers to use -->
margaretha4de41192017-11-15 11:47:11 +0100212 <!-- <bean id="api_auth" class="de.ids_mannheim.korap.authentication.APIAuthentication">
213 <constructor-arg type="de.ids_mannheim.korap.config.KustvaktConfiguration"
214 ref="kustvakt_config" />
215 </bean> -->
216
217 <bean id="ldap_auth" class="de.ids_mannheim.korap.authentication.LdapAuth3">
margaretha543f2002017-07-14 00:27:15 +0200218 <constructor-arg type="de.ids_mannheim.korap.config.KustvaktConfiguration"
219 ref="kustvakt_config" />
220 </bean>
221
222 <bean id="openid_auth"
margaretha139d0f72017-11-14 18:56:22 +0100223 class="de.ids_mannheim.korap.authentication.OpenIDconnectAuthentication">
margaretha543f2002017-07-14 00:27:15 +0200224 <constructor-arg type="de.ids_mannheim.korap.config.KustvaktConfiguration"
225 ref="kustvakt_config" />
226 <constructor-arg
227 type="de.ids_mannheim.korap.interfaces.db.PersistenceClient" ref="kustvakt_db" />
228 </bean>
229
margaretha4b5c1412017-11-15 20:55:04 +0100230 <bean id="basic_auth" class="de.ids_mannheim.korap.authentication.BasicAuthentication" />
Michael Hanle4fc7752016-02-17 11:41:18 +0100231
232
margaretha543f2002017-07-14 00:27:15 +0200233 <bean id="session_auth"
margaretha139d0f72017-11-14 18:56:22 +0100234 class="de.ids_mannheim.korap.authentication.SessionAuthentication">
margaretha543f2002017-07-14 00:27:15 +0200235 <constructor-arg type="de.ids_mannheim.korap.config.KustvaktConfiguration"
236 ref="kustvakt_config" />
237 <constructor-arg type="de.ids_mannheim.korap.interfaces.EncryptionIface"
238 ref="kustvakt_encryption" />
239 </bean>
Michael Hanlca740d72015-06-16 10:04:58 +0200240
margaretha543f2002017-07-14 00:27:15 +0200241 <util:list id="kustvakt_authproviders"
242 value-type="de.ids_mannheim.korap.interfaces.AuthenticationIface">
243 <ref bean="basic_auth" />
margaretha4de41192017-11-15 11:47:11 +0100244 <ref bean="ldap_auth" />
margaretha543f2002017-07-14 00:27:15 +0200245 <ref bean="session_auth" />
margaretha4de41192017-11-15 11:47:11 +0100246 <!-- <ref bean="api_auth" /> -->
margaretha543f2002017-07-14 00:27:15 +0200247 <ref bean="openid_auth" />
248 </util:list>
Michael Hanl72c7b832015-09-03 08:42:15 +0200249
250
margaretha543f2002017-07-14 00:27:15 +0200251 <bean id="userdata_details" class="de.ids_mannheim.korap.handlers.UserDetailsDao">
252 <constructor-arg ref="kustvakt_db" />
253 </bean>
Michael Hanl72c7b832015-09-03 08:42:15 +0200254
margaretha543f2002017-07-14 00:27:15 +0200255 <bean id="userdata_settings" class="de.ids_mannheim.korap.handlers.UserSettingsDao">
256 <constructor-arg ref="kustvakt_db" />
257 </bean>
258
259 <util:list id="kustvakt_userdata"
260 value-type="de.ids_mannheim.korap.interfaces.db.UserdataDbIface">
261 <ref bean="userdata_details" />
262 <ref bean="userdata_settings" />
263 </util:list>
Michael Hanl72c7b832015-09-03 08:42:15 +0200264
Michael Hanldaf86602016-05-12 14:31:52 +0200265
margaretha543f2002017-07-14 00:27:15 +0200266 <util:list id="kustvakt_resources"
267 value-type="de.ids_mannheim.korap.interfaces.db.ResourceOperationIface">
268 <ref bean="document_provider" />
269 <ref bean="resource_provider" />
270 </util:list>
Michael Hanlf8fcc7a2016-06-03 17:41:07 +0200271
margaretha543f2002017-07-14 00:27:15 +0200272 <!-- specify type for constructor argument -->
273 <bean id="kustvakt_authenticationmanager"
margaretha139d0f72017-11-14 18:56:22 +0100274 class="de.ids_mannheim.korap.authentication.KustvaktAuthenticationManager">
margaretha543f2002017-07-14 00:27:15 +0200275 <constructor-arg
276 type="de.ids_mannheim.korap.interfaces.db.EntityHandlerIface" ref="kustvakt_userdb" />
277 <constructor-arg
278 type="de.ids_mannheim.korap.interfaces.db.AdminHandlerIface" ref="kustvakt_admindb" />
279 <constructor-arg type="de.ids_mannheim.korap.interfaces.EncryptionIface"
280 ref="kustvakt_encryption" />
281 <constructor-arg ref="kustvakt_config" />
282 <constructor-arg type="de.ids_mannheim.korap.interfaces.db.AuditingIface"
283 ref="kustvakt_auditing" />
284 <constructor-arg ref="kustvakt_userdata" />
285 <!-- inject authentication providers to use -->
286 <property name="providers" ref="kustvakt_authproviders" />
287 </bean>
Michael Hanldaf86602016-05-12 14:31:52 +0200288
margaretha543f2002017-07-14 00:27:15 +0200289 <!-- todo: if db interfaces not loaded via spring, does transaction even
290 work then? -->
291 <!-- the transactional advice (i.e. what 'happens'; see the <aop:advisor/>
292 bean below) -->
293 <tx:advice id="txAdvice" transaction-manager="txManager">
294 <!-- the transactional semantics... -->
295 <tx:attributes>
296 <!-- all methods starting with 'get' are read-only -->
297 <tx:method name="get*" read-only="true" rollback-for="KorAPException" />
298 <!-- other methods use the default transaction settings (see below) -->
299 <tx:method name="*" rollback-for="KorAPException" />
300 </tx:attributes>
301 </tx:advice>
Michael Hanldaf86602016-05-12 14:31:52 +0200302
margaretha543f2002017-07-14 00:27:15 +0200303 <!-- ensure that the above transactional advice runs for any execution of
304 an operation defined by the service interface -->
305 <aop:config>
306 <aop:pointcut id="service"
307 expression="execution(* de.ids_mannheim.korap.interfaces.db.*.*(..))" />
308 <aop:advisor advice-ref="txAdvice" pointcut-ref="service" />
309 </aop:config>
Michael Hanlf8fcc7a2016-06-03 17:41:07 +0200310
margaretha543f2002017-07-14 00:27:15 +0200311 <!-- similarly, don't forget the PlatformTransactionManager -->
312 <bean id="txManager"
313 class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
margaretha894a7d72017-11-08 19:24:20 +0100314 <!-- <property name="dataSource" ref="dataSource" /> -->
315 <property name="dataSource" ref="sqliteDataSource" />
margaretha543f2002017-07-14 00:27:15 +0200316 </bean>
margarethaf68daa62017-09-21 02:11:24 +0200317
margarethac9f1dfa2018-02-07 17:50:33 +0100318 <!-- mail -->
margarethaaecee1b2018-02-20 14:44:21 +0100319 <bean id="authenticator" class="de.ids_mannheim.korap.service.MailAuthenticator">
320 <constructor-arg index="0" value="${mail.username}"/>
321 <constructor-arg index="1" value="${mail.password}"/>
322 </bean>
323 <bean id="smtpSession" class="javax.mail.Session" factory-method="getInstance">
324 <constructor-arg index="0">
325 <props>
326 <prop key="mail.smtp.submitter">${mail.username}</prop>
327 <prop key="mail.smtp.auth">${mail.auth}</prop>
328 <prop key="mail.smtp.host">${mail.host}</prop>
329 <prop key="mail.smtp.port">${mail.port}</prop>
330 <prop key="mail.smtp.starttls.enable">${mail.starttls.enable}</prop>
331 <prop key="mail.smtp.connectiontimeout">${mail.connectiontimeout}</prop>
332 </props>
333 </constructor-arg>
334 <constructor-arg index="1" ref="authenticator"/>
margarethac9f1dfa2018-02-07 17:50:33 +0100335 </bean>
336 <bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
margarethaaecee1b2018-02-20 14:44:21 +0100337 <property name="username" value="${mail.username}" />
338 <property name="password" value="${mail.password}" />
margarethac9f1dfa2018-02-07 17:50:33 +0100339 <property name="session" ref="smtpSession" />
340 </bean>
341 <bean id="velocityEngine" class="org.apache.velocity.app.VelocityEngine">
342 <constructor-arg index="0">
343 <props>
344 <prop key="resource.loader">class</prop>
margarethaaecee1b2018-02-20 14:44:21 +0100345 <prop key="class.resource.loader.class">org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader</prop>
margarethac9f1dfa2018-02-07 17:50:33 +0100346 </props>
347 </constructor-arg>
margarethaaecee1b2018-02-20 14:44:21 +0100348 </bean>
Michael Hanlca740d72015-06-16 10:04:58 +0200349</beans>