blob: f79f967ca3087b3f92b81a317276d7fe5edc0751 [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>
margarethaaecee1b2018-02-20 14:44:21 +010043 <value>classpath:properties/mail.properties</value>
44 <value>file:./mail.properties</value>
margarethaf6d5a822017-10-19 19:51:20 +020045 <value>classpath:test-hibernate.properties</value>
margaretha1960ea52023-02-28 11:20:15 +010046 <value>file:./kustvakt-test.conf</value>
margarethaf18298b2017-09-14 22:14:32 +020047 <value>classpath:kustvakt-test.conf</value>
margaretha62055f72017-04-11 19:17:43 +020048 </array>
49 </property>
50 </bean>
margarethaf6f6c3c2024-06-11 10:51:06 +020051
margarethaf6f6c3c2024-06-11 10:51:06 +020052 <bean id="kustvakt_config"
53 class="de.ids_mannheim.korap.config.FullConfiguration">
54 <constructor-arg name="properties" ref="props" />
55 </bean>
56
Michael Hanlbd852b82015-11-18 22:17:00 +010057
margaretha35e1ca22023-11-16 22:00:01 +010058 <bean id="dataSource"
59 class="org.apache.commons.dbcp2.BasicDataSource" lazy-init="true">
margaretha4edc70e2018-03-14 22:34:29 +010060 <!-- <property name="driverClassName" value="${jdbc.driverClassName}" /> -->
margaretha6c2a20f2017-07-24 15:33:01 +020061 <property name="url" value="${jdbc.url}" />
62 <property name="username" value="${jdbc.username}" />
63 <property name="password" value="${jdbc.password}" />
margaretha318fec32017-10-24 12:11:58 +020064 <property name="maxTotal" value="4" />
margaretha514e1412017-10-10 15:54:20 +020065 <property name="maxIdle" value="1" />
margaretha6c2a20f2017-07-24 15:33:01 +020066 <property name="minIdle" value="1" />
67 <property name="maxWaitMillis" value="15000" />
68 <!--<property name="poolPreparedStatements" value="true"/> -->
69 </bean>
70
margaretha35e1ca22023-11-16 22:00:01 +010071 <bean id="c3p0DataSource"
72 class="com.mchange.v2.c3p0.ComboPooledDataSource"
margaretha58e18632018-02-15 13:04:42 +010073 destroy-method="close">
74 <property name="driverClass" value="${jdbc.driverClassName}" />
margaretha514e1412017-10-10 15:54:20 +020075 <property name="jdbcUrl" value="${jdbc.url}" />
76 <property name="user" value="${jdbc.username}" />
77 <property name="password" value="${jdbc.password}" />
margaretha58e18632018-02-15 13:04:42 +010078 <property name="maxPoolSize" value="4" />
79 <property name="minPoolSize" value="1" />
80 <property name="maxStatements" value="1" />
81 <property name="testConnectionOnCheckout" value="true" />
margaretha62055f72017-04-11 19:17:43 +020082 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +010083
margaretha62055f72017-04-11 19:17:43 +020084 <!-- to configure database for sqlite, mysql, etc. migrations -->
margaretha35e1ca22023-11-16 22:00:01 +010085 <bean id="flywayConfig"
86 class="org.flywaydb.core.api.configuration.ClassicConfiguration">
margarethaf6d5a822017-10-19 19:51:20 +020087 <!-- drop existing tables and create new tables -->
88 <property name="validateOnMigrate" value="true" />
89 <property name="cleanOnValidationError" value="true" />
margaretha514e1412017-10-10 15:54:20 +020090 <property name="baselineOnMigrate" value="false" />
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" />
margarethad66a6832022-03-03 08:47:13 +010094 <property name="outOfOrder" value="true" />
margaretha62055f72017-04-11 19:17:43 +020095 </bean>
margaretha35e1ca22023-11-16 22:00:01 +010096
97 <bean id="flyway" class="org.flywaydb.core.Flyway"
98 init-method="migrate">
99 <constructor-arg ref="flywayConfig" />
margarethafcf8bd92021-01-14 10:55:53 +0100100 </bean>
margaretha35e1ca22023-11-16 22:00:01 +0100101
margarethaade7d4a2017-07-20 19:53:35 +0200102 <bean id="entityManagerFactory"
103 class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
margaretha8fe51e92023-09-20 11:22:20 +0200104 <property name="dataSource" ref="dataSource" />
margaretha3a966022024-06-13 13:51:50 +0200105
margarethaa452c5e2018-04-25 22:48:09 +0200106 <property name="packagesToScan">
107 <array>
margaretha5b708792023-05-12 16:55:29 +0200108 <value>de.ids_mannheim.korap.core.entity</value>
margarethaa452c5e2018-04-25 22:48:09 +0200109 <value>de.ids_mannheim.korap.entity</value>
110 <value>de.ids_mannheim.korap.oauth2.entity</value>
111 </array>
112 </property>
margarethaade7d4a2017-07-20 19:53:35 +0200113 <property name="jpaVendorAdapter">
114 <bean id="jpaVendorAdapter"
115 class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
margaretha35e1ca22023-11-16 22:00:01 +0100116 <property name="databasePlatform"
117 value="${hibernate.dialect}" />
margarethaade7d4a2017-07-20 19:53:35 +0200118 </bean>
119 </property>
120 <property name="jpaProperties">
121 <props>
122 <prop key="hibernate.dialect">${hibernate.dialect}</prop>
123 <prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop>
124 <prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
125 <prop key="hibernate.cache.use_query_cache">${hibernate.cache.use_query_cache}</prop>
126 <prop key="hibernate.cache.use_second_level_cache">${hibernate.cache.use_second_level_cache}
127 </prop>
128 <prop key="hibernate.cache.provider_class">${hibernate.cache.provider}</prop>
129 <prop key="hibernate.cache.region.factory_class">${hibernate.cache.region.factory}</prop>
margaretha6ad08b42018-08-22 18:33:54 +0200130 <prop key="hibernate.jdbc.time_zone">${hibernate.jdbc.time_zone}</prop>
margarethaade7d4a2017-07-20 19:53:35 +0200131 <!-- <prop key="net.sf.ehcache.configurationResourceName">classpath:ehcache.xml</prop> -->
132 </props>
133 </property>
margaretha62055f72017-04-11 19:17:43 +0200134 </bean>
Michael Hanle4fc7752016-02-17 11:41:18 +0100135
margarethaade7d4a2017-07-20 19:53:35 +0200136 <tx:annotation-driven proxy-target-class="true"
137 transaction-manager="transactionManager" />
margaretha35e1ca22023-11-16 22:00:01 +0100138 <bean id="transactionManager"
139 class="org.springframework.orm.jpa.JpaTransactionManager">
140 <property name="entityManagerFactory"
141 ref="entityManagerFactory" />
margaretha62055f72017-04-11 19:17:43 +0200142 </bean>
Michael Hanle4fc7752016-02-17 11:41:18 +0100143
margarethaade7d4a2017-07-20 19:53:35 +0200144 <bean id="transactionTemplate"
145 class="org.springframework.transaction.support.TransactionTemplate">
146 <constructor-arg ref="transactionManager" />
147 </bean>
148
149 <!-- Data access objects -->
margaretha34954472018-10-24 20:05:17 +0200150 <bean id="adminDao" class="de.ids_mannheim.korap.dao.AdminDaoImpl" />
margaretha35e1ca22023-11-16 22:00:01 +0100151 <bean id="resourceDao"
152 class="de.ids_mannheim.korap.dao.ResourceDao" />
153 <bean id="accessScopeDao"
154 class="de.ids_mannheim.korap.oauth2.dao.AccessScopeDao" />
155 <bean id="authorizationDao"
156 class="de.ids_mannheim.korap.oauth2.dao.CachedAuthorizationDaoImpl" />
157
margaretha34954472018-10-24 20:05:17 +0200158 <!-- Services -->
margaretha35e1ca22023-11-16 22:00:01 +0100159 <bean id="scopeService"
160 class="de.ids_mannheim.korap.oauth2.service.OAuth2ScopeServiceImpl" />
161
margaretha35e1ca22023-11-16 22:00:01 +0100162 <bean id="initializator"
163 class="de.ids_mannheim.korap.init.Initializator"
margaretha1b320452018-08-02 16:56:25 +0200164 init-method="initTest">
margarethab4ce6602018-04-26 20:23:57 +0200165 </bean>
166
margaretha6c2a20f2017-07-24 15:33:01 +0200167 <!-- Krill -->
margaretha35e1ca22023-11-16 22:00:01 +0100168 <bean id="search_krill"
169 class="de.ids_mannheim.korap.web.SearchKrill">
margaretha58e18632018-02-15 13:04:42 +0100170 <constructor-arg value="${krill.indexDir}" />
margaretha6c2a20f2017-07-24 15:33:01 +0200171 </bean>
172
margaretha6cd27f32019-01-24 14:47:47 +0100173 <!-- Validator -->
margaretha35e1ca22023-11-16 22:00:01 +0100174 <bean id="validator"
175 class="de.ids_mannheim.korap.validator.ApacheValidator" />
176
margaretha31a9f522018-04-03 20:40:45 +0200177 <!-- URLValidator -->
margaretha35e1ca22023-11-16 22:00:01 +0100178 <bean id="redirectURIValidator"
179 class="org.apache.commons.validator.routines.UrlValidator">
margarethae4034a82018-07-02 14:46:59 +0200180 <constructor-arg value="http,https" index="0" />
margaretha35e1ca22023-11-16 22:00:01 +0100181 <constructor-arg index="1" type="long"
182 value="#{T(org.apache.commons.validator.routines.UrlValidator).ALLOW_LOCAL_URLS +
183 T(org.apache.commons.validator.routines.UrlValidator).NO_FRAGMENTS}" />
margaretha31a9f522018-04-03 20:40:45 +0200184 </bean>
margaretha35e1ca22023-11-16 22:00:01 +0100185 <bean id="urlValidator"
186 class="org.apache.commons.validator.routines.UrlValidator">
margarethad7cab212018-07-02 19:01:43 +0200187 <constructor-arg value="http,https" />
188 </bean>
margaretha56e8e552017-12-05 16:31:21 +0100189
margaretha4fa4b062019-01-28 19:43:30 +0100190 <!-- Rewrite -->
margaretha35e1ca22023-11-16 22:00:01 +0100191 <bean id="foundryRewrite"
192 class="de.ids_mannheim.korap.rewrite.FoundryRewrite" />
193 <bean id="collectionRewrite"
194 class="de.ids_mannheim.korap.rewrite.CollectionRewrite" />
margaretha35e1ca22023-11-16 22:00:01 +0100195 <bean id="virtualCorpusRewrite"
196 class="de.ids_mannheim.korap.rewrite.VirtualCorpusRewrite" />
margaretha35e1ca22023-11-16 22:00:01 +0100197 <bean id="queryReferenceRewrite"
198 class="de.ids_mannheim.korap.rewrite.QueryReferenceRewrite" />
199
margaretha4fa4b062019-01-28 19:43:30 +0100200 <util:list id="rewriteTasks"
201 value-type="de.ids_mannheim.korap.rewrite.RewriteTask">
margaretha4fa4b062019-01-28 19:43:30 +0100202 <ref bean="foundryRewrite" />
203 <ref bean="collectionRewrite" />
204 <ref bean="virtualCorpusRewrite" />
Akronbee031a2020-10-29 16:58:14 +0100205 <ref bean="queryReferenceRewrite" />
margaretha4fa4b062019-01-28 19:43:30 +0100206 </util:list>
margaretha35e1ca22023-11-16 22:00:01 +0100207
208 <bean id="rewriteHandler"
209 class="de.ids_mannheim.korap.rewrite.RewriteHandler">
210 <constructor-arg ref="rewriteTasks" />
margaretha56e8e552017-12-05 16:31:21 +0100211 </bean>
212
margaretha35e1ca22023-11-16 22:00:01 +0100213 <bean id="kustvaktResponseHandler"
214 class="de.ids_mannheim.korap.web.KustvaktResponseHandler">
margaretha05122312018-04-16 15:01:34 +0200215 </bean>
margarethafb027f92018-04-23 20:00:13 +0200216
217 <!-- OAuth -->
margaretha35e1ca22023-11-16 22:00:01 +0100218 <bean id="oauth2ResponseHandler"
219 class="de.ids_mannheim.korap.web.OAuth2ResponseHandler">
margaretha58e18632018-02-15 13:04:42 +0100220 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +0100221
margaretha35e1ca22023-11-16 22:00:01 +0100222 <bean name="kustvakt_encryption"
223 class="de.ids_mannheim.korap.encryption.KustvaktEncryption">
margaretha62055f72017-04-11 19:17:43 +0200224 <constructor-arg ref="kustvakt_config" />
225 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +0100226
margaretha62055f72017-04-11 19:17:43 +0200227 <!-- authentication providers to use -->
margaretha58e18632018-02-15 13:04:42 +0100228 <bean id="basic_auth"
229 class="de.ids_mannheim.korap.authentication.BasicAuthentication" />
Michael Hanlbd852b82015-11-18 22:17:00 +0100230
231
margaretha62055f72017-04-11 19:17:43 +0200232 <bean id="session_auth"
margaretha139d0f72017-11-14 18:56:22 +0100233 class="de.ids_mannheim.korap.authentication.SessionAuthentication">
margaretha35e1ca22023-11-16 22:00:01 +0100234 <constructor-arg
235 type="de.ids_mannheim.korap.config.KustvaktConfiguration"
margaretha62055f72017-04-11 19:17:43 +0200236 ref="kustvakt_config" />
margaretha35e1ca22023-11-16 22:00:01 +0100237 <constructor-arg
238 type="de.ids_mannheim.korap.interfaces.EncryptionIface"
margaretha62055f72017-04-11 19:17:43 +0200239 ref="kustvakt_encryption" />
240 </bean>
margarethae4034a82018-07-02 14:46:59 +0200241
margarethacf306d32018-05-30 19:45:35 +0200242 <bean id="oauth2_auth"
243 class="de.ids_mannheim.korap.authentication.OAuth2Authentication" />
margarethae4034a82018-07-02 14:46:59 +0200244
Michael Hanlbd852b82015-11-18 22:17:00 +0100245
margaretha62055f72017-04-11 19:17:43 +0200246 <util:list id="kustvakt_authproviders"
247 value-type="de.ids_mannheim.korap.interfaces.AuthenticationIface">
248 <ref bean="basic_auth" />
249 <ref bean="session_auth" />
margarethacf306d32018-05-30 19:45:35 +0200250 <ref bean="oauth2_auth" />
margaretha62055f72017-04-11 19:17:43 +0200251 </util:list>
Michael Hanlbd852b82015-11-18 22:17:00 +0100252
margaretha62055f72017-04-11 19:17:43 +0200253 <!-- specify type for constructor argument -->
margaretha34954472018-10-24 20:05:17 +0200254 <bean id="authenticationManager"
margaretha139d0f72017-11-14 18:56:22 +0100255 class="de.ids_mannheim.korap.authentication.KustvaktAuthenticationManager">
margaretha35e1ca22023-11-16 22:00:01 +0100256 <constructor-arg
257 type="de.ids_mannheim.korap.interfaces.EncryptionIface"
margaretha62055f72017-04-11 19:17:43 +0200258 ref="kustvakt_encryption" />
259 <constructor-arg ref="kustvakt_config" />
margaretha62055f72017-04-11 19:17:43 +0200260 <!-- inject authentication providers to use -->
261 <property name="providers" ref="kustvakt_authproviders" />
262 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +0100263
margaretha62055f72017-04-11 19:17:43 +0200264 <!-- todo: if db interfaces not loaded via spring, does transaction even
265 work then? -->
266 <!-- the transactional advice (i.e. what 'happens'; see the <aop:advisor/>
267 bean below) -->
268 <tx:advice id="txAdvice" transaction-manager="txManager">
269 <!-- the transactional semantics... -->
270 <tx:attributes>
271 <!-- all methods starting with 'get' are read-only -->
margaretha35e1ca22023-11-16 22:00:01 +0100272 <tx:method name="get*" read-only="true"
273 rollback-for="KorAPException" />
margaretha62055f72017-04-11 19:17:43 +0200274 <!-- other methods use the default transaction settings (see below) -->
275 <tx:method name="*" rollback-for="KorAPException" />
276 </tx:attributes>
277 </tx:advice>
Michael Hanlbd852b82015-11-18 22:17:00 +0100278
margaretha62055f72017-04-11 19:17:43 +0200279 <!-- ensure that the above transactional advice runs for any execution of
280 an operation defined by the service interface -->
281 <aop:config>
282 <aop:pointcut id="service"
283 expression="execution(* de.ids_mannheim.korap.interfaces.db.*.*(..))" />
284 <aop:advisor advice-ref="txAdvice" pointcut-ref="service" />
285 </aop:config>
Michael Hanlbd852b82015-11-18 22:17:00 +0100286
margaretha62055f72017-04-11 19:17:43 +0200287 <!-- similarly, don't forget the PlatformTransactionManager -->
288 <bean id="txManager"
289 class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
290 <property name="dataSource" ref="dataSource" />
291 </bean>
margaretha58e18632018-02-15 13:04:42 +0100292
293 <!-- mail -->
margaretha35e1ca22023-11-16 22:00:01 +0100294 <bean id="authenticator"
295 class="de.ids_mannheim.korap.service.MailAuthenticator">
margarethafb027f92018-04-23 20:00:13 +0200296 <constructor-arg index="0" value="${mail.username}" />
297 <constructor-arg index="1" value="${mail.password}" />
margarethaaecee1b2018-02-20 14:44:21 +0100298 </bean>
margaretha35e1ca22023-11-16 22:00:01 +0100299 <bean id="smtpSession" class="jakarta.mail.Session"
300 factory-method="getInstance">
margarethaaecee1b2018-02-20 14:44:21 +0100301 <constructor-arg index="0">
302 <props>
303 <prop key="mail.smtp.submitter">${mail.username}</prop>
304 <prop key="mail.smtp.auth">${mail.auth}</prop>
305 <prop key="mail.smtp.host">${mail.host}</prop>
306 <prop key="mail.smtp.port">${mail.port}</prop>
307 <prop key="mail.smtp.starttls.enable">${mail.starttls.enable}</prop>
308 <prop key="mail.smtp.connectiontimeout">${mail.connectiontimeout}</prop>
309 </props>
310 </constructor-arg>
margarethafb027f92018-04-23 20:00:13 +0200311 <constructor-arg index="1" ref="authenticator" />
margaretha58e18632018-02-15 13:04:42 +0100312 </bean>
margaretha35e1ca22023-11-16 22:00:01 +0100313 <bean id="mailSender"
314 class="org.springframework.mail.javamail.JavaMailSenderImpl">
margaretha3a966022024-06-13 13:51:50 +0200315 <property name="username" value="${mail.username}" />
316 <property name="password" value="${mail.password}" />
margaretha58e18632018-02-15 13:04:42 +0100317 <property name="session" ref="smtpSession" />
318 </bean>
margaretha35e1ca22023-11-16 22:00:01 +0100319 <bean id="velocityEngine"
320 class="org.apache.velocity.app.VelocityEngine">
margaretha58e18632018-02-15 13:04:42 +0100321 <constructor-arg index="0">
322 <props>
323 <prop key="resource.loader">class</prop>
324 <prop key="class.resource.loader.class">org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
325 </prop>
326 </props>
327 </constructor-arg>
margarethaaecee1b2018-02-20 14:44:21 +0100328 </bean>
Akronbee031a2020-10-29 16:58:14 +0100329</beans>