blob: 955d1977defd7dbb78b1457613e6e869c859c65a [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"
margaretha0e8f4e72018-04-05 14:11:52 +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"
5 xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context"
margaretha543f2002017-07-14 00:27:15 +02006 xmlns:cache="http://www.springframework.org/schema/cache"
7 xsi:schemaLocation="http://www.springframework.org/schema/beans
8 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">
17
18 <context:component-scan base-package="de.ids_mannheim.korap" />
19 <context:annotation-config />
20
margaretha0e8f4e72018-04-05 14:11:52 +020021 <!-- <bean id="test" class="de.ids_mannheim.korap.web.Test"> <property name="config"
22 ref="kustvakt_config" /> </bean> -->
margarethaade7d4a2017-07-20 19:53:35 +020023
margaretha543f2002017-07-14 00:27:15 +020024 <bean id="props"
25 class="org.springframework.beans.factory.config.PropertiesFactoryBean">
26 <property name="ignoreResourceNotFound" value="true" />
27 <property name="locations">
28 <array>
29 <value>classpath:kustvakt.conf</value>
30 <value>file:./kustvakt.conf</value>
31 </array>
32 </property>
33 </bean>
34
35 <bean id="placeholders"
36 class="org.springframework.context.support.PropertySourcesPlaceholderConfigurer">
37 <property name="ignoreResourceNotFound" value="true" />
38 <property name="locations">
39 <array>
margarethaaecee1b2018-02-20 14:44:21 +010040 <value>classpath:properties/jdbc.properties</value>
margarethaea68a0a2017-09-21 03:09:49 +020041 <value>file:./jdbc.properties</value>
margarethaaecee1b2018-02-20 14:44:21 +010042 <value>classpath:properties/mail.properties</value>
43 <value>file:./mail.properties</value>
44 <value>classpath:properties/hibernate.properties</value>
margaretha0e8f4e72018-04-05 14:11:52 +020045
margarethaade7d4a2017-07-20 19:53:35 +020046 <value>classpath:kustvakt.conf</value>
margaretha14503cd2017-09-08 15:35:24 +020047 <value>file:./kustvakt.conf</value>
margaretha543f2002017-07-14 00:27:15 +020048 </array>
49 </property>
50 </bean>
51
52 <bean id='cacheManager' class='org.springframework.cache.ehcache.EhCacheCacheManager'
53 p:cacheManager-ref='ehcache' />
54
55 <bean id='ehcache'
56 class='org.springframework.cache.ehcache.EhCacheManagerFactoryBean'
57 p:configLocation='classpath:ehcache.xml' p:shared='true' />
58
59 <!-- props are injected from default-config.xml -->
margaretha56e8e552017-12-05 16:31:21 +010060 <bean id="kustvakt_config" class="de.ids_mannheim.korap.config.FullConfiguration">
margarethaf68daa62017-09-21 02:11:24 +020061 <constructor-arg name="properties" ref="props" />
margaretha543f2002017-07-14 00:27:15 +020062 </bean>
63
64 <!--class="org.apache.commons.dbcp2.BasicDataSource" -->
65 <!-- org.springframework.jdbc.datasource.SingleConnectionDataSource -->
66 <bean id="dataSource" class="org.apache.commons.dbcp2.BasicDataSource"
67 lazy-init="true">
68 <property name="driverClassName" value="${jdbc.driverClassName}" />
69 <property name="url" value="${jdbc.url}" />
70 <property name="username" value="${jdbc.username}" />
71 <property name="password" value="${jdbc.password}" />
72 <!-- relevant for single connection datasource and sqlite -->
73 <!-- <property name="suppressClose"> <value>true</value> </property> -->
74 <!--<property name="initialSize" value="2"/> -->
75 <property name="maxTotal" value="4" />
76 <property name="maxIdle" value="2" />
77 <property name="minIdle" value="1" />
78 <property name="maxWaitMillis" value="15000" />
79 <!--<property name="poolPreparedStatements" value="true"/> -->
80 </bean>
81
82 <bean id="sqliteDataSource"
83 class="org.springframework.jdbc.datasource.SingleConnectionDataSource"
84 lazy-init="true">
85 <property name="driverClassName" value="${jdbc.driverClassName}" />
86 <property name="url" value="${jdbc.url}" />
87 <property name="username" value="${jdbc.username}" />
88 <property name="password" value="${jdbc.password}" />
margarethae6c711b2018-02-06 21:55:04 +010089 <property name="connectionProperties">
margaretha0e8f4e72018-04-05 14:11:52 +020090 <props>
91 <prop key="date_string_format">yyyy-MM-dd HH:mm:ss</prop>
92 </props>
93 </property>
94
margaretha543f2002017-07-14 00:27:15 +020095 <!-- relevant for single connection datasource and sqlite -->
96 <property name="suppressClose">
97 <value>true</value>
98 </property>
99 <!--<property name="initialSize" value="2"/> -->
100 <!--<property name="poolPreparedStatements" value="true"/> -->
101 </bean>
102
103 <!-- to configure database for sqlite, mysql, etc. migrations -->
104 <bean id="flyway" class="org.flywaydb.core.Flyway" init-method="migrate">
margarethaf6d5a822017-10-19 19:51:20 +0200105 <property name="baselineOnMigrate" value="true" />
margarethaecbe72d2017-07-26 17:13:32 +0200106 <!-- <property name="validateOnMigrate" value="false" /> -->
107 <!-- <property name="cleanOnValidationError" value="true" /> -->
margaretha543f2002017-07-14 00:27:15 +0200108 <property name="locations" value="${jdbc.schemaPath}" />
margaretha894a7d72017-11-08 19:24:20 +0100109 <!-- <property name="dataSource" ref="dataSource" /> -->
110 <property name="dataSource" ref="sqliteDataSource" />
margaretha543f2002017-07-14 00:27:15 +0200111 </bean>
margaretha0e8f4e72018-04-05 14:11:52 +0200112
113
margaretha543f2002017-07-14 00:27:15 +0200114 <bean id="kustvakt_db" class="de.ids_mannheim.korap.handlers.JDBCClient">
115 <constructor-arg index="0" ref="dataSource" />
116 <!-- deprecated property -->
117 <property name="database" value="${jdbc.database}" />
118 </bean>
119
120 <bean id="entityManagerFactory"
121 class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
margaretha894a7d72017-11-08 19:24:20 +0100122 <!-- <property name="dataSource" ref="dataSource" /> -->
123 <property name="dataSource" ref="sqliteDataSource" />
margaretha0e8f4e72018-04-05 14:11:52 +0200124
margarethaa452c5e2018-04-25 22:48:09 +0200125 <property name="packagesToScan">
126 <array>
127 <value>de.ids_mannheim.korap.entity</value>
128 <value>de.ids_mannheim.korap.oauth2.entity</value>
129 </array>
130 </property>
margaretha543f2002017-07-14 00:27:15 +0200131 <property name="jpaVendorAdapter">
132 <bean id="jpaVendorAdapter"
133 class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
134 <property name="databasePlatform" value="${hibernate.dialect}" />
135 </bean>
136 </property>
137 <property name="jpaProperties">
138 <props>
139 <prop key="hibernate.dialect">${hibernate.dialect}</prop>
140 <prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop>
141 <prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
142 <prop key="hibernate.cache.use_query_cache">${hibernate.cache.use_query_cache}</prop>
143 <prop key="hibernate.cache.use_second_level_cache">${hibernate.cache.use_second_level_cache}
144 </prop>
145 <prop key="hibernate.cache.provider_class">${hibernate.cache.provider}</prop>
146 <prop key="hibernate.cache.region.factory_class">${hibernate.cache.region.factory}</prop>
147 <!-- <prop key="net.sf.ehcache.configurationResourceName">classpath:ehcache.xml</prop> -->
148 </props>
149 </property>
150 </bean>
151
152 <tx:annotation-driven proxy-target-class="true"
153 transaction-manager="transactionManager" />
margaretha0e8f4e72018-04-05 14:11:52 +0200154
margaretha543f2002017-07-14 00:27:15 +0200155 <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
156 <property name="entityManagerFactory" ref="entityManagerFactory" />
157 </bean>
158
159 <bean id="transactionTemplate"
160 class="org.springframework.transaction.support.TransactionTemplate">
161 <constructor-arg ref="transactionManager" />
162 </bean>
163
margarethaade7d4a2017-07-20 19:53:35 +0200164 <!-- Data access objects -->
margaretha0e8f4e72018-04-05 14:11:52 +0200165 <bean id="resourceDao" class="de.ids_mannheim.korap.dao.ResourceDao" />
margarethaade7d4a2017-07-20 19:53:35 +0200166 <!-- <bean id="annotationDao" class="de.ids_mannheim.korap.dao.AnnotationDao"/> -->
167
168 <!-- Krill -->
169 <bean id="search_krill" class="de.ids_mannheim.korap.web.SearchKrill">
margaretha0e8f4e72018-04-05 14:11:52 +0200170 <constructor-arg value="${krill.indexDir}" />
margaretha543f2002017-07-14 00:27:15 +0200171 </bean>
172
margaretha31a9f522018-04-03 20:40:45 +0200173 <!-- URLValidator -->
174 <bean id="urlValidator" class="org.apache.commons.validator.routines.UrlValidator">
margaretha0e8f4e72018-04-05 14:11:52 +0200175 <constructor-arg value="http,https" />
margaretha31a9f522018-04-03 20:40:45 +0200176 </bean>
margarethaa0486272018-04-12 19:59:31 +0200177 <bean id="httpsValidator" class="org.apache.commons.validator.routines.UrlValidator">
margarethaa452c5e2018-04-25 22:48:09 +0200178 <constructor-arg value="https" />
margarethaa0486272018-04-12 19:59:31 +0200179 </bean>
margaretha0e8f4e72018-04-05 14:11:52 +0200180
margaretha56e8e552017-12-05 16:31:21 +0100181 <bean id="kustvakt_rewrite" class="de.ids_mannheim.korap.rewrite.FullRewriteHandler">
182 <constructor-arg ref="kustvakt_config" />
183 </bean>
184
margaretha543f2002017-07-14 00:27:15 +0200185 <bean id="kustvakt_auditing" class="de.ids_mannheim.korap.handlers.JDBCAuditing">
186 <constructor-arg ref="kustvakt_db" />
187 </bean>
188
margaretha05122312018-04-16 15:01:34 +0200189 <bean id="kustvaktResponseHandler" class="de.ids_mannheim.korap.web.KustvaktExceptionHandler">
margaretha0e8f4e72018-04-05 14:11:52 +0200190 <constructor-arg index="0" name="iface" ref="kustvakt_auditing" />
191 </bean>
margarethaa452c5e2018-04-25 22:48:09 +0200192
margarethafb027f92018-04-23 20:00:13 +0200193 <!-- OAuth -->
194 <bean id="oauth2ResponseHandler" class="de.ids_mannheim.korap.web.OAuth2ResponseHandler">
margaretha05122312018-04-16 15:01:34 +0200195 <constructor-arg index="0" name="iface" ref="kustvakt_auditing" />
196 </bean>
margarethaa452c5e2018-04-25 22:48:09 +0200197
margarethafb027f92018-04-23 20:00:13 +0200198 <bean id="mdGenerator" class="org.apache.oltu.oauth2.as.issuer.MD5Generator">
199 </bean>
200 <bean id="oauthIssuer" class="org.apache.oltu.oauth2.as.issuer.OAuthIssuerImpl">
201 <constructor-arg index="0" ref="mdGenerator" />
202 </bean>
margaretha0e8f4e72018-04-05 14:11:52 +0200203
margaretha543f2002017-07-14 00:27:15 +0200204 <bean id="kustvakt_userdb" class="de.ids_mannheim.korap.handlers.EntityDao">
205 <constructor-arg ref="kustvakt_db" />
206 </bean>
207
margaretha543f2002017-07-14 00:27:15 +0200208 <bean id="resource_provider" class="de.ids_mannheim.korap.handlers.ResourceDao">
209 <constructor-arg ref="kustvakt_db" />
210 </bean>
211
212 <bean id="document_provider" class="de.ids_mannheim.korap.handlers.DocumentDao">
213 <constructor-arg ref="kustvakt_db" />
214 </bean>
215
margarethaa452c5e2018-04-25 22:48:09 +0200216 <bean name="kustvakt_encryption" class="de.ids_mannheim.korap.encryption.KustvaktEncryption">
margaretha543f2002017-07-14 00:27:15 +0200217 <constructor-arg ref="kustvakt_config" />
218 </bean>
219
220 <!-- authentication providers to use -->
margaretha0e8f4e72018-04-05 14:11:52 +0200221 <!-- <bean id="api_auth" class="de.ids_mannheim.korap.authentication.APIAuthentication">
222 <constructor-arg type="de.ids_mannheim.korap.config.KustvaktConfiguration"
223 ref="kustvakt_config" /> </bean> -->
224
margaretha4de41192017-11-15 11:47:11 +0100225 <bean id="ldap_auth" class="de.ids_mannheim.korap.authentication.LdapAuth3">
margaretha543f2002017-07-14 00:27:15 +0200226 <constructor-arg type="de.ids_mannheim.korap.config.KustvaktConfiguration"
227 ref="kustvakt_config" />
228 </bean>
229
230 <bean id="openid_auth"
margaretha139d0f72017-11-14 18:56:22 +0100231 class="de.ids_mannheim.korap.authentication.OpenIDconnectAuthentication">
margaretha543f2002017-07-14 00:27:15 +0200232 <constructor-arg type="de.ids_mannheim.korap.config.KustvaktConfiguration"
233 ref="kustvakt_config" />
234 <constructor-arg
235 type="de.ids_mannheim.korap.interfaces.db.PersistenceClient" ref="kustvakt_db" />
236 </bean>
237
margaretha543f2002017-07-14 00:27:15 +0200238 <bean id="session_auth"
margaretha139d0f72017-11-14 18:56:22 +0100239 class="de.ids_mannheim.korap.authentication.SessionAuthentication">
margaretha543f2002017-07-14 00:27:15 +0200240 <constructor-arg type="de.ids_mannheim.korap.config.KustvaktConfiguration"
241 ref="kustvakt_config" />
242 <constructor-arg type="de.ids_mannheim.korap.interfaces.EncryptionIface"
243 ref="kustvakt_encryption" />
244 </bean>
Michael Hanlca740d72015-06-16 10:04:58 +0200245
margaretha543f2002017-07-14 00:27:15 +0200246 <util:list id="kustvakt_authproviders"
247 value-type="de.ids_mannheim.korap.interfaces.AuthenticationIface">
margaretha4de41192017-11-15 11:47:11 +0100248 <ref bean="ldap_auth" />
margaretha543f2002017-07-14 00:27:15 +0200249 <ref bean="session_auth" />
margaretha4de41192017-11-15 11:47:11 +0100250 <!-- <ref bean="api_auth" /> -->
margaretha543f2002017-07-14 00:27:15 +0200251 <ref bean="openid_auth" />
margaretha0e8f4e72018-04-05 14:11:52 +0200252 <ref bean="client_auth" />
margaretha543f2002017-07-14 00:27:15 +0200253 </util:list>
Michael Hanl72c7b832015-09-03 08:42:15 +0200254
255
margaretha543f2002017-07-14 00:27:15 +0200256 <bean id="userdata_details" class="de.ids_mannheim.korap.handlers.UserDetailsDao">
257 <constructor-arg ref="kustvakt_db" />
258 </bean>
Michael Hanl72c7b832015-09-03 08:42:15 +0200259
margaretha543f2002017-07-14 00:27:15 +0200260 <bean id="userdata_settings" class="de.ids_mannheim.korap.handlers.UserSettingsDao">
261 <constructor-arg ref="kustvakt_db" />
262 </bean>
263
264 <util:list id="kustvakt_userdata"
265 value-type="de.ids_mannheim.korap.interfaces.db.UserdataDbIface">
266 <ref bean="userdata_details" />
267 <ref bean="userdata_settings" />
268 </util:list>
Michael Hanl72c7b832015-09-03 08:42:15 +0200269
Michael Hanldaf86602016-05-12 14:31:52 +0200270
margaretha543f2002017-07-14 00:27:15 +0200271 <util:list id="kustvakt_resources"
272 value-type="de.ids_mannheim.korap.interfaces.db.ResourceOperationIface">
273 <ref bean="document_provider" />
274 <ref bean="resource_provider" />
275 </util:list>
Michael Hanlf8fcc7a2016-06-03 17:41:07 +0200276
margaretha543f2002017-07-14 00:27:15 +0200277 <!-- specify type for constructor argument -->
278 <bean id="kustvakt_authenticationmanager"
margaretha139d0f72017-11-14 18:56:22 +0100279 class="de.ids_mannheim.korap.authentication.KustvaktAuthenticationManager">
margaretha0e8f4e72018-04-05 14:11:52 +0200280 <constructor-arg type="de.ids_mannheim.korap.interfaces.EntityHandlerIface"
281 ref="kustvakt_userdb" />
margaretha543f2002017-07-14 00:27:15 +0200282 <constructor-arg type="de.ids_mannheim.korap.interfaces.EncryptionIface"
283 ref="kustvakt_encryption" />
284 <constructor-arg ref="kustvakt_config" />
285 <constructor-arg type="de.ids_mannheim.korap.interfaces.db.AuditingIface"
286 ref="kustvakt_auditing" />
287 <constructor-arg ref="kustvakt_userdata" />
288 <!-- inject authentication providers to use -->
289 <property name="providers" ref="kustvakt_authproviders" />
290 </bean>
Michael Hanldaf86602016-05-12 14:31:52 +0200291
margaretha543f2002017-07-14 00:27:15 +0200292 <!-- todo: if db interfaces not loaded via spring, does transaction even
293 work then? -->
294 <!-- the transactional advice (i.e. what 'happens'; see the <aop:advisor/>
295 bean below) -->
296 <tx:advice id="txAdvice" transaction-manager="txManager">
297 <!-- the transactional semantics... -->
298 <tx:attributes>
299 <!-- all methods starting with 'get' are read-only -->
300 <tx:method name="get*" read-only="true" rollback-for="KorAPException" />
301 <!-- other methods use the default transaction settings (see below) -->
302 <tx:method name="*" rollback-for="KorAPException" />
303 </tx:attributes>
304 </tx:advice>
Michael Hanldaf86602016-05-12 14:31:52 +0200305
margaretha543f2002017-07-14 00:27:15 +0200306 <!-- ensure that the above transactional advice runs for any execution of
307 an operation defined by the service interface -->
308 <aop:config>
309 <aop:pointcut id="service"
310 expression="execution(* de.ids_mannheim.korap.interfaces.db.*.*(..))" />
311 <aop:advisor advice-ref="txAdvice" pointcut-ref="service" />
312 </aop:config>
Michael Hanlf8fcc7a2016-06-03 17:41:07 +0200313
margaretha543f2002017-07-14 00:27:15 +0200314 <!-- similarly, don't forget the PlatformTransactionManager -->
315 <bean id="txManager"
316 class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
margaretha894a7d72017-11-08 19:24:20 +0100317 <!-- <property name="dataSource" ref="dataSource" /> -->
318 <property name="dataSource" ref="sqliteDataSource" />
margaretha543f2002017-07-14 00:27:15 +0200319 </bean>
margaretha0e8f4e72018-04-05 14:11:52 +0200320
margarethac9f1dfa2018-02-07 17:50:33 +0100321 <!-- mail -->
margaretha0e8f4e72018-04-05 14:11:52 +0200322 <bean id="authenticator" class="de.ids_mannheim.korap.service.MailAuthenticator">
323 <constructor-arg index="0" value="${mail.username}" />
324 <constructor-arg index="1" value="${mail.password}" />
margarethaaecee1b2018-02-20 14:44:21 +0100325 </bean>
326 <bean id="smtpSession" class="javax.mail.Session" factory-method="getInstance">
327 <constructor-arg index="0">
328 <props>
329 <prop key="mail.smtp.submitter">${mail.username}</prop>
330 <prop key="mail.smtp.auth">${mail.auth}</prop>
331 <prop key="mail.smtp.host">${mail.host}</prop>
332 <prop key="mail.smtp.port">${mail.port}</prop>
333 <prop key="mail.smtp.starttls.enable">${mail.starttls.enable}</prop>
334 <prop key="mail.smtp.connectiontimeout">${mail.connectiontimeout}</prop>
335 </props>
336 </constructor-arg>
margaretha0e8f4e72018-04-05 14:11:52 +0200337 <constructor-arg index="1" ref="authenticator" />
margarethac9f1dfa2018-02-07 17:50:33 +0100338 </bean>
339 <bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
margarethaaecee1b2018-02-20 14:44:21 +0100340 <property name="username" value="${mail.username}" />
margaretha0e8f4e72018-04-05 14:11:52 +0200341 <property name="password" value="${mail.password}" />
margarethac9f1dfa2018-02-07 17:50:33 +0100342 <property name="session" ref="smtpSession" />
343 </bean>
344 <bean id="velocityEngine" class="org.apache.velocity.app.VelocityEngine">
345 <constructor-arg index="0">
346 <props>
347 <prop key="resource.loader">class</prop>
margaretha0e8f4e72018-04-05 14:11:52 +0200348 <prop key="class.resource.loader.class">org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
349 </prop>
margarethac9f1dfa2018-02-07 17:50:33 +0100350 </props>
351 </constructor-arg>
margarethaaecee1b2018-02-20 14:44:21 +0100352 </bean>
Michael Hanlca740d72015-06-16 10:04:58 +0200353</beans>