blob: 57e2f8d9e54edd296fd41aefe3b9a42cb505ef0f [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"
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"
margaretha543f2002017-07-14 00:27:15 +02009 xmlns:cache="http://www.springframework.org/schema/cache"
10 xsi:schemaLocation="http://www.springframework.org/schema/beans
margaretha3da7cd32018-10-22 17:42:52 +020011 http://www.springframework.org/schema/beans/spring-beans.xsd
margaretha543f2002017-07-14 00:27:15 +020012 http://www.springframework.org/schema/tx
margaretha3da7cd32018-10-22 17:42:52 +020013 http://www.springframework.org/schema/tx/spring-tx.xsd
margaretha543f2002017-07-14 00:27:15 +020014 http://www.springframework.org/schema/aop
margaretha3da7cd32018-10-22 17:42:52 +020015 http://www.springframework.org/schema/aop/spring-aop.xsd
margaretha543f2002017-07-14 00:27:15 +020016 http://www.springframework.org/schema/context
margaretha3da7cd32018-10-22 17:42:52 +020017 http://www.springframework.org/schema/context/spring-context.xsd
margaretha543f2002017-07-14 00:27:15 +020018 http://www.springframework.org/schema/util
margaretha3da7cd32018-10-22 17:42:52 +020019 http://www.springframework.org/schema/util/spring-util.xsd">
margaretha543f2002017-07-14 00:27:15 +020020
margaretha35e1ca22023-11-16 22:00:01 +010021 <context:component-scan
22 base-package="de.ids_mannheim.korap" />
margaretha543f2002017-07-14 00:27:15 +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>
margarethad77ee712024-03-22 12:35:30 +010032 <value>file:./data/kustvakt.conf</value>
margaretha543f2002017-07-14 00:27:15 +020033 </array>
34 </property>
35 </bean>
36
37 <bean id="placeholders"
38 class="org.springframework.context.support.PropertySourcesPlaceholderConfigurer">
39 <property name="ignoreResourceNotFound" value="true" />
40 <property name="locations">
41 <array>
margarethaaecee1b2018-02-20 14:44:21 +010042 <value>classpath:properties/jdbc.properties</value>
margarethaea68a0a2017-09-21 03:09:49 +020043 <value>file:./jdbc.properties</value>
margarethad77ee712024-03-22 12:35:30 +010044 <value>file:./data/jdbc.properties</value>
margarethaaecee1b2018-02-20 14:44:21 +010045 <value>classpath:properties/mail.properties</value>
46 <value>file:./mail.properties</value>
margarethacc7feb62023-05-09 08:57:46 +020047 <value>classpath:properties/hibernate.properties</value>
margaretha0e8f4e72018-04-05 14:11:52 +020048
margarethaade7d4a2017-07-20 19:53:35 +020049 <value>classpath:kustvakt.conf</value>
margaretha14503cd2017-09-08 15:35:24 +020050 <value>file:./kustvakt.conf</value>
margarethad77ee712024-03-22 12:35:30 +010051 <value>file:./data/kustvakt.conf</value>
margaretha543f2002017-07-14 00:27:15 +020052 </array>
53 </property>
54 </bean>
55
margaretha35e1ca22023-11-16 22:00:01 +010056 <!-- <bean id='cacheManager' class='org.springframework.cache.ehcache.EhCacheCacheManager'
57 p:cacheManager-ref='ehcache' /> <bean id='ehcache' class='org.springframework.cache.ehcache.EhCacheManagerFactoryBean'
58 p:configLocation='classpath:ehcache.xml' p:shared='true' /> -->
margaretha543f2002017-07-14 00:27:15 +020059 <!--class="org.apache.commons.dbcp2.BasicDataSource" -->
60 <!-- org.springframework.jdbc.datasource.SingleConnectionDataSource -->
margaretha35e1ca22023-11-16 22:00:01 +010061 <bean id="dataSource"
62 class="org.apache.commons.dbcp2.BasicDataSource" lazy-init="true">
63 <property name="driverClassName"
64 value="${jdbc.driverClassName}" />
margaretha543f2002017-07-14 00:27:15 +020065 <property name="url" value="${jdbc.url}" />
66 <property name="username" value="${jdbc.username}" />
67 <property name="password" value="${jdbc.password}" />
68 <!-- relevant for single connection datasource and sqlite -->
69 <!-- <property name="suppressClose"> <value>true</value> </property> -->
70 <!--<property name="initialSize" value="2"/> -->
71 <property name="maxTotal" value="4" />
72 <property name="maxIdle" value="2" />
73 <property name="minIdle" value="1" />
margaretha45211af2018-08-28 12:49:07 +020074 <property name="maxWaitMillis" value="-1" />
margaretha543f2002017-07-14 00:27:15 +020075 <!--<property name="poolPreparedStatements" value="true"/> -->
76 </bean>
margaretha35e1ca22023-11-16 22:00:01 +010077
78 <bean id="c3p0DataSource"
79 class="com.mchange.v2.c3p0.ComboPooledDataSource"
margaretha45211af2018-08-28 12:49:07 +020080 destroy-method="close" lazy-init="true">
81 <property name="driverClass" value="${jdbc.driverClassName}" />
82 <property name="jdbcUrl" value="${jdbc.url}" />
83 <property name="user" value="${jdbc.username}" />
84 <property name="password" value="${jdbc.password}" />
85 <property name="maxPoolSize" value="4" />
86 <property name="minPoolSize" value="1" />
87 <property name="maxStatements" value="100" />
88 <!-- <property name="testConnectionOnCheckOut" value="true" /> -->
89 <property name="idleConnectionTestPeriod" value="60" />
90 <property name="testConnectionOnCheckin" value="true" />
91 </bean>
margaretha543f2002017-07-14 00:27:15 +020092
margaretha543f2002017-07-14 00:27:15 +020093 <!-- to configure database for sqlite, mysql, etc. migrations -->
margaretha35e1ca22023-11-16 22:00:01 +010094 <bean id="flywayConfig"
95 class="org.flywaydb.core.api.configuration.ClassicConfiguration">
margarethaf6d5a822017-10-19 19:51:20 +020096 <property name="baselineOnMigrate" value="true" />
margarethaecbe72d2017-07-26 17:13:32 +020097 <!-- <property name="validateOnMigrate" value="false" /> -->
98 <!-- <property name="cleanOnValidationError" value="true" /> -->
margaretha35e1ca22023-11-16 22:00:01 +010099 <property name="locations"
100 value="#{'${jdbc.schemaPath}'.split(',')}" />
margaretha8fe51e92023-09-20 11:22:20 +0200101 <property name="dataSource" ref="dataSource" />
margaretha8514d782018-08-28 17:36:56 +0200102 <!-- <property name="dataSource" ref="c3p0DataSource" /> -->
margarethad66a6832022-03-03 08:47:13 +0100103 <property name="outOfOrder" value="true" />
margaretha543f2002017-07-14 00:27:15 +0200104 </bean>
margaretha35e1ca22023-11-16 22:00:01 +0100105
106 <bean id="flyway" class="org.flywaydb.core.Flyway"
107 init-method="migrate">
108 <constructor-arg ref="flywayConfig" />
margarethafcf8bd92021-01-14 10:55:53 +0100109 </bean>
margaretha0e8f4e72018-04-05 14:11:52 +0200110
margaretha543f2002017-07-14 00:27:15 +0200111 <bean id="entityManagerFactory"
margarethafcf8bd92021-01-14 10:55:53 +0100112 class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
113 depends-on="flyway">
margaretha8fe51e92023-09-20 11:22:20 +0200114 <property name="dataSource" ref="dataSource" />
margaretha8514d782018-08-28 17:36:56 +0200115 <!-- <property name="dataSource" ref="c3p0DataSource" /> -->
margaretha0e8f4e72018-04-05 14:11:52 +0200116
margarethaa452c5e2018-04-25 22:48:09 +0200117 <property name="packagesToScan">
118 <array>
margaretha5b708792023-05-12 16:55:29 +0200119 <value>de.ids_mannheim.korap.core.entity</value>
margarethaa452c5e2018-04-25 22:48:09 +0200120 <value>de.ids_mannheim.korap.entity</value>
121 <value>de.ids_mannheim.korap.oauth2.entity</value>
122 </array>
123 </property>
margaretha543f2002017-07-14 00:27:15 +0200124 <property name="jpaVendorAdapter">
125 <bean id="jpaVendorAdapter"
126 class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
margaretha35e1ca22023-11-16 22:00:01 +0100127 <property name="databasePlatform"
128 value="${hibernate.dialect}" />
margaretha543f2002017-07-14 00:27:15 +0200129 </bean>
130 </property>
131 <property name="jpaProperties">
132 <props>
133 <prop key="hibernate.dialect">${hibernate.dialect}</prop>
134 <prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop>
135 <prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
136 <prop key="hibernate.cache.use_query_cache">${hibernate.cache.use_query_cache}</prop>
137 <prop key="hibernate.cache.use_second_level_cache">${hibernate.cache.use_second_level_cache}
138 </prop>
139 <prop key="hibernate.cache.provider_class">${hibernate.cache.provider}</prop>
140 <prop key="hibernate.cache.region.factory_class">${hibernate.cache.region.factory}</prop>
margaretha6ad08b42018-08-22 18:33:54 +0200141 <prop key="hibernate.jdbc.time_zone">${hibernate.jdbc.time_zone}</prop>
margaretha543f2002017-07-14 00:27:15 +0200142 </props>
143 </property>
144 </bean>
145
146 <tx:annotation-driven proxy-target-class="true"
147 transaction-manager="transactionManager" />
margaretha0e8f4e72018-04-05 14:11:52 +0200148
margaretha35e1ca22023-11-16 22:00:01 +0100149 <bean id="transactionManager"
150 class="org.springframework.orm.jpa.JpaTransactionManager">
151 <property name="entityManagerFactory"
152 ref="entityManagerFactory" />
margaretha543f2002017-07-14 00:27:15 +0200153 </bean>
154
155 <bean id="transactionTemplate"
156 class="org.springframework.transaction.support.TransactionTemplate">
157 <constructor-arg ref="transactionManager" />
158 </bean>
159
margarethaade7d4a2017-07-20 19:53:35 +0200160 <!-- Data access objects -->
margaretha34954472018-10-24 20:05:17 +0200161 <bean id="adminDao" class="de.ids_mannheim.korap.dao.AdminDaoImpl" />
margaretha35e1ca22023-11-16 22:00:01 +0100162 <bean id="authorizationDao"
163 class="de.ids_mannheim.korap.oauth2.dao.CachedAuthorizationDaoImpl" />
margarethab4ce6602018-04-26 20:23:57 +0200164
margaretha34954472018-10-24 20:05:17 +0200165 <!-- Services -->
margaretha35e1ca22023-11-16 22:00:01 +0100166 <bean id="scopeService"
167 class="de.ids_mannheim.korap.oauth2.service.OAuth2ScopeServiceImpl" />
168
margarethab4ce6602018-04-26 20:23:57 +0200169 <!-- props are injected from default-config.xml -->
margaretha35e1ca22023-11-16 22:00:01 +0100170 <bean id="kustvakt_config"
171 class="de.ids_mannheim.korap.config.FullConfiguration">
margarethab4ce6602018-04-26 20:23:57 +0200172 <constructor-arg name="properties" ref="props" />
173 </bean>
174
margaretha35e1ca22023-11-16 22:00:01 +0100175 <bean id="initializator"
176 class="de.ids_mannheim.korap.init.Initializator" init-method="init">
margarethab4ce6602018-04-26 20:23:57 +0200177 </bean>
margaretha35e1ca22023-11-16 22:00:01 +0100178
margarethaade7d4a2017-07-20 19:53:35 +0200179 <!-- Krill -->
margaretha35e1ca22023-11-16 22:00:01 +0100180 <bean id="search_krill"
181 class="de.ids_mannheim.korap.web.SearchKrill">
margaretha0e8f4e72018-04-05 14:11:52 +0200182 <constructor-arg value="${krill.indexDir}" />
margaretha543f2002017-07-14 00:27:15 +0200183 </bean>
margaretha35e1ca22023-11-16 22:00:01 +0100184
margaretha6cd27f32019-01-24 14:47:47 +0100185 <!-- Validator -->
margaretha35e1ca22023-11-16 22:00:01 +0100186 <bean id="validator"
187 class="de.ids_mannheim.korap.validator.ApacheValidator" />
margaretha543f2002017-07-14 00:27:15 +0200188
margaretha31a9f522018-04-03 20:40:45 +0200189 <!-- URLValidator -->
margaretha35e1ca22023-11-16 22:00:01 +0100190 <bean id="redirectURIValidator"
191 class="org.apache.commons.validator.routines.UrlValidator">
margarethae4034a82018-07-02 14:46:59 +0200192 <constructor-arg value="http,https" index="0" />
margaretha35e1ca22023-11-16 22:00:01 +0100193 <constructor-arg index="1" type="long"
194 value="#{T(org.apache.commons.validator.routines.UrlValidator).ALLOW_LOCAL_URLS +
195 T(org.apache.commons.validator.routines.UrlValidator).NO_FRAGMENTS}" />
196
197 <!-- <constructor-arg index="1" type="long"> <util:constant static-field="org.apache.commons.validator.routines.UrlValidator.NO_FRAGMENTS"
198 /> </constructor-arg> -->
margarethaa0486272018-04-12 19:59:31 +0200199 </bean>
margaretha35e1ca22023-11-16 22:00:01 +0100200 <bean id="urlValidator"
201 class="org.apache.commons.validator.routines.UrlValidator">
margarethad7cab212018-07-02 19:01:43 +0200202 <constructor-arg value="http,https" />
203 </bean>
margaretha35e1ca22023-11-16 22:00:01 +0100204
margaretha34954472018-10-24 20:05:17 +0200205 <!-- Rewrite -->
margaretha35e1ca22023-11-16 22:00:01 +0100206 <bean id="foundryRewrite"
207 class="de.ids_mannheim.korap.rewrite.FoundryRewrite" />
208 <bean id="collectionRewrite"
209 class="de.ids_mannheim.korap.rewrite.CollectionRewrite" />
210 <bean id="virtualCorpusRewrite"
211 class="de.ids_mannheim.korap.rewrite.VirtualCorpusRewrite" />
212 <bean id="queryReferenceRewrite"
213 class="de.ids_mannheim.korap.rewrite.QueryReferenceRewrite" />
214
margaretha4fa4b062019-01-28 19:43:30 +0100215 <util:list id="rewriteTasks"
216 value-type="de.ids_mannheim.korap.rewrite.RewriteTask">
217 <ref bean="foundryRewrite" />
218 <ref bean="collectionRewrite" />
219 <ref bean="virtualCorpusRewrite" />
margaretha35e1ca22023-11-16 22:00:01 +0100220 <ref bean="queryReferenceRewrite" />
margaretha4fa4b062019-01-28 19:43:30 +0100221 </util:list>
margaretha35e1ca22023-11-16 22:00:01 +0100222
223 <bean id="rewriteHandler"
224 class="de.ids_mannheim.korap.rewrite.RewriteHandler">
225 <constructor-arg ref="rewriteTasks" />
margaretha56e8e552017-12-05 16:31:21 +0100226 </bean>
227
margaretha35e1ca22023-11-16 22:00:01 +0100228 <bean id="kustvaktResponseHandler"
229 class="de.ids_mannheim.korap.web.KustvaktResponseHandler">
margaretha0e8f4e72018-04-05 14:11:52 +0200230 </bean>
margarethaa452c5e2018-04-25 22:48:09 +0200231
margarethafb027f92018-04-23 20:00:13 +0200232 <!-- OAuth -->
margaretha35e1ca22023-11-16 22:00:01 +0100233 <bean id="oauth2ResponseHandler"
234 class="de.ids_mannheim.korap.web.OAuth2ResponseHandler">
margaretha05122312018-04-16 15:01:34 +0200235 </bean>
margarethaa452c5e2018-04-25 22:48:09 +0200236
margaretha35e1ca22023-11-16 22:00:01 +0100237 <bean name="kustvakt_encryption"
238 class="de.ids_mannheim.korap.encryption.KustvaktEncryption">
margaretha543f2002017-07-14 00:27:15 +0200239 <constructor-arg ref="kustvakt_config" />
240 </bean>
241
242 <!-- authentication providers to use -->
margaretha543f2002017-07-14 00:27:15 +0200243
margaretha35e1ca22023-11-16 22:00:01 +0100244 <!-- <bean id="session_auth" class="de.ids_mannheim.korap.authentication.SessionAuthentication">
245 <constructor-arg type="de.ids_mannheim.korap.config.KustvaktConfiguration"
246 ref="kustvakt_config" /> <constructor-arg type="de.ids_mannheim.korap.interfaces.EncryptionIface"
247 ref="kustvakt_encryption" /> </bean> -->
Michael Hanlca740d72015-06-16 10:04:58 +0200248
margarethacf306d32018-05-30 19:45:35 +0200249 <bean id="oauth2_auth"
250 class="de.ids_mannheim.korap.authentication.OAuth2Authentication" />
margaretha35e1ca22023-11-16 22:00:01 +0100251
margaretha543f2002017-07-14 00:27:15 +0200252 <util:list id="kustvakt_authproviders"
253 value-type="de.ids_mannheim.korap.interfaces.AuthenticationIface">
margarethaac49b502023-04-18 11:01:48 +0200254 <!-- <ref bean="session_auth" /> -->
margarethacf306d32018-05-30 19:45:35 +0200255 <ref bean="oauth2_auth" />
margaretha543f2002017-07-14 00:27:15 +0200256 </util:list>
Michael Hanl72c7b832015-09-03 08:42:15 +0200257
258
margaretha543f2002017-07-14 00:27:15 +0200259 <!-- specify type for constructor argument -->
margaretha34954472018-10-24 20:05:17 +0200260 <bean id="authenticationManager"
margaretha139d0f72017-11-14 18:56:22 +0100261 class="de.ids_mannheim.korap.authentication.KustvaktAuthenticationManager">
margaretha35e1ca22023-11-16 22:00:01 +0100262 <constructor-arg
263 type="de.ids_mannheim.korap.interfaces.EncryptionIface"
margaretha543f2002017-07-14 00:27:15 +0200264 ref="kustvakt_encryption" />
265 <constructor-arg ref="kustvakt_config" />
margaretha543f2002017-07-14 00:27:15 +0200266 <!-- inject authentication providers to use -->
267 <property name="providers" ref="kustvakt_authproviders" />
268 </bean>
margaretha35e1ca22023-11-16 22:00:01 +0100269
margaretha543f2002017-07-14 00:27:15 +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 -->
margaretha35e1ca22023-11-16 22:00:01 +0100278 <tx:method name="get*" read-only="true"
279 rollback-for="KorAPException" />
margaretha543f2002017-07-14 00:27:15 +0200280 <!-- other methods use the default transaction settings (see below) -->
281 <tx:method name="*" rollback-for="KorAPException" />
282 </tx:attributes>
283 </tx:advice>
Michael Hanldaf86602016-05-12 14:31:52 +0200284
margaretha543f2002017-07-14 00:27:15 +0200285 <!-- ensure that the above transactional advice runs for any execution of
286 an operation defined by the service interface -->
287 <aop:config>
288 <aop:pointcut id="service"
289 expression="execution(* de.ids_mannheim.korap.interfaces.db.*.*(..))" />
290 <aop:advisor advice-ref="txAdvice" pointcut-ref="service" />
291 </aop:config>
Michael Hanlf8fcc7a2016-06-03 17:41:07 +0200292
margaretha543f2002017-07-14 00:27:15 +0200293 <!-- similarly, don't forget the PlatformTransactionManager -->
294 <bean id="txManager"
295 class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
margaretha09a9a582024-01-11 21:48:20 +0100296 <property name="dataSource" ref="dataSource" />
margaretha8514d782018-08-28 17:36:56 +0200297 <!-- <property name="dataSource" ref="c3p0DataSource" /> -->
margaretha543f2002017-07-14 00:27:15 +0200298 </bean>
margaretha0e8f4e72018-04-05 14:11:52 +0200299
margarethac9f1dfa2018-02-07 17:50:33 +0100300 <!-- mail -->
margaretha35e1ca22023-11-16 22:00:01 +0100301 <bean id="authenticator"
302 class="de.ids_mannheim.korap.service.MailAuthenticator">
margaretha0e8f4e72018-04-05 14:11:52 +0200303 <constructor-arg index="0" value="${mail.username}" />
304 <constructor-arg index="1" value="${mail.password}" />
margarethaaecee1b2018-02-20 14:44:21 +0100305 </bean>
margaretha35e1ca22023-11-16 22:00:01 +0100306 <bean id="smtpSession" class="jakarta.mail.Session"
307 factory-method="getInstance">
margarethaaecee1b2018-02-20 14:44:21 +0100308 <constructor-arg index="0">
309 <props>
310 <prop key="mail.smtp.submitter">${mail.username}</prop>
311 <prop key="mail.smtp.auth">${mail.auth}</prop>
312 <prop key="mail.smtp.host">${mail.host}</prop>
313 <prop key="mail.smtp.port">${mail.port}</prop>
314 <prop key="mail.smtp.starttls.enable">${mail.starttls.enable}</prop>
315 <prop key="mail.smtp.connectiontimeout">${mail.connectiontimeout}</prop>
316 </props>
317 </constructor-arg>
margaretha0e8f4e72018-04-05 14:11:52 +0200318 <constructor-arg index="1" ref="authenticator" />
margarethac9f1dfa2018-02-07 17:50:33 +0100319 </bean>
margaretha35e1ca22023-11-16 22:00:01 +0100320 <bean id="mailSender"
321 class="org.springframework.mail.javamail.JavaMailSenderImpl">
margarethaaecee1b2018-02-20 14:44:21 +0100322 <property name="username" value="${mail.username}" />
margaretha0e8f4e72018-04-05 14:11:52 +0200323 <property name="password" value="${mail.password}" />
margarethac9f1dfa2018-02-07 17:50:33 +0100324 <property name="session" ref="smtpSession" />
325 </bean>
margaretha35e1ca22023-11-16 22:00:01 +0100326 <bean id="velocityEngine"
327 class="org.apache.velocity.app.VelocityEngine">
margarethac9f1dfa2018-02-07 17:50:33 +0100328 <constructor-arg index="0">
329 <props>
330 <prop key="resource.loader">class</prop>
margaretha0e8f4e72018-04-05 14:11:52 +0200331 <prop key="class.resource.loader.class">org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
332 </prop>
margarethac9f1dfa2018-02-07 17:50:33 +0100333 </props>
334 </constructor-arg>
margarethaaecee1b2018-02-20 14:44:21 +0100335 </bean>
Akronbee031a2020-10-29 16:58:14 +0100336</beans>