blob: d8825328fcbf118ecb28d4824ca92be00e7cbdde [file] [log] [blame]
margarethaceae6972022-05-31 10:57:11 +02001<?xml version="1.0" encoding="UTF-8"?>
2<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
margaretha35e1ca22023-11-16 22:00:01 +01003 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"
margarethaceae6972022-05-31 10:57:11 +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
margaretha35e1ca22023-11-16 22:00:01 +010021 <context:component-scan
22 base-package="de.ids_mannheim.korap" />
margarethaceae6972022-05-31 10:57:11 +020023 <context:annotation-config />
24
25 <bean id="props"
26 class="org.springframework.beans.factory.config.PropertiesFactoryBean">
27 <property name="ignoreResourceNotFound" value="true" />
28 <property name="locations">
29 <array>
30 <value>classpath:kustvakt.conf</value>
31 <value>file:./kustvakt.conf</value>
32 </array>
33 </property>
34 </bean>
35
36 <bean id="placeholders"
37 class="org.springframework.context.support.PropertySourcesPlaceholderConfigurer">
38 <property name="ignoreResourceNotFound" value="true" />
39 <property name="locations">
40 <array>
41 <value>classpath:properties/basic-jdbc.properties</value>
42 <value>file:./basic-jdbc.properties</value>
43 <value>classpath:properties/mail.properties</value>
44 <value>file:./mail.properties</value>
margarethacc7feb62023-05-09 08:57:46 +020045 <value>classpath:properties/hibernate.properties</value>
margarethaceae6972022-05-31 10:57:11 +020046
47 <value>classpath:kustvakt.conf</value>
48 <value>file:./kustvakt.conf</value>
49 </array>
50 </property>
51 </bean>
52
margaretha35e1ca22023-11-16 22:00:01 +010053 <bean id='cacheManager'
54 class='org.springframework.cache.ehcache.EhCacheCacheManager'
margarethaceae6972022-05-31 10:57:11 +020055 p:cacheManager-ref='ehcache' />
56
57 <bean id='ehcache'
58 class='org.springframework.cache.ehcache.EhCacheManagerFactoryBean'
59 p:configLocation='classpath:ehcache.xml' p:shared='true' />
60
61 <!--class="org.apache.commons.dbcp2.BasicDataSource" -->
62 <!-- org.springframework.jdbc.datasource.SingleConnectionDataSource -->
margaretha35e1ca22023-11-16 22:00:01 +010063 <bean id="dataSource"
64 class="org.apache.commons.dbcp2.BasicDataSource" lazy-init="true">
65 <property name="driverClassName"
66 value="${jdbc.driverClassName}" />
margarethaceae6972022-05-31 10:57:11 +020067 <property name="url" value="${jdbc.url}" />
68 <property name="username" value="${jdbc.username}" />
69 <property name="password" value="${jdbc.password}" />
70 <!-- relevant for single connection datasource and sqlite -->
71 <!-- <property name="suppressClose"> <value>true</value> </property> -->
72 <!--<property name="initialSize" value="2"/> -->
73 <property name="maxTotal" value="4" />
74 <property name="maxIdle" value="2" />
75 <property name="minIdle" value="1" />
76 <property name="maxWaitMillis" value="15000" />
77 <!--<property name="poolPreparedStatements" value="true"/> -->
78 </bean>
79
80 <bean id="sqliteDataSource"
81 class="org.springframework.jdbc.datasource.SingleConnectionDataSource"
82 lazy-init="true">
margaretha35e1ca22023-11-16 22:00:01 +010083 <property name="driverClassName"
84 value="${jdbc.driverClassName}" />
margarethaceae6972022-05-31 10:57:11 +020085 <property name="url" value="${jdbc.url}" />
86 <property name="username" value="${jdbc.username}" />
87 <property name="password" value="${jdbc.password}" />
88 <property name="connectionProperties">
89 <props>
90 <prop key="date_string_format">yyyy-MM-dd HH:mm:ss</prop>
91 </props>
92 </property>
93
94 <!-- relevant for single connection datasource and sqlite -->
95 <property name="suppressClose">
96 <value>true</value>
97 </property>
98 <!--<property name="initialSize" value="2"/> -->
99 <!--<property name="poolPreparedStatements" value="true"/> -->
100 </bean>
101
102 <!-- to configure database for sqlite, mysql, etc. migrations -->
margaretha35e1ca22023-11-16 22:00:01 +0100103 <bean id="flywayConfig"
104 class="org.flywaydb.core.api.configuration.ClassicConfiguration">
margarethaceae6972022-05-31 10:57:11 +0200105 <property name="baselineOnMigrate" value="true" />
106 <!-- <property name="validateOnMigrate" value="false" /> -->
107 <!-- <property name="cleanOnValidationError" value="true" /> -->
margaretha35e1ca22023-11-16 22:00:01 +0100108 <property name="locations"
109 value="#{'${jdbc.schemaPath}'.split(',')}" />
margarethaceae6972022-05-31 10:57:11 +0200110 <!-- <property name="dataSource" ref="dataSource" /> -->
111 <property name="dataSource" ref="sqliteDataSource" />
margaretha35e1ca22023-11-16 22:00:01 +0100112 <property name="outOfOrder" value="true" />
margarethaceae6972022-05-31 10:57:11 +0200113 </bean>
margaretha35e1ca22023-11-16 22:00:01 +0100114
115 <bean id="flyway" class="org.flywaydb.core.Flyway"
116 init-method="migrate">
117 <constructor-arg ref="flywayConfig" />
margarethaceae6972022-05-31 10:57:11 +0200118 </bean>
119
120
margaretha35e1ca22023-11-16 22:00:01 +0100121 <bean id="kustvakt_db"
122 class="de.ids_mannheim.korap.handlers.JDBCClient">
margarethaceae6972022-05-31 10:57:11 +0200123 <constructor-arg index="0" ref="dataSource" />
124 <!-- deprecated property -->
125 <property name="database" value="${jdbc.database}" />
126 </bean>
127
128 <bean id="entityManagerFactory"
129 class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
130 depends-on="flyway">
131 <!-- <property name="dataSource" ref="dataSource" /> -->
132 <property name="dataSource" ref="sqliteDataSource" />
133
134 <property name="packagesToScan">
135 <array>
136 <value>de.ids_mannheim.korap.entity</value>
137 <value>de.ids_mannheim.korap.oauth2.entity</value>
138 </array>
139 </property>
140 <property name="jpaVendorAdapter">
141 <bean id="jpaVendorAdapter"
142 class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
margaretha35e1ca22023-11-16 22:00:01 +0100143 <property name="databasePlatform"
144 value="${hibernate.dialect}" />
margarethaceae6972022-05-31 10:57:11 +0200145 </bean>
146 </property>
147 <property name="jpaProperties">
148 <props>
149 <prop key="hibernate.dialect">${hibernate.dialect}</prop>
150 <prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop>
151 <prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
152 <prop key="hibernate.cache.use_query_cache">${hibernate.cache.use_query_cache}</prop>
153 <prop key="hibernate.cache.use_second_level_cache">${hibernate.cache.use_second_level_cache}
154 </prop>
155 <prop key="hibernate.cache.provider_class">${hibernate.cache.provider}</prop>
156 <prop key="hibernate.cache.region.factory_class">${hibernate.cache.region.factory}</prop>
157 <prop key="hibernate.jdbc.time_zone">${hibernate.jdbc.time_zone}</prop>
158 <!-- <prop key="net.sf.ehcache.configurationResourceName">classpath:ehcache.xml</prop> -->
159 </props>
160 </property>
161 </bean>
162
163 <tx:annotation-driven proxy-target-class="true"
164 transaction-manager="transactionManager" />
165
margaretha35e1ca22023-11-16 22:00:01 +0100166 <bean id="transactionManager"
167 class="org.springframework.orm.jpa.JpaTransactionManager">
168 <property name="entityManagerFactory"
169 ref="entityManagerFactory" />
margarethaceae6972022-05-31 10:57:11 +0200170 </bean>
171
172 <bean id="transactionTemplate"
173 class="org.springframework.transaction.support.TransactionTemplate">
174 <constructor-arg ref="transactionManager" />
175 </bean>
176
177 <!-- Data access objects -->
178 <bean id="adminDao" class="de.ids_mannheim.korap.dao.AdminDaoImpl" />
margaretha35e1ca22023-11-16 22:00:01 +0100179 <bean id="authorizationDao"
180 class="de.ids_mannheim.korap.oauth2.dao.CachedAuthorizationDaoImpl" />
margarethaceae6972022-05-31 10:57:11 +0200181
182 <!-- Services -->
margaretha35e1ca22023-11-16 22:00:01 +0100183 <bean id="scopeService"
184 class="de.ids_mannheim.korap.oauth2.service.OAuth2ScopeServiceImpl" />
185
margarethaceae6972022-05-31 10:57:11 +0200186 <!-- props are injected from default-config.xml -->
margaretha35e1ca22023-11-16 22:00:01 +0100187 <bean id="kustvakt_config"
188 class="de.ids_mannheim.korap.config.FullConfiguration">
margarethaceae6972022-05-31 10:57:11 +0200189 <constructor-arg name="properties" ref="props" />
190 </bean>
191
margaretha35e1ca22023-11-16 22:00:01 +0100192 <bean id="initializator"
193 class="de.ids_mannheim.de.init.Initializator" init-method="init">
margarethaceae6972022-05-31 10:57:11 +0200194 </bean>
margaretha35e1ca22023-11-16 22:00:01 +0100195
margarethaceae6972022-05-31 10:57:11 +0200196 <!-- Krill -->
margaretha35e1ca22023-11-16 22:00:01 +0100197 <bean id="search_krill"
198 class="de.ids_mannheim.korap.web.SearchKrill">
margarethaceae6972022-05-31 10:57:11 +0200199 <constructor-arg value="${krill.indexDir}" />
200 </bean>
201
margaretha35e1ca22023-11-16 22:00:01 +0100202 <!-- Validator -->
203 <bean id="validator"
204 class="de.ids_mannheim.korap.validator.ApacheValidator" />
205
margarethaceae6972022-05-31 10:57:11 +0200206 <!-- URLValidator -->
margaretha35e1ca22023-11-16 22:00:01 +0100207 <bean id="redirectURIValidator"
208 class="org.apache.commons.validator.routines.UrlValidator">
margarethaceae6972022-05-31 10:57:11 +0200209 <constructor-arg value="http,https" index="0" />
210 <constructor-arg index="1" type="long">
211 <util:constant
212 static-field="org.apache.commons.validator.routines.UrlValidator.NO_FRAGMENTS" />
213 </constructor-arg>
214 </bean>
margaretha35e1ca22023-11-16 22:00:01 +0100215 <bean id="urlValidator"
216 class="org.apache.commons.validator.routines.UrlValidator">
margarethaceae6972022-05-31 10:57:11 +0200217 <constructor-arg value="http,https" />
218 </bean>
margaretha35e1ca22023-11-16 22:00:01 +0100219
margarethaceae6972022-05-31 10:57:11 +0200220 <!-- Rewrite -->
margaretha35e1ca22023-11-16 22:00:01 +0100221 <bean id="foundryRewrite"
222 class="de.ids_mannheim.korap.rewrite.FoundryRewrite" />
223 <bean id="collectionRewrite"
224 class="de.ids_mannheim.korap.rewrite.CollectionRewrite" />
225 <bean id="virtualCorpusRewrite"
226 class="de.ids_mannheim.korap.rewrite.VirtualCorpusRewrite" />
227 <bean id="queryReferenceRewrite"
228 class="de.ids_mannheim.korap.rewrite.QueryReferenceRewrite" />
229
margarethaceae6972022-05-31 10:57:11 +0200230 <util:list id="rewriteTasks"
231 value-type="de.ids_mannheim.korap.rewrite.RewriteTask">
232 <ref bean="foundryRewrite" />
233 <ref bean="collectionRewrite" />
234 <ref bean="virtualCorpusRewrite" />
margaretha35e1ca22023-11-16 22:00:01 +0100235 <ref bean="queryReferenceRewrite" />
margarethaceae6972022-05-31 10:57:11 +0200236 </util:list>
margaretha35e1ca22023-11-16 22:00:01 +0100237
238 <bean id="rewriteHandler"
239 class="de.ids_mannheim.korap.rewrite.RewriteHandler">
240 <constructor-arg ref="rewriteTasks" />
margarethaceae6972022-05-31 10:57:11 +0200241 </bean>
242
margaretha35e1ca22023-11-16 22:00:01 +0100243 <bean id="kustvaktResponseHandler"
244 class="de.ids_mannheim.korap.web.KustvaktResponseHandler">
margarethaceae6972022-05-31 10:57:11 +0200245 </bean>
246
247 <!-- OAuth -->
margaretha35e1ca22023-11-16 22:00:01 +0100248 <bean id="oauth2ResponseHandler"
249 class="de.ids_mannheim.korap.web.OAuth2ResponseHandler">
margarethaceae6972022-05-31 10:57:11 +0200250 </bean>
251
margaretha35e1ca22023-11-16 22:00:01 +0100252 <bean id="kustvakt_userdb"
253 class="de.ids_mannheim.korap.handlers.EntityDao">
margarethaceae6972022-05-31 10:57:11 +0200254 <constructor-arg ref="kustvakt_db" />
255 </bean>
256
margaretha35e1ca22023-11-16 22:00:01 +0100257 <bean name="kustvakt_encryption"
258 class="de.ids_mannheim.korap.encryption.KustvaktEncryption">
margarethaceae6972022-05-31 10:57:11 +0200259 <constructor-arg ref="kustvakt_config" />
260 </bean>
261
262 <!-- authentication providers to use -->
263 <!-- <bean id="api_auth" class="de.ids_mannheim.korap.authentication.APIAuthentication">
264 <constructor-arg type="de.ids_mannheim.korap.config.KustvaktConfiguration"
265 ref="kustvakt_config" /> </bean> -->
266
margaretha35e1ca22023-11-16 22:00:01 +0100267 <bean id="ldap_auth"
268 class="de.ids_mannheim.korap.authentication.LdapAuth3">
269 <constructor-arg
270 type="de.ids_mannheim.korap.config.KustvaktConfiguration"
margarethaceae6972022-05-31 10:57:11 +0200271 ref="kustvakt_config" />
272 </bean>
273
274 <bean id="basic_auth"
275 class="de.ids_mannheim.korap.authentication.BasicAuthentication" />
276
277
278 <bean id="session_auth"
279 class="de.ids_mannheim.korap.authentication.SessionAuthentication">
margaretha35e1ca22023-11-16 22:00:01 +0100280 <constructor-arg
281 type="de.ids_mannheim.korap.config.KustvaktConfiguration"
margarethaceae6972022-05-31 10:57:11 +0200282 ref="kustvakt_config" />
margaretha35e1ca22023-11-16 22:00:01 +0100283 <constructor-arg
284 type="de.ids_mannheim.korap.interfaces.EncryptionIface"
margarethaceae6972022-05-31 10:57:11 +0200285 ref="kustvakt_encryption" />
286 </bean>
287
288 <bean id="oauth2_auth"
289 class="de.ids_mannheim.korap.authentication.OAuth2Authentication" />
margaretha35e1ca22023-11-16 22:00:01 +0100290
margarethaceae6972022-05-31 10:57:11 +0200291 <util:list id="kustvakt_authproviders"
292 value-type="de.ids_mannheim.korap.interfaces.AuthenticationIface">
293 <ref bean="basic_auth" />
294 <ref bean="ldap_auth" />
margaretha35e1ca22023-11-16 22:00:01 +0100295 <!-- <ref bean="session_auth" /> <ref bean="api_auth" /> -->
margarethaceae6972022-05-31 10:57:11 +0200296 <ref bean="oauth2_auth" />
297 </util:list>
298
299
margaretha35e1ca22023-11-16 22:00:01 +0100300 <bean id="userdata_details"
301 class="de.ids_mannheim.korap.handlers.UserDetailsDao">
margarethaceae6972022-05-31 10:57:11 +0200302 <constructor-arg ref="kustvakt_db" />
303 </bean>
304
margaretha35e1ca22023-11-16 22:00:01 +0100305 <bean id="userdata_settings"
306 class="de.ids_mannheim.korap.handlers.UserSettingsDao">
margarethaceae6972022-05-31 10:57:11 +0200307 <constructor-arg ref="kustvakt_db" />
308 </bean>
309
310 <util:list id="kustvakt_userdata"
311 value-type="de.ids_mannheim.korap.interfaces.db.UserdataDbIface">
312 <ref bean="userdata_details" />
313 <ref bean="userdata_settings" />
314 </util:list>
315
316 <!-- specify type for constructor argument -->
317 <bean id="authenticationManager"
318 class="de.ids_mannheim.korap.authentication.KustvaktAuthenticationManager">
margaretha35e1ca22023-11-16 22:00:01 +0100319 <constructor-arg
320 type="de.ids_mannheim.korap.interfaces.EntityHandlerIface"
margarethaceae6972022-05-31 10:57:11 +0200321 ref="kustvakt_userdb" />
margaretha35e1ca22023-11-16 22:00:01 +0100322 <constructor-arg
323 type="de.ids_mannheim.korap.interfaces.EncryptionIface"
margarethaceae6972022-05-31 10:57:11 +0200324 ref="kustvakt_encryption" />
325 <constructor-arg ref="kustvakt_config" />
margarethaceae6972022-05-31 10:57:11 +0200326 <constructor-arg ref="kustvakt_userdata" />
327 <!-- inject authentication providers to use -->
328 <property name="providers" ref="kustvakt_authproviders" />
329 </bean>
margaretha35e1ca22023-11-16 22:00:01 +0100330
margarethaceae6972022-05-31 10:57:11 +0200331 <!-- todo: if db interfaces not loaded via spring, does transaction even
332 work then? -->
333 <!-- the transactional advice (i.e. what 'happens'; see the <aop:advisor/>
334 bean below) -->
335 <tx:advice id="txAdvice" transaction-manager="txManager">
336 <!-- the transactional semantics... -->
337 <tx:attributes>
338 <!-- all methods starting with 'get' are read-only -->
margaretha35e1ca22023-11-16 22:00:01 +0100339 <tx:method name="get*" read-only="true"
340 rollback-for="KorAPException" />
margarethaceae6972022-05-31 10:57:11 +0200341 <!-- other methods use the default transaction settings (see below) -->
342 <tx:method name="*" rollback-for="KorAPException" />
343 </tx:attributes>
344 </tx:advice>
345
346 <!-- ensure that the above transactional advice runs for any execution of
347 an operation defined by the service interface -->
348 <aop:config>
349 <aop:pointcut id="service"
350 expression="execution(* de.ids_mannheim.korap.interfaces.db.*.*(..))" />
351 <aop:advisor advice-ref="txAdvice" pointcut-ref="service" />
352 </aop:config>
353
354 <!-- similarly, don't forget the PlatformTransactionManager -->
355 <bean id="txManager"
356 class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
357 <!-- <property name="dataSource" ref="dataSource" /> -->
358 <property name="dataSource" ref="sqliteDataSource" />
359 </bean>
360
361 <!-- mail -->
margaretha35e1ca22023-11-16 22:00:01 +0100362 <bean id="authenticator"
363 class="de.ids_mannheim.korap.service.MailAuthenticator">
margarethaceae6972022-05-31 10:57:11 +0200364 <constructor-arg index="0" value="${mail.username}" />
365 <constructor-arg index="1" value="${mail.password}" />
366 </bean>
margaretha35e1ca22023-11-16 22:00:01 +0100367 <bean id="smtpSession" class="jakarta.mail.Session"
368 factory-method="getInstance">
margarethaceae6972022-05-31 10:57:11 +0200369 <constructor-arg index="0">
370 <props>
371 <prop key="mail.smtp.submitter">${mail.username}</prop>
372 <prop key="mail.smtp.auth">${mail.auth}</prop>
373 <prop key="mail.smtp.host">${mail.host}</prop>
374 <prop key="mail.smtp.port">${mail.port}</prop>
375 <prop key="mail.smtp.starttls.enable">${mail.starttls.enable}</prop>
376 <prop key="mail.smtp.connectiontimeout">${mail.connectiontimeout}</prop>
377 </props>
378 </constructor-arg>
379 <constructor-arg index="1" ref="authenticator" />
380 </bean>
margaretha35e1ca22023-11-16 22:00:01 +0100381 <bean id="mailSender"
382 class="org.springframework.mail.javamail.JavaMailSenderImpl">
margarethaceae6972022-05-31 10:57:11 +0200383 <property name="username" value="${mail.username}" />
384 <property name="password" value="${mail.password}" />
385 <property name="session" ref="smtpSession" />
386 </bean>
margaretha35e1ca22023-11-16 22:00:01 +0100387 <bean id="velocityEngine"
388 class="org.apache.velocity.app.VelocityEngine">
margarethaceae6972022-05-31 10:57:11 +0200389 <constructor-arg index="0">
390 <props>
391 <prop key="resource.loader">class</prop>
392 <prop key="class.resource.loader.class">org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
393 </prop>
394 </props>
395 </constructor-arg>
396 </bean>
397</beans>