blob: 0e122147f370abf219ed28b954960fe43f7b9a6b [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="dataSource"
57 class="org.apache.commons.dbcp2.BasicDataSource" lazy-init="true">
58 <property name="driverClassName"
59 value="${jdbc.driverClassName}" />
margaretha543f2002017-07-14 00:27:15 +020060 <property name="url" value="${jdbc.url}" />
61 <property name="username" value="${jdbc.username}" />
62 <property name="password" value="${jdbc.password}" />
margaretha543f2002017-07-14 00:27:15 +020063 <property name="maxTotal" value="4" />
64 <property name="maxIdle" value="2" />
65 <property name="minIdle" value="1" />
margaretha45211af2018-08-28 12:49:07 +020066 <property name="maxWaitMillis" value="-1" />
margaretha543f2002017-07-14 00:27:15 +020067 <!--<property name="poolPreparedStatements" value="true"/> -->
68 </bean>
margaretha35e1ca22023-11-16 22:00:01 +010069
70 <bean id="c3p0DataSource"
71 class="com.mchange.v2.c3p0.ComboPooledDataSource"
margaretha45211af2018-08-28 12:49:07 +020072 destroy-method="close" lazy-init="true">
73 <property name="driverClass" value="${jdbc.driverClassName}" />
74 <property name="jdbcUrl" value="${jdbc.url}" />
75 <property name="user" value="${jdbc.username}" />
76 <property name="password" value="${jdbc.password}" />
77 <property name="maxPoolSize" value="4" />
78 <property name="minPoolSize" value="1" />
79 <property name="maxStatements" value="100" />
80 <!-- <property name="testConnectionOnCheckOut" value="true" /> -->
81 <property name="idleConnectionTestPeriod" value="60" />
82 <property name="testConnectionOnCheckin" value="true" />
83 </bean>
margaretha543f2002017-07-14 00:27:15 +020084
margaretha543f2002017-07-14 00:27:15 +020085 <!-- to configure database for sqlite, mysql, etc. migrations -->
margaretha35e1ca22023-11-16 22:00:01 +010086 <bean id="flywayConfig"
87 class="org.flywaydb.core.api.configuration.ClassicConfiguration">
margarethaf6d5a822017-10-19 19:51:20 +020088 <property name="baselineOnMigrate" value="true" />
margarethaecbe72d2017-07-26 17:13:32 +020089 <!-- <property name="validateOnMigrate" value="false" /> -->
90 <!-- <property name="cleanOnValidationError" value="true" /> -->
margaretha35e1ca22023-11-16 22:00:01 +010091 <property name="locations"
92 value="#{'${jdbc.schemaPath}'.split(',')}" />
margaretha8fe51e92023-09-20 11:22:20 +020093 <property name="dataSource" ref="dataSource" />
margaretha8514d782018-08-28 17:36:56 +020094 <!-- <property name="dataSource" ref="c3p0DataSource" /> -->
margarethad66a6832022-03-03 08:47:13 +010095 <property name="outOfOrder" value="true" />
margaretha543f2002017-07-14 00:27:15 +020096 </bean>
margaretha35e1ca22023-11-16 22:00:01 +010097
98 <bean id="flyway" class="org.flywaydb.core.Flyway"
99 init-method="migrate">
100 <constructor-arg ref="flywayConfig" />
margarethafcf8bd92021-01-14 10:55:53 +0100101 </bean>
margaretha0e8f4e72018-04-05 14:11:52 +0200102
margaretha543f2002017-07-14 00:27:15 +0200103 <bean id="entityManagerFactory"
margarethafcf8bd92021-01-14 10:55:53 +0100104 class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
105 depends-on="flyway">
margaretha8fe51e92023-09-20 11:22:20 +0200106 <property name="dataSource" ref="dataSource" />
margaretha8514d782018-08-28 17:36:56 +0200107 <!-- <property name="dataSource" ref="c3p0DataSource" /> -->
margaretha0e8f4e72018-04-05 14:11:52 +0200108
margarethaa452c5e2018-04-25 22:48:09 +0200109 <property name="packagesToScan">
110 <array>
margaretha5b708792023-05-12 16:55:29 +0200111 <value>de.ids_mannheim.korap.core.entity</value>
margarethaa452c5e2018-04-25 22:48:09 +0200112 <value>de.ids_mannheim.korap.entity</value>
113 <value>de.ids_mannheim.korap.oauth2.entity</value>
114 </array>
115 </property>
margaretha543f2002017-07-14 00:27:15 +0200116 <property name="jpaVendorAdapter">
117 <bean id="jpaVendorAdapter"
118 class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
margaretha35e1ca22023-11-16 22:00:01 +0100119 <property name="databasePlatform"
120 value="${hibernate.dialect}" />
margaretha543f2002017-07-14 00:27:15 +0200121 </bean>
122 </property>
123 <property name="jpaProperties">
124 <props>
125 <prop key="hibernate.dialect">${hibernate.dialect}</prop>
126 <prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop>
127 <prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
128 <prop key="hibernate.cache.use_query_cache">${hibernate.cache.use_query_cache}</prop>
129 <prop key="hibernate.cache.use_second_level_cache">${hibernate.cache.use_second_level_cache}
130 </prop>
131 <prop key="hibernate.cache.provider_class">${hibernate.cache.provider}</prop>
132 <prop key="hibernate.cache.region.factory_class">${hibernate.cache.region.factory}</prop>
margaretha6ad08b42018-08-22 18:33:54 +0200133 <prop key="hibernate.jdbc.time_zone">${hibernate.jdbc.time_zone}</prop>
margaretha543f2002017-07-14 00:27:15 +0200134 </props>
135 </property>
136 </bean>
137
138 <tx:annotation-driven proxy-target-class="true"
139 transaction-manager="transactionManager" />
margaretha0e8f4e72018-04-05 14:11:52 +0200140
margaretha35e1ca22023-11-16 22:00:01 +0100141 <bean id="transactionManager"
142 class="org.springframework.orm.jpa.JpaTransactionManager">
143 <property name="entityManagerFactory"
144 ref="entityManagerFactory" />
margaretha543f2002017-07-14 00:27:15 +0200145 </bean>
146
147 <bean id="transactionTemplate"
148 class="org.springframework.transaction.support.TransactionTemplate">
149 <constructor-arg ref="transactionManager" />
150 </bean>
151
margarethaade7d4a2017-07-20 19:53:35 +0200152 <!-- Data access objects -->
margaretha34954472018-10-24 20:05:17 +0200153 <bean id="adminDao" class="de.ids_mannheim.korap.dao.AdminDaoImpl" />
margaretha35e1ca22023-11-16 22:00:01 +0100154 <bean id="authorizationDao"
155 class="de.ids_mannheim.korap.oauth2.dao.CachedAuthorizationDaoImpl" />
margarethab4ce6602018-04-26 20:23:57 +0200156
margaretha34954472018-10-24 20:05:17 +0200157 <!-- Services -->
margaretha35e1ca22023-11-16 22:00:01 +0100158 <bean id="scopeService"
159 class="de.ids_mannheim.korap.oauth2.service.OAuth2ScopeServiceImpl" />
160
margarethab4ce6602018-04-26 20:23:57 +0200161 <!-- props are injected from default-config.xml -->
margaretha35e1ca22023-11-16 22:00:01 +0100162 <bean id="kustvakt_config"
163 class="de.ids_mannheim.korap.config.FullConfiguration">
margarethab4ce6602018-04-26 20:23:57 +0200164 <constructor-arg name="properties" ref="props" />
165 </bean>
166
margaretha35e1ca22023-11-16 22:00:01 +0100167 <bean id="initializator"
168 class="de.ids_mannheim.korap.init.Initializator" init-method="init">
margarethab4ce6602018-04-26 20:23:57 +0200169 </bean>
margaretha35e1ca22023-11-16 22:00:01 +0100170
margarethaade7d4a2017-07-20 19:53:35 +0200171 <!-- Krill -->
margaretha35e1ca22023-11-16 22:00:01 +0100172 <bean id="search_krill"
173 class="de.ids_mannheim.korap.web.SearchKrill">
margaretha0e8f4e72018-04-05 14:11:52 +0200174 <constructor-arg value="${krill.indexDir}" />
margaretha543f2002017-07-14 00:27:15 +0200175 </bean>
margaretha35e1ca22023-11-16 22:00:01 +0100176
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" />
margaretha543f2002017-07-14 00:27:15 +0200180
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}" />
188
189 <!-- <constructor-arg index="1" type="long"> <util:constant static-field="org.apache.commons.validator.routines.UrlValidator.NO_FRAGMENTS"
190 /> </constructor-arg> -->
margarethaa0486272018-04-12 19:59:31 +0200191 </bean>
margaretha35e1ca22023-11-16 22:00:01 +0100192 <bean id="urlValidator"
193 class="org.apache.commons.validator.routines.UrlValidator">
margarethad7cab212018-07-02 19:01:43 +0200194 <constructor-arg value="http,https" />
195 </bean>
margaretha35e1ca22023-11-16 22:00:01 +0100196
margaretha34954472018-10-24 20:05:17 +0200197 <!-- Rewrite -->
margaretha35e1ca22023-11-16 22:00:01 +0100198 <bean id="foundryRewrite"
199 class="de.ids_mannheim.korap.rewrite.FoundryRewrite" />
200 <bean id="collectionRewrite"
201 class="de.ids_mannheim.korap.rewrite.CollectionRewrite" />
202 <bean id="virtualCorpusRewrite"
203 class="de.ids_mannheim.korap.rewrite.VirtualCorpusRewrite" />
204 <bean id="queryReferenceRewrite"
205 class="de.ids_mannheim.korap.rewrite.QueryReferenceRewrite" />
206
margaretha4fa4b062019-01-28 19:43:30 +0100207 <util:list id="rewriteTasks"
208 value-type="de.ids_mannheim.korap.rewrite.RewriteTask">
209 <ref bean="foundryRewrite" />
210 <ref bean="collectionRewrite" />
211 <ref bean="virtualCorpusRewrite" />
margaretha35e1ca22023-11-16 22:00:01 +0100212 <ref bean="queryReferenceRewrite" />
margaretha4fa4b062019-01-28 19:43:30 +0100213 </util:list>
margaretha35e1ca22023-11-16 22:00:01 +0100214
215 <bean id="rewriteHandler"
216 class="de.ids_mannheim.korap.rewrite.RewriteHandler">
217 <constructor-arg ref="rewriteTasks" />
margaretha56e8e552017-12-05 16:31:21 +0100218 </bean>
219
margaretha35e1ca22023-11-16 22:00:01 +0100220 <bean id="kustvaktResponseHandler"
221 class="de.ids_mannheim.korap.web.KustvaktResponseHandler">
margaretha0e8f4e72018-04-05 14:11:52 +0200222 </bean>
margarethaa452c5e2018-04-25 22:48:09 +0200223
margarethafb027f92018-04-23 20:00:13 +0200224 <!-- OAuth -->
margaretha35e1ca22023-11-16 22:00:01 +0100225 <bean id="oauth2ResponseHandler"
226 class="de.ids_mannheim.korap.web.OAuth2ResponseHandler">
margaretha05122312018-04-16 15:01:34 +0200227 </bean>
margarethaa452c5e2018-04-25 22:48:09 +0200228
margaretha35e1ca22023-11-16 22:00:01 +0100229 <bean name="kustvakt_encryption"
230 class="de.ids_mannheim.korap.encryption.KustvaktEncryption">
margaretha543f2002017-07-14 00:27:15 +0200231 <constructor-arg ref="kustvakt_config" />
232 </bean>
233
234 <!-- authentication providers to use -->
margaretha543f2002017-07-14 00:27:15 +0200235
margaretha35e1ca22023-11-16 22:00:01 +0100236 <!-- <bean id="session_auth" class="de.ids_mannheim.korap.authentication.SessionAuthentication">
237 <constructor-arg type="de.ids_mannheim.korap.config.KustvaktConfiguration"
238 ref="kustvakt_config" /> <constructor-arg type="de.ids_mannheim.korap.interfaces.EncryptionIface"
239 ref="kustvakt_encryption" /> </bean> -->
Michael Hanlca740d72015-06-16 10:04:58 +0200240
margarethacf306d32018-05-30 19:45:35 +0200241 <bean id="oauth2_auth"
242 class="de.ids_mannheim.korap.authentication.OAuth2Authentication" />
margaretha35e1ca22023-11-16 22:00:01 +0100243
margaretha543f2002017-07-14 00:27:15 +0200244 <util:list id="kustvakt_authproviders"
245 value-type="de.ids_mannheim.korap.interfaces.AuthenticationIface">
margarethaac49b502023-04-18 11:01:48 +0200246 <!-- <ref bean="session_auth" /> -->
margarethacf306d32018-05-30 19:45:35 +0200247 <ref bean="oauth2_auth" />
margaretha543f2002017-07-14 00:27:15 +0200248 </util:list>
Michael Hanl72c7b832015-09-03 08:42:15 +0200249
250
margaretha543f2002017-07-14 00:27:15 +0200251 <!-- specify type for constructor argument -->
margaretha34954472018-10-24 20:05:17 +0200252 <bean id="authenticationManager"
margaretha139d0f72017-11-14 18:56:22 +0100253 class="de.ids_mannheim.korap.authentication.KustvaktAuthenticationManager">
margaretha35e1ca22023-11-16 22:00:01 +0100254 <constructor-arg
255 type="de.ids_mannheim.korap.interfaces.EncryptionIface"
margaretha543f2002017-07-14 00:27:15 +0200256 ref="kustvakt_encryption" />
257 <constructor-arg ref="kustvakt_config" />
margaretha543f2002017-07-14 00:27:15 +0200258 <!-- inject authentication providers to use -->
259 <property name="providers" ref="kustvakt_authproviders" />
260 </bean>
margaretha35e1ca22023-11-16 22:00:01 +0100261
margaretha543f2002017-07-14 00:27:15 +0200262 <!-- todo: if db interfaces not loaded via spring, does transaction even
263 work then? -->
264 <!-- the transactional advice (i.e. what 'happens'; see the <aop:advisor/>
265 bean below) -->
266 <tx:advice id="txAdvice" transaction-manager="txManager">
267 <!-- the transactional semantics... -->
268 <tx:attributes>
269 <!-- all methods starting with 'get' are read-only -->
margaretha35e1ca22023-11-16 22:00:01 +0100270 <tx:method name="get*" read-only="true"
271 rollback-for="KorAPException" />
margaretha543f2002017-07-14 00:27:15 +0200272 <!-- other methods use the default transaction settings (see below) -->
273 <tx:method name="*" rollback-for="KorAPException" />
274 </tx:attributes>
275 </tx:advice>
Michael Hanldaf86602016-05-12 14:31:52 +0200276
margaretha543f2002017-07-14 00:27:15 +0200277 <!-- ensure that the above transactional advice runs for any execution of
278 an operation defined by the service interface -->
279 <aop:config>
280 <aop:pointcut id="service"
281 expression="execution(* de.ids_mannheim.korap.interfaces.db.*.*(..))" />
282 <aop:advisor advice-ref="txAdvice" pointcut-ref="service" />
283 </aop:config>
Michael Hanlf8fcc7a2016-06-03 17:41:07 +0200284
margaretha543f2002017-07-14 00:27:15 +0200285 <!-- similarly, don't forget the PlatformTransactionManager -->
286 <bean id="txManager"
287 class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
margaretha09a9a582024-01-11 21:48:20 +0100288 <property name="dataSource" ref="dataSource" />
margaretha8514d782018-08-28 17:36:56 +0200289 <!-- <property name="dataSource" ref="c3p0DataSource" /> -->
margaretha543f2002017-07-14 00:27:15 +0200290 </bean>
margaretha0e8f4e72018-04-05 14:11:52 +0200291
margarethac9f1dfa2018-02-07 17:50:33 +0100292 <!-- mail -->
margaretha35e1ca22023-11-16 22:00:01 +0100293 <bean id="authenticator"
294 class="de.ids_mannheim.korap.service.MailAuthenticator">
margaretha0e8f4e72018-04-05 14:11:52 +0200295 <constructor-arg index="0" value="${mail.username}" />
296 <constructor-arg index="1" value="${mail.password}" />
margarethaaecee1b2018-02-20 14:44:21 +0100297 </bean>
margaretha35e1ca22023-11-16 22:00:01 +0100298 <bean id="smtpSession" class="jakarta.mail.Session"
299 factory-method="getInstance">
margarethaaecee1b2018-02-20 14:44:21 +0100300 <constructor-arg index="0">
301 <props>
302 <prop key="mail.smtp.submitter">${mail.username}</prop>
303 <prop key="mail.smtp.auth">${mail.auth}</prop>
304 <prop key="mail.smtp.host">${mail.host}</prop>
305 <prop key="mail.smtp.port">${mail.port}</prop>
306 <prop key="mail.smtp.starttls.enable">${mail.starttls.enable}</prop>
307 <prop key="mail.smtp.connectiontimeout">${mail.connectiontimeout}</prop>
308 </props>
309 </constructor-arg>
margaretha0e8f4e72018-04-05 14:11:52 +0200310 <constructor-arg index="1" ref="authenticator" />
margarethac9f1dfa2018-02-07 17:50:33 +0100311 </bean>
margaretha35e1ca22023-11-16 22:00:01 +0100312 <bean id="mailSender"
313 class="org.springframework.mail.javamail.JavaMailSenderImpl">
margarethaaecee1b2018-02-20 14:44:21 +0100314 <property name="username" value="${mail.username}" />
margaretha0e8f4e72018-04-05 14:11:52 +0200315 <property name="password" value="${mail.password}" />
margarethac9f1dfa2018-02-07 17:50:33 +0100316 <property name="session" ref="smtpSession" />
317 </bean>
margaretha35e1ca22023-11-16 22:00:01 +0100318 <bean id="velocityEngine"
319 class="org.apache.velocity.app.VelocityEngine">
margarethac9f1dfa2018-02-07 17:50:33 +0100320 <constructor-arg index="0">
321 <props>
322 <prop key="resource.loader">class</prop>
margaretha0e8f4e72018-04-05 14:11:52 +0200323 <prop key="class.resource.loader.class">org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
324 </prop>
margarethac9f1dfa2018-02-07 17:50:33 +0100325 </props>
326 </constructor-arg>
margarethaaecee1b2018-02-20 14:44:21 +0100327 </bean>
Akronbee031a2020-10-29 16:58:14 +0100328</beans>