blob: 291271c8723fa13b348ad49efe93eda612c189b6 [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>
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>
margarethaaecee1b2018-02-20 14:44:21 +010041 <value>classpath:properties/jdbc.properties</value>
margarethaea68a0a2017-09-21 03:09:49 +020042 <value>file:./jdbc.properties</value>
margarethaaecee1b2018-02-20 14:44:21 +010043 <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>
margaretha0e8f4e72018-04-05 14:11:52 +020046
margarethaade7d4a2017-07-20 19:53:35 +020047 <value>classpath:kustvakt.conf</value>
margaretha14503cd2017-09-08 15:35:24 +020048 <value>file:./kustvakt.conf</value>
margaretha543f2002017-07-14 00:27:15 +020049 </array>
50 </property>
51 </bean>
52
margaretha35e1ca22023-11-16 22:00:01 +010053 <!-- <bean id='cacheManager' class='org.springframework.cache.ehcache.EhCacheCacheManager'
54 p:cacheManager-ref='ehcache' /> <bean id='ehcache' class='org.springframework.cache.ehcache.EhCacheManagerFactoryBean'
55 p:configLocation='classpath:ehcache.xml' p:shared='true' /> -->
margaretha543f2002017-07-14 00:27:15 +020056 <!--class="org.apache.commons.dbcp2.BasicDataSource" -->
57 <!-- org.springframework.jdbc.datasource.SingleConnectionDataSource -->
margaretha35e1ca22023-11-16 22:00:01 +010058 <bean id="dataSource"
59 class="org.apache.commons.dbcp2.BasicDataSource" lazy-init="true">
60 <property name="driverClassName"
61 value="${jdbc.driverClassName}" />
margaretha543f2002017-07-14 00:27:15 +020062 <property name="url" value="${jdbc.url}" />
63 <property name="username" value="${jdbc.username}" />
64 <property name="password" value="${jdbc.password}" />
65 <!-- relevant for single connection datasource and sqlite -->
66 <!-- <property name="suppressClose"> <value>true</value> </property> -->
67 <!--<property name="initialSize" value="2"/> -->
68 <property name="maxTotal" value="4" />
69 <property name="maxIdle" value="2" />
70 <property name="minIdle" value="1" />
margaretha45211af2018-08-28 12:49:07 +020071 <property name="maxWaitMillis" value="-1" />
margaretha543f2002017-07-14 00:27:15 +020072 <!--<property name="poolPreparedStatements" value="true"/> -->
73 </bean>
margaretha35e1ca22023-11-16 22:00:01 +010074
75 <bean id="c3p0DataSource"
76 class="com.mchange.v2.c3p0.ComboPooledDataSource"
margaretha45211af2018-08-28 12:49:07 +020077 destroy-method="close" lazy-init="true">
78 <property name="driverClass" value="${jdbc.driverClassName}" />
79 <property name="jdbcUrl" value="${jdbc.url}" />
80 <property name="user" value="${jdbc.username}" />
81 <property name="password" value="${jdbc.password}" />
82 <property name="maxPoolSize" value="4" />
83 <property name="minPoolSize" value="1" />
84 <property name="maxStatements" value="100" />
85 <!-- <property name="testConnectionOnCheckOut" value="true" /> -->
86 <property name="idleConnectionTestPeriod" value="60" />
87 <property name="testConnectionOnCheckin" value="true" />
88 </bean>
margaretha543f2002017-07-14 00:27:15 +020089
margaretha543f2002017-07-14 00:27:15 +020090 <!-- to configure database for sqlite, mysql, etc. migrations -->
margaretha35e1ca22023-11-16 22:00:01 +010091 <bean id="flywayConfig"
92 class="org.flywaydb.core.api.configuration.ClassicConfiguration">
margarethaf6d5a822017-10-19 19:51:20 +020093 <property name="baselineOnMigrate" value="true" />
margarethaecbe72d2017-07-26 17:13:32 +020094 <!-- <property name="validateOnMigrate" value="false" /> -->
95 <!-- <property name="cleanOnValidationError" value="true" /> -->
margaretha35e1ca22023-11-16 22:00:01 +010096 <property name="locations"
97 value="#{'${jdbc.schemaPath}'.split(',')}" />
margaretha8fe51e92023-09-20 11:22:20 +020098 <property name="dataSource" ref="dataSource" />
margaretha8514d782018-08-28 17:36:56 +020099 <!-- <property name="dataSource" ref="c3p0DataSource" /> -->
margarethad66a6832022-03-03 08:47:13 +0100100 <property name="outOfOrder" value="true" />
margaretha543f2002017-07-14 00:27:15 +0200101 </bean>
margaretha35e1ca22023-11-16 22:00:01 +0100102
103 <bean id="flyway" class="org.flywaydb.core.Flyway"
104 init-method="migrate">
105 <constructor-arg ref="flywayConfig" />
margarethafcf8bd92021-01-14 10:55:53 +0100106 </bean>
margaretha0e8f4e72018-04-05 14:11:52 +0200107
margaretha543f2002017-07-14 00:27:15 +0200108 <bean id="entityManagerFactory"
margarethafcf8bd92021-01-14 10:55:53 +0100109 class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
110 depends-on="flyway">
margaretha8fe51e92023-09-20 11:22:20 +0200111 <property name="dataSource" ref="dataSource" />
margaretha8514d782018-08-28 17:36:56 +0200112 <!-- <property name="dataSource" ref="c3p0DataSource" /> -->
margaretha0e8f4e72018-04-05 14:11:52 +0200113
margarethaa452c5e2018-04-25 22:48:09 +0200114 <property name="packagesToScan">
115 <array>
margaretha5b708792023-05-12 16:55:29 +0200116 <value>de.ids_mannheim.korap.core.entity</value>
margarethaa452c5e2018-04-25 22:48:09 +0200117 <value>de.ids_mannheim.korap.entity</value>
118 <value>de.ids_mannheim.korap.oauth2.entity</value>
119 </array>
120 </property>
margaretha543f2002017-07-14 00:27:15 +0200121 <property name="jpaVendorAdapter">
122 <bean id="jpaVendorAdapter"
123 class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
margaretha35e1ca22023-11-16 22:00:01 +0100124 <property name="databasePlatform"
125 value="${hibernate.dialect}" />
margaretha543f2002017-07-14 00:27:15 +0200126 </bean>
127 </property>
128 <property name="jpaProperties">
129 <props>
130 <prop key="hibernate.dialect">${hibernate.dialect}</prop>
131 <prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop>
132 <prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
133 <prop key="hibernate.cache.use_query_cache">${hibernate.cache.use_query_cache}</prop>
134 <prop key="hibernate.cache.use_second_level_cache">${hibernate.cache.use_second_level_cache}
135 </prop>
136 <prop key="hibernate.cache.provider_class">${hibernate.cache.provider}</prop>
137 <prop key="hibernate.cache.region.factory_class">${hibernate.cache.region.factory}</prop>
margaretha6ad08b42018-08-22 18:33:54 +0200138 <prop key="hibernate.jdbc.time_zone">${hibernate.jdbc.time_zone}</prop>
margaretha543f2002017-07-14 00:27:15 +0200139 </props>
140 </property>
141 </bean>
142
143 <tx:annotation-driven proxy-target-class="true"
144 transaction-manager="transactionManager" />
margaretha0e8f4e72018-04-05 14:11:52 +0200145
margaretha35e1ca22023-11-16 22:00:01 +0100146 <bean id="transactionManager"
147 class="org.springframework.orm.jpa.JpaTransactionManager">
148 <property name="entityManagerFactory"
149 ref="entityManagerFactory" />
margaretha543f2002017-07-14 00:27:15 +0200150 </bean>
151
152 <bean id="transactionTemplate"
153 class="org.springframework.transaction.support.TransactionTemplate">
154 <constructor-arg ref="transactionManager" />
155 </bean>
156
margarethaade7d4a2017-07-20 19:53:35 +0200157 <!-- Data access objects -->
margaretha34954472018-10-24 20:05:17 +0200158 <bean id="adminDao" class="de.ids_mannheim.korap.dao.AdminDaoImpl" />
margaretha35e1ca22023-11-16 22:00:01 +0100159 <bean id="authorizationDao"
160 class="de.ids_mannheim.korap.oauth2.dao.CachedAuthorizationDaoImpl" />
margarethab4ce6602018-04-26 20:23:57 +0200161
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
margarethab4ce6602018-04-26 20:23:57 +0200166 <!-- props are injected from default-config.xml -->
margaretha35e1ca22023-11-16 22:00:01 +0100167 <bean id="kustvakt_config"
168 class="de.ids_mannheim.korap.config.FullConfiguration">
margarethab4ce6602018-04-26 20:23:57 +0200169 <constructor-arg name="properties" ref="props" />
170 </bean>
171
margaretha35e1ca22023-11-16 22:00:01 +0100172 <bean id="initializator"
173 class="de.ids_mannheim.korap.init.Initializator" init-method="init">
margarethab4ce6602018-04-26 20:23:57 +0200174 </bean>
margaretha35e1ca22023-11-16 22:00:01 +0100175
margarethaade7d4a2017-07-20 19:53:35 +0200176 <!-- Krill -->
margaretha35e1ca22023-11-16 22:00:01 +0100177 <bean id="search_krill"
178 class="de.ids_mannheim.korap.web.SearchKrill">
margaretha0e8f4e72018-04-05 14:11:52 +0200179 <constructor-arg value="${krill.indexDir}" />
margaretha543f2002017-07-14 00:27:15 +0200180 </bean>
margaretha35e1ca22023-11-16 22:00:01 +0100181
margaretha6cd27f32019-01-24 14:47:47 +0100182 <!-- Validator -->
margaretha35e1ca22023-11-16 22:00:01 +0100183 <bean id="validator"
184 class="de.ids_mannheim.korap.validator.ApacheValidator" />
margaretha543f2002017-07-14 00:27:15 +0200185
margaretha31a9f522018-04-03 20:40:45 +0200186 <!-- URLValidator -->
margaretha35e1ca22023-11-16 22:00:01 +0100187 <bean id="redirectURIValidator"
188 class="org.apache.commons.validator.routines.UrlValidator">
margarethae4034a82018-07-02 14:46:59 +0200189 <constructor-arg value="http,https" index="0" />
margaretha35e1ca22023-11-16 22:00:01 +0100190 <constructor-arg index="1" type="long"
191 value="#{T(org.apache.commons.validator.routines.UrlValidator).ALLOW_LOCAL_URLS +
192 T(org.apache.commons.validator.routines.UrlValidator).NO_FRAGMENTS}" />
193
194 <!-- <constructor-arg index="1" type="long"> <util:constant static-field="org.apache.commons.validator.routines.UrlValidator.NO_FRAGMENTS"
195 /> </constructor-arg> -->
margarethaa0486272018-04-12 19:59:31 +0200196 </bean>
margaretha35e1ca22023-11-16 22:00:01 +0100197 <bean id="urlValidator"
198 class="org.apache.commons.validator.routines.UrlValidator">
margarethad7cab212018-07-02 19:01:43 +0200199 <constructor-arg value="http,https" />
200 </bean>
margaretha35e1ca22023-11-16 22:00:01 +0100201
margaretha34954472018-10-24 20:05:17 +0200202 <!-- Rewrite -->
margaretha35e1ca22023-11-16 22:00:01 +0100203 <bean id="foundryRewrite"
204 class="de.ids_mannheim.korap.rewrite.FoundryRewrite" />
205 <bean id="collectionRewrite"
206 class="de.ids_mannheim.korap.rewrite.CollectionRewrite" />
207 <bean id="virtualCorpusRewrite"
208 class="de.ids_mannheim.korap.rewrite.VirtualCorpusRewrite" />
209 <bean id="queryReferenceRewrite"
210 class="de.ids_mannheim.korap.rewrite.QueryReferenceRewrite" />
211
margaretha4fa4b062019-01-28 19:43:30 +0100212 <util:list id="rewriteTasks"
213 value-type="de.ids_mannheim.korap.rewrite.RewriteTask">
214 <ref bean="foundryRewrite" />
215 <ref bean="collectionRewrite" />
216 <ref bean="virtualCorpusRewrite" />
margaretha35e1ca22023-11-16 22:00:01 +0100217 <ref bean="queryReferenceRewrite" />
margaretha4fa4b062019-01-28 19:43:30 +0100218 </util:list>
margaretha35e1ca22023-11-16 22:00:01 +0100219
220 <bean id="rewriteHandler"
221 class="de.ids_mannheim.korap.rewrite.RewriteHandler">
222 <constructor-arg ref="rewriteTasks" />
margaretha56e8e552017-12-05 16:31:21 +0100223 </bean>
224
margaretha35e1ca22023-11-16 22:00:01 +0100225 <bean id="kustvaktResponseHandler"
226 class="de.ids_mannheim.korap.web.KustvaktResponseHandler">
margaretha0e8f4e72018-04-05 14:11:52 +0200227 </bean>
margarethaa452c5e2018-04-25 22:48:09 +0200228
margarethafb027f92018-04-23 20:00:13 +0200229 <!-- OAuth -->
margaretha35e1ca22023-11-16 22:00:01 +0100230 <bean id="oauth2ResponseHandler"
231 class="de.ids_mannheim.korap.web.OAuth2ResponseHandler">
margaretha05122312018-04-16 15:01:34 +0200232 </bean>
margarethaa452c5e2018-04-25 22:48:09 +0200233
margaretha35e1ca22023-11-16 22:00:01 +0100234 <bean name="kustvakt_encryption"
235 class="de.ids_mannheim.korap.encryption.KustvaktEncryption">
margaretha543f2002017-07-14 00:27:15 +0200236 <constructor-arg ref="kustvakt_config" />
237 </bean>
238
239 <!-- authentication providers to use -->
margaretha543f2002017-07-14 00:27:15 +0200240
margaretha35e1ca22023-11-16 22:00:01 +0100241 <!-- <bean id="session_auth" class="de.ids_mannheim.korap.authentication.SessionAuthentication">
242 <constructor-arg type="de.ids_mannheim.korap.config.KustvaktConfiguration"
243 ref="kustvakt_config" /> <constructor-arg type="de.ids_mannheim.korap.interfaces.EncryptionIface"
244 ref="kustvakt_encryption" /> </bean> -->
Michael Hanlca740d72015-06-16 10:04:58 +0200245
margarethacf306d32018-05-30 19:45:35 +0200246 <bean id="oauth2_auth"
247 class="de.ids_mannheim.korap.authentication.OAuth2Authentication" />
margaretha35e1ca22023-11-16 22:00:01 +0100248
margaretha543f2002017-07-14 00:27:15 +0200249 <util:list id="kustvakt_authproviders"
250 value-type="de.ids_mannheim.korap.interfaces.AuthenticationIface">
margarethaac49b502023-04-18 11:01:48 +0200251 <!-- <ref bean="session_auth" /> -->
margarethacf306d32018-05-30 19:45:35 +0200252 <ref bean="oauth2_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 <!-- specify type for constructor argument -->
margaretha34954472018-10-24 20:05:17 +0200257 <bean id="authenticationManager"
margaretha139d0f72017-11-14 18:56:22 +0100258 class="de.ids_mannheim.korap.authentication.KustvaktAuthenticationManager">
margaretha35e1ca22023-11-16 22:00:01 +0100259 <constructor-arg
260 type="de.ids_mannheim.korap.interfaces.EncryptionIface"
margaretha543f2002017-07-14 00:27:15 +0200261 ref="kustvakt_encryption" />
262 <constructor-arg ref="kustvakt_config" />
margaretha543f2002017-07-14 00:27:15 +0200263 <!-- inject authentication providers to use -->
264 <property name="providers" ref="kustvakt_authproviders" />
265 </bean>
margaretha35e1ca22023-11-16 22:00:01 +0100266
margaretha543f2002017-07-14 00:27:15 +0200267 <!-- todo: if db interfaces not loaded via spring, does transaction even
268 work then? -->
269 <!-- the transactional advice (i.e. what 'happens'; see the <aop:advisor/>
270 bean below) -->
271 <tx:advice id="txAdvice" transaction-manager="txManager">
272 <!-- the transactional semantics... -->
273 <tx:attributes>
274 <!-- all methods starting with 'get' are read-only -->
margaretha35e1ca22023-11-16 22:00:01 +0100275 <tx:method name="get*" read-only="true"
276 rollback-for="KorAPException" />
margaretha543f2002017-07-14 00:27:15 +0200277 <!-- other methods use the default transaction settings (see below) -->
278 <tx:method name="*" rollback-for="KorAPException" />
279 </tx:attributes>
280 </tx:advice>
Michael Hanldaf86602016-05-12 14:31:52 +0200281
margaretha543f2002017-07-14 00:27:15 +0200282 <!-- ensure that the above transactional advice runs for any execution of
283 an operation defined by the service interface -->
284 <aop:config>
285 <aop:pointcut id="service"
286 expression="execution(* de.ids_mannheim.korap.interfaces.db.*.*(..))" />
287 <aop:advisor advice-ref="txAdvice" pointcut-ref="service" />
288 </aop:config>
Michael Hanlf8fcc7a2016-06-03 17:41:07 +0200289
margaretha543f2002017-07-14 00:27:15 +0200290 <!-- similarly, don't forget the PlatformTransactionManager -->
291 <bean id="txManager"
292 class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
margaretha09a9a582024-01-11 21:48:20 +0100293 <property name="dataSource" ref="dataSource" />
margaretha8514d782018-08-28 17:36:56 +0200294 <!-- <property name="dataSource" ref="c3p0DataSource" /> -->
margaretha543f2002017-07-14 00:27:15 +0200295 </bean>
margaretha0e8f4e72018-04-05 14:11:52 +0200296
margarethac9f1dfa2018-02-07 17:50:33 +0100297 <!-- mail -->
margaretha35e1ca22023-11-16 22:00:01 +0100298 <bean id="authenticator"
299 class="de.ids_mannheim.korap.service.MailAuthenticator">
margaretha0e8f4e72018-04-05 14:11:52 +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>
margaretha0e8f4e72018-04-05 14:11:52 +0200315 <constructor-arg index="1" ref="authenticator" />
margarethac9f1dfa2018-02-07 17:50:33 +0100316 </bean>
margaretha35e1ca22023-11-16 22:00:01 +0100317 <bean id="mailSender"
318 class="org.springframework.mail.javamail.JavaMailSenderImpl">
margarethaaecee1b2018-02-20 14:44:21 +0100319 <property name="username" value="${mail.username}" />
margaretha0e8f4e72018-04-05 14:11:52 +0200320 <property name="password" value="${mail.password}" />
margarethac9f1dfa2018-02-07 17:50:33 +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">
margarethac9f1dfa2018-02-07 17:50:33 +0100325 <constructor-arg index="0">
326 <props>
327 <prop key="resource.loader">class</prop>
margaretha0e8f4e72018-04-05 14:11:52 +0200328 <prop key="class.resource.loader.class">org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
329 </prop>
margarethac9f1dfa2018-02-07 17:50:33 +0100330 </props>
331 </constructor-arg>
margarethaaecee1b2018-02-20 14:44:21 +0100332 </bean>
Akronbee031a2020-10-29 16:58:14 +0100333</beans>