blob: cff5100056148e2a6122e9bebb01634ba75c9217 [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"
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"
margarethaade7d4a2017-07-20 19:53:35 +02009 xmlns:cache="http://www.springframework.org/schema/cache"
margaretha62055f72017-04-11 19:17:43 +020010 xsi:schemaLocation="http://www.springframework.org/schema/beans
margaretha3da7cd32018-10-22 17:42:52 +020011 http://www.springframework.org/schema/beans/spring-beans.xsd
margarethaade7d4a2017-07-20 19:53:35 +020012 http://www.springframework.org/schema/tx
margaretha3da7cd32018-10-22 17:42:52 +020013 http://www.springframework.org/schema/tx/spring-tx.xsd
margarethaade7d4a2017-07-20 19:53:35 +020014 http://www.springframework.org/schema/aop
margaretha3da7cd32018-10-22 17:42:52 +020015 http://www.springframework.org/schema/aop/spring-aop.xsd
margarethaade7d4a2017-07-20 19:53:35 +020016 http://www.springframework.org/schema/context
margaretha3da7cd32018-10-22 17:42:52 +020017 http://www.springframework.org/schema/context/spring-context.xsd
margarethaade7d4a2017-07-20 19:53:35 +020018 http://www.springframework.org/schema/util
margaretha3da7cd32018-10-22 17:42:52 +020019 http://www.springframework.org/schema/util/spring-util.xsd">
Michael Hanlbd852b82015-11-18 22:17:00 +010020
margaretha35e1ca22023-11-16 22:00:01 +010021 <context:component-scan
22 base-package="de.ids_mannheim.korap" />
margarethaade7d4a2017-07-20 19:53:35 +020023 <context:annotation-config />
Michael Hanlbd852b82015-11-18 22:17:00 +010024
margaretha62055f72017-04-11 19:17:43 +020025 <bean id="props"
26 class="org.springframework.beans.factory.config.PropertiesFactoryBean">
27 <property name="ignoreResourceNotFound" value="true" />
28 <property name="locations">
29 <array>
margaretha0c47c652017-04-19 18:44:40 +020030 <value>classpath:kustvakt-test.conf</value>
31 <value>file:./kustvakt-test.conf</value>
margaretha62055f72017-04-11 19:17:43 +020032 </array>
33 </property>
34 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +010035
margarethaade7d4a2017-07-20 19:53:35 +020036 <bean id="placeholders"
37 class="org.springframework.context.support.PropertySourcesPlaceholderConfigurer">
margaretha62055f72017-04-11 19:17:43 +020038 <property name="ignoreResourceNotFound" value="true" />
39 <property name="locations">
40 <array>
margaretha6c2a20f2017-07-24 15:33:01 +020041 <value>classpath:test-jdbc.properties</value>
margaretha1f106f62017-10-18 22:27:30 +020042 <value>file:./test-jdbc.properties</value>
margaretha64755022024-06-18 10:30:59 +020043 <value>file:./data/test-jdbc.properties</value>
margarethaaecee1b2018-02-20 14:44:21 +010044 <value>classpath:properties/mail.properties</value>
45 <value>file:./mail.properties</value>
margaretha64755022024-06-18 10:30:59 +020046 <value>file:./data/mail.properties</value>
margarethaf6d5a822017-10-19 19:51:20 +020047 <value>classpath:test-hibernate.properties</value>
margaretha64755022024-06-18 10:30:59 +020048 <value>file:./data/test-hibernate.properties</value>
margaretha1960ea52023-02-28 11:20:15 +010049 <value>file:./kustvakt-test.conf</value>
margarethaf18298b2017-09-14 22:14:32 +020050 <value>classpath:kustvakt-test.conf</value>
margaretha64755022024-06-18 10:30:59 +020051 <value>file:./data/kustvakt-test.conf</value>
margaretha62055f72017-04-11 19:17:43 +020052 </array>
53 </property>
54 </bean>
margarethaf6f6c3c2024-06-11 10:51:06 +020055
margarethaf6f6c3c2024-06-11 10:51:06 +020056 <bean id="kustvakt_config"
57 class="de.ids_mannheim.korap.config.FullConfiguration">
58 <constructor-arg name="properties" ref="props" />
59 </bean>
60
Michael Hanlbd852b82015-11-18 22:17:00 +010061
margaretha35e1ca22023-11-16 22:00:01 +010062 <bean id="dataSource"
63 class="org.apache.commons.dbcp2.BasicDataSource" lazy-init="true">
margaretha4edc70e2018-03-14 22:34:29 +010064 <!-- <property name="driverClassName" value="${jdbc.driverClassName}" /> -->
margaretha6c2a20f2017-07-24 15:33:01 +020065 <property name="url" value="${jdbc.url}" />
66 <property name="username" value="${jdbc.username}" />
67 <property name="password" value="${jdbc.password}" />
margaretha318fec32017-10-24 12:11:58 +020068 <property name="maxTotal" value="4" />
margaretha514e1412017-10-10 15:54:20 +020069 <property name="maxIdle" value="1" />
margaretha6c2a20f2017-07-24 15:33:01 +020070 <property name="minIdle" value="1" />
71 <property name="maxWaitMillis" value="15000" />
72 <!--<property name="poolPreparedStatements" value="true"/> -->
73 </bean>
74
margaretha35e1ca22023-11-16 22:00:01 +010075 <bean id="c3p0DataSource"
76 class="com.mchange.v2.c3p0.ComboPooledDataSource"
margaretha58e18632018-02-15 13:04:42 +010077 destroy-method="close">
78 <property name="driverClass" value="${jdbc.driverClassName}" />
margaretha514e1412017-10-10 15:54:20 +020079 <property name="jdbcUrl" value="${jdbc.url}" />
80 <property name="user" value="${jdbc.username}" />
81 <property name="password" value="${jdbc.password}" />
margaretha58e18632018-02-15 13:04:42 +010082 <property name="maxPoolSize" value="4" />
83 <property name="minPoolSize" value="1" />
84 <property name="maxStatements" value="1" />
85 <property name="testConnectionOnCheckout" value="true" />
margaretha62055f72017-04-11 19:17:43 +020086 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +010087
margaretha62055f72017-04-11 19:17:43 +020088 <!-- to configure database for sqlite, mysql, etc. migrations -->
margaretha35e1ca22023-11-16 22:00:01 +010089 <bean id="flywayConfig"
90 class="org.flywaydb.core.api.configuration.ClassicConfiguration">
margarethaf6d5a822017-10-19 19:51:20 +020091 <!-- drop existing tables and create new tables -->
92 <property name="validateOnMigrate" value="true" />
93 <property name="cleanOnValidationError" value="true" />
margaretha514e1412017-10-10 15:54:20 +020094 <property name="baselineOnMigrate" value="false" />
margaretha35e1ca22023-11-16 22:00:01 +010095 <property name="locations"
96 value="#{'${jdbc.schemaPath}'.split(',')}" />
margaretha8fe51e92023-09-20 11:22:20 +020097 <property name="dataSource" ref="dataSource" />
margarethad66a6832022-03-03 08:47:13 +010098 <property name="outOfOrder" value="true" />
margaretha62055f72017-04-11 19:17:43 +020099 </bean>
margaretha35e1ca22023-11-16 22:00:01 +0100100
101 <bean id="flyway" class="org.flywaydb.core.Flyway"
102 init-method="migrate">
103 <constructor-arg ref="flywayConfig" />
margarethafcf8bd92021-01-14 10:55:53 +0100104 </bean>
margaretha35e1ca22023-11-16 22:00:01 +0100105
margarethaade7d4a2017-07-20 19:53:35 +0200106 <bean id="entityManagerFactory"
107 class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
margaretha8fe51e92023-09-20 11:22:20 +0200108 <property name="dataSource" ref="dataSource" />
margaretha3a966022024-06-13 13:51:50 +0200109
margarethaa452c5e2018-04-25 22:48:09 +0200110 <property name="packagesToScan">
111 <array>
margaretha5b708792023-05-12 16:55:29 +0200112 <value>de.ids_mannheim.korap.core.entity</value>
margarethaa452c5e2018-04-25 22:48:09 +0200113 <value>de.ids_mannheim.korap.entity</value>
114 <value>de.ids_mannheim.korap.oauth2.entity</value>
115 </array>
116 </property>
margarethaade7d4a2017-07-20 19:53:35 +0200117 <property name="jpaVendorAdapter">
118 <bean id="jpaVendorAdapter"
119 class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
margaretha35e1ca22023-11-16 22:00:01 +0100120 <property name="databasePlatform"
121 value="${hibernate.dialect}" />
margarethaade7d4a2017-07-20 19:53:35 +0200122 </bean>
123 </property>
124 <property name="jpaProperties">
125 <props>
126 <prop key="hibernate.dialect">${hibernate.dialect}</prop>
127 <prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop>
128 <prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
129 <prop key="hibernate.cache.use_query_cache">${hibernate.cache.use_query_cache}</prop>
130 <prop key="hibernate.cache.use_second_level_cache">${hibernate.cache.use_second_level_cache}
131 </prop>
132 <prop key="hibernate.cache.provider_class">${hibernate.cache.provider}</prop>
133 <prop key="hibernate.cache.region.factory_class">${hibernate.cache.region.factory}</prop>
margaretha6ad08b42018-08-22 18:33:54 +0200134 <prop key="hibernate.jdbc.time_zone">${hibernate.jdbc.time_zone}</prop>
margarethaade7d4a2017-07-20 19:53:35 +0200135 <!-- <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" />
margaretha35e1ca22023-11-16 22:00:01 +0100142 <bean id="transactionManager"
143 class="org.springframework.orm.jpa.JpaTransactionManager">
144 <property name="entityManagerFactory"
145 ref="entityManagerFactory" />
margaretha62055f72017-04-11 19:17:43 +0200146 </bean>
Michael Hanle4fc7752016-02-17 11:41:18 +0100147
margarethaade7d4a2017-07-20 19:53:35 +0200148 <bean id="transactionTemplate"
149 class="org.springframework.transaction.support.TransactionTemplate">
150 <constructor-arg ref="transactionManager" />
151 </bean>
152
153 <!-- Data access objects -->
margaretha34954472018-10-24 20:05:17 +0200154 <bean id="adminDao" class="de.ids_mannheim.korap.dao.AdminDaoImpl" />
margaretha35e1ca22023-11-16 22:00:01 +0100155 <bean id="resourceDao"
156 class="de.ids_mannheim.korap.dao.ResourceDao" />
157 <bean id="accessScopeDao"
158 class="de.ids_mannheim.korap.oauth2.dao.AccessScopeDao" />
159 <bean id="authorizationDao"
160 class="de.ids_mannheim.korap.oauth2.dao.CachedAuthorizationDaoImpl" />
161
margaretha34954472018-10-24 20:05:17 +0200162 <!-- Services -->
margaretha35e1ca22023-11-16 22:00:01 +0100163 <bean id="scopeService"
164 class="de.ids_mannheim.korap.oauth2.service.OAuth2ScopeServiceImpl" />
165
margaretha35e1ca22023-11-16 22:00:01 +0100166 <bean id="initializator"
167 class="de.ids_mannheim.korap.init.Initializator"
margaretha1b320452018-08-02 16:56:25 +0200168 init-method="initTest">
margarethab4ce6602018-04-26 20:23:57 +0200169 </bean>
170
margaretha6c2a20f2017-07-24 15:33:01 +0200171 <!-- Krill -->
margaretha35e1ca22023-11-16 22:00:01 +0100172 <bean id="search_krill"
173 class="de.ids_mannheim.korap.web.SearchKrill">
margaretha58e18632018-02-15 13:04:42 +0100174 <constructor-arg value="${krill.indexDir}" />
margaretha6c2a20f2017-07-24 15:33:01 +0200175 </bean>
176
margaretha6cd27f32019-01-24 14:47:47 +0100177 <!-- Validator -->
margaretha35e1ca22023-11-16 22:00:01 +0100178 <bean id="validator"
179 class="de.ids_mannheim.korap.validator.ApacheValidator" />
180
margaretha31a9f522018-04-03 20:40:45 +0200181 <!-- URLValidator -->
margaretha35e1ca22023-11-16 22:00:01 +0100182 <bean id="redirectURIValidator"
183 class="org.apache.commons.validator.routines.UrlValidator">
margarethae4034a82018-07-02 14:46:59 +0200184 <constructor-arg value="http,https" index="0" />
margaretha35e1ca22023-11-16 22:00:01 +0100185 <constructor-arg index="1" type="long"
186 value="#{T(org.apache.commons.validator.routines.UrlValidator).ALLOW_LOCAL_URLS +
187 T(org.apache.commons.validator.routines.UrlValidator).NO_FRAGMENTS}" />
margaretha31a9f522018-04-03 20:40:45 +0200188 </bean>
margaretha35e1ca22023-11-16 22:00:01 +0100189 <bean id="urlValidator"
190 class="org.apache.commons.validator.routines.UrlValidator">
margarethad7cab212018-07-02 19:01:43 +0200191 <constructor-arg value="http,https" />
192 </bean>
margaretha56e8e552017-12-05 16:31:21 +0100193
margaretha4fa4b062019-01-28 19:43:30 +0100194 <!-- Rewrite -->
margaretha35e1ca22023-11-16 22:00:01 +0100195 <bean id="foundryRewrite"
196 class="de.ids_mannheim.korap.rewrite.FoundryRewrite" />
197 <bean id="collectionRewrite"
198 class="de.ids_mannheim.korap.rewrite.CollectionRewrite" />
margaretha35e1ca22023-11-16 22:00:01 +0100199 <bean id="virtualCorpusRewrite"
200 class="de.ids_mannheim.korap.rewrite.VirtualCorpusRewrite" />
margaretha35e1ca22023-11-16 22:00:01 +0100201 <bean id="queryReferenceRewrite"
202 class="de.ids_mannheim.korap.rewrite.QueryReferenceRewrite" />
203
margaretha4fa4b062019-01-28 19:43:30 +0100204 <util:list id="rewriteTasks"
205 value-type="de.ids_mannheim.korap.rewrite.RewriteTask">
margaretha4fa4b062019-01-28 19:43:30 +0100206 <ref bean="foundryRewrite" />
207 <ref bean="collectionRewrite" />
208 <ref bean="virtualCorpusRewrite" />
Akronbee031a2020-10-29 16:58:14 +0100209 <ref bean="queryReferenceRewrite" />
margaretha4fa4b062019-01-28 19:43:30 +0100210 </util:list>
margaretha35e1ca22023-11-16 22:00:01 +0100211
212 <bean id="rewriteHandler"
213 class="de.ids_mannheim.korap.rewrite.RewriteHandler">
214 <constructor-arg ref="rewriteTasks" />
margaretha56e8e552017-12-05 16:31:21 +0100215 </bean>
216
margaretha35e1ca22023-11-16 22:00:01 +0100217 <bean id="kustvaktResponseHandler"
218 class="de.ids_mannheim.korap.web.KustvaktResponseHandler">
margaretha05122312018-04-16 15:01:34 +0200219 </bean>
margarethafb027f92018-04-23 20:00:13 +0200220
221 <!-- OAuth -->
margaretha35e1ca22023-11-16 22:00:01 +0100222 <bean id="oauth2ResponseHandler"
223 class="de.ids_mannheim.korap.web.OAuth2ResponseHandler">
margaretha58e18632018-02-15 13:04:42 +0100224 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +0100225
margaretha35e1ca22023-11-16 22:00:01 +0100226 <bean name="kustvakt_encryption"
227 class="de.ids_mannheim.korap.encryption.KustvaktEncryption">
margaretha62055f72017-04-11 19:17:43 +0200228 <constructor-arg ref="kustvakt_config" />
229 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +0100230
margaretha62055f72017-04-11 19:17:43 +0200231 <!-- authentication providers to use -->
margaretha58e18632018-02-15 13:04:42 +0100232 <bean id="basic_auth"
233 class="de.ids_mannheim.korap.authentication.BasicAuthentication" />
Michael Hanlbd852b82015-11-18 22:17:00 +0100234
235
margaretha62055f72017-04-11 19:17:43 +0200236 <bean id="session_auth"
margaretha139d0f72017-11-14 18:56:22 +0100237 class="de.ids_mannheim.korap.authentication.SessionAuthentication">
margaretha35e1ca22023-11-16 22:00:01 +0100238 <constructor-arg
239 type="de.ids_mannheim.korap.config.KustvaktConfiguration"
margaretha62055f72017-04-11 19:17:43 +0200240 ref="kustvakt_config" />
margaretha35e1ca22023-11-16 22:00:01 +0100241 <constructor-arg
242 type="de.ids_mannheim.korap.interfaces.EncryptionIface"
margaretha62055f72017-04-11 19:17:43 +0200243 ref="kustvakt_encryption" />
244 </bean>
margarethae4034a82018-07-02 14:46:59 +0200245
margarethacf306d32018-05-30 19:45:35 +0200246 <bean id="oauth2_auth"
247 class="de.ids_mannheim.korap.authentication.OAuth2Authentication" />
margarethae4034a82018-07-02 14:46:59 +0200248
Michael Hanlbd852b82015-11-18 22:17:00 +0100249
margaretha62055f72017-04-11 19:17:43 +0200250 <util:list id="kustvakt_authproviders"
251 value-type="de.ids_mannheim.korap.interfaces.AuthenticationIface">
252 <ref bean="basic_auth" />
253 <ref bean="session_auth" />
margarethacf306d32018-05-30 19:45:35 +0200254 <ref bean="oauth2_auth" />
margaretha62055f72017-04-11 19:17:43 +0200255 </util:list>
Michael Hanlbd852b82015-11-18 22:17:00 +0100256
margaretha62055f72017-04-11 19:17:43 +0200257 <!-- specify type for constructor argument -->
margaretha34954472018-10-24 20:05:17 +0200258 <bean id="authenticationManager"
margaretha139d0f72017-11-14 18:56:22 +0100259 class="de.ids_mannheim.korap.authentication.KustvaktAuthenticationManager">
margaretha35e1ca22023-11-16 22:00:01 +0100260 <constructor-arg
261 type="de.ids_mannheim.korap.interfaces.EncryptionIface"
margaretha62055f72017-04-11 19:17:43 +0200262 ref="kustvakt_encryption" />
263 <constructor-arg ref="kustvakt_config" />
margaretha62055f72017-04-11 19:17:43 +0200264 <!-- inject authentication providers to use -->
265 <property name="providers" ref="kustvakt_authproviders" />
266 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +0100267
margaretha62055f72017-04-11 19:17:43 +0200268 <!-- todo: if db interfaces not loaded via spring, does transaction even
269 work then? -->
270 <!-- the transactional advice (i.e. what 'happens'; see the <aop:advisor/>
271 bean below) -->
272 <tx:advice id="txAdvice" transaction-manager="txManager">
273 <!-- the transactional semantics... -->
274 <tx:attributes>
275 <!-- all methods starting with 'get' are read-only -->
margaretha35e1ca22023-11-16 22:00:01 +0100276 <tx:method name="get*" read-only="true"
277 rollback-for="KorAPException" />
margaretha62055f72017-04-11 19:17:43 +0200278 <!-- other methods use the default transaction settings (see below) -->
279 <tx:method name="*" rollback-for="KorAPException" />
280 </tx:attributes>
281 </tx:advice>
Michael Hanlbd852b82015-11-18 22:17:00 +0100282
margaretha62055f72017-04-11 19:17:43 +0200283 <!-- ensure that the above transactional advice runs for any execution of
284 an operation defined by the service interface -->
285 <aop:config>
286 <aop:pointcut id="service"
287 expression="execution(* de.ids_mannheim.korap.interfaces.db.*.*(..))" />
288 <aop:advisor advice-ref="txAdvice" pointcut-ref="service" />
289 </aop:config>
Michael Hanlbd852b82015-11-18 22:17:00 +0100290
margaretha62055f72017-04-11 19:17:43 +0200291 <!-- similarly, don't forget the PlatformTransactionManager -->
292 <bean id="txManager"
293 class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
294 <property name="dataSource" ref="dataSource" />
295 </bean>
margaretha58e18632018-02-15 13:04:42 +0100296
297 <!-- mail -->
margaretha35e1ca22023-11-16 22:00:01 +0100298 <bean id="authenticator"
299 class="de.ids_mannheim.korap.service.MailAuthenticator">
margarethafb027f92018-04-23 20:00:13 +0200300 <constructor-arg index="0" value="${mail.username}" />
301 <constructor-arg index="1" value="${mail.password}" />
margarethaaecee1b2018-02-20 14:44:21 +0100302 </bean>
margaretha35e1ca22023-11-16 22:00:01 +0100303 <bean id="smtpSession" class="jakarta.mail.Session"
304 factory-method="getInstance">
margarethaaecee1b2018-02-20 14:44:21 +0100305 <constructor-arg index="0">
306 <props>
307 <prop key="mail.smtp.submitter">${mail.username}</prop>
308 <prop key="mail.smtp.auth">${mail.auth}</prop>
309 <prop key="mail.smtp.host">${mail.host}</prop>
310 <prop key="mail.smtp.port">${mail.port}</prop>
311 <prop key="mail.smtp.starttls.enable">${mail.starttls.enable}</prop>
312 <prop key="mail.smtp.connectiontimeout">${mail.connectiontimeout}</prop>
313 </props>
314 </constructor-arg>
margarethafb027f92018-04-23 20:00:13 +0200315 <constructor-arg index="1" ref="authenticator" />
margaretha58e18632018-02-15 13:04:42 +0100316 </bean>
margaretha35e1ca22023-11-16 22:00:01 +0100317 <bean id="mailSender"
318 class="org.springframework.mail.javamail.JavaMailSenderImpl">
margaretha3a966022024-06-13 13:51:50 +0200319 <property name="username" value="${mail.username}" />
320 <property name="password" value="${mail.password}" />
margaretha58e18632018-02-15 13:04:42 +0100321 <property name="session" ref="smtpSession" />
322 </bean>
margaretha35e1ca22023-11-16 22:00:01 +0100323 <bean id="velocityEngine"
324 class="org.apache.velocity.app.VelocityEngine">
margaretha58e18632018-02-15 13:04:42 +0100325 <constructor-arg index="0">
326 <props>
327 <prop key="resource.loader">class</prop>
328 <prop key="class.resource.loader.class">org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
329 </prop>
330 </props>
331 </constructor-arg>
margarethaaecee1b2018-02-20 14:44:21 +0100332 </bean>
Akronbee031a2020-10-29 16:58:14 +0100333</beans>