blob: 3b6f5d1b33deebb14468291c542406b3a6520896 [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>
margarethaf6d5a822017-10-19 19:51:20 +020044 <value>classpath:test-hibernate.properties</value>
margaretha1960ea52023-02-28 11:20:15 +010045 <value>file:./kustvakt-test.conf</value>
margarethaf18298b2017-09-14 22:14:32 +020046 <value>classpath:kustvakt-test.conf</value>
margaretha62055f72017-04-11 19:17:43 +020047 </array>
48 </property>
49 </bean>
margarethaf6f6c3c2024-06-11 10:51:06 +020050
margarethaf6f6c3c2024-06-11 10:51:06 +020051 <bean id="kustvakt_config"
52 class="de.ids_mannheim.korap.config.FullConfiguration">
53 <constructor-arg name="properties" ref="props" />
54 </bean>
55
Michael Hanlbd852b82015-11-18 22:17:00 +010056
margaretha35e1ca22023-11-16 22:00:01 +010057 <bean id="dataSource"
58 class="org.apache.commons.dbcp2.BasicDataSource" lazy-init="true">
margaretha4edc70e2018-03-14 22:34:29 +010059 <!-- <property name="driverClassName" value="${jdbc.driverClassName}" /> -->
margaretha6c2a20f2017-07-24 15:33:01 +020060 <property name="url" value="${jdbc.url}" />
61 <property name="username" value="${jdbc.username}" />
62 <property name="password" value="${jdbc.password}" />
margaretha318fec32017-10-24 12:11:58 +020063 <property name="maxTotal" value="4" />
margaretha514e1412017-10-10 15:54:20 +020064 <property name="maxIdle" value="1" />
margaretha6c2a20f2017-07-24 15:33:01 +020065 <property name="minIdle" value="1" />
66 <property name="maxWaitMillis" value="15000" />
67 <!--<property name="poolPreparedStatements" value="true"/> -->
68 </bean>
69
margaretha35e1ca22023-11-16 22:00:01 +010070 <bean id="c3p0DataSource"
71 class="com.mchange.v2.c3p0.ComboPooledDataSource"
margaretha58e18632018-02-15 13:04:42 +010072 destroy-method="close">
73 <property name="driverClass" value="${jdbc.driverClassName}" />
margaretha514e1412017-10-10 15:54:20 +020074 <property name="jdbcUrl" value="${jdbc.url}" />
75 <property name="user" value="${jdbc.username}" />
76 <property name="password" value="${jdbc.password}" />
margaretha58e18632018-02-15 13:04:42 +010077 <property name="maxPoolSize" value="4" />
78 <property name="minPoolSize" value="1" />
79 <property name="maxStatements" value="1" />
80 <property name="testConnectionOnCheckout" value="true" />
margaretha62055f72017-04-11 19:17:43 +020081 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +010082
margaretha62055f72017-04-11 19:17:43 +020083 <!-- to configure database for sqlite, mysql, etc. migrations -->
margaretha35e1ca22023-11-16 22:00:01 +010084 <bean id="flywayConfig"
85 class="org.flywaydb.core.api.configuration.ClassicConfiguration">
margarethaf6d5a822017-10-19 19:51:20 +020086 <!-- drop existing tables and create new tables -->
87 <property name="validateOnMigrate" value="true" />
88 <property name="cleanOnValidationError" value="true" />
margaretha514e1412017-10-10 15:54:20 +020089 <property name="baselineOnMigrate" value="false" />
margaretha35e1ca22023-11-16 22:00:01 +010090 <property name="locations"
91 value="#{'${jdbc.schemaPath}'.split(',')}" />
margaretha8fe51e92023-09-20 11:22:20 +020092 <property name="dataSource" ref="dataSource" />
margarethad66a6832022-03-03 08:47:13 +010093 <property name="outOfOrder" value="true" />
margaretha62055f72017-04-11 19:17:43 +020094 </bean>
margaretha35e1ca22023-11-16 22:00:01 +010095
96 <bean id="flyway" class="org.flywaydb.core.Flyway"
97 init-method="migrate">
98 <constructor-arg ref="flywayConfig" />
margarethafcf8bd92021-01-14 10:55:53 +010099 </bean>
margaretha35e1ca22023-11-16 22:00:01 +0100100
margarethaade7d4a2017-07-20 19:53:35 +0200101 <bean id="entityManagerFactory"
102 class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
margaretha8fe51e92023-09-20 11:22:20 +0200103 <property name="dataSource" ref="dataSource" />
margaretha3a966022024-06-13 13:51:50 +0200104
margarethaa452c5e2018-04-25 22:48:09 +0200105 <property name="packagesToScan">
106 <array>
margaretha5b708792023-05-12 16:55:29 +0200107 <value>de.ids_mannheim.korap.core.entity</value>
margarethaa452c5e2018-04-25 22:48:09 +0200108 <value>de.ids_mannheim.korap.entity</value>
109 <value>de.ids_mannheim.korap.oauth2.entity</value>
110 </array>
111 </property>
margarethaade7d4a2017-07-20 19:53:35 +0200112 <property name="jpaVendorAdapter">
113 <bean id="jpaVendorAdapter"
114 class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
margaretha35e1ca22023-11-16 22:00:01 +0100115 <property name="databasePlatform"
116 value="${hibernate.dialect}" />
margarethaade7d4a2017-07-20 19:53:35 +0200117 </bean>
118 </property>
119 <property name="jpaProperties">
120 <props>
121 <prop key="hibernate.dialect">${hibernate.dialect}</prop>
122 <prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop>
123 <prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
124 <prop key="hibernate.cache.use_query_cache">${hibernate.cache.use_query_cache}</prop>
125 <prop key="hibernate.cache.use_second_level_cache">${hibernate.cache.use_second_level_cache}
126 </prop>
127 <prop key="hibernate.cache.provider_class">${hibernate.cache.provider}</prop>
128 <prop key="hibernate.cache.region.factory_class">${hibernate.cache.region.factory}</prop>
margaretha6ad08b42018-08-22 18:33:54 +0200129 <prop key="hibernate.jdbc.time_zone">${hibernate.jdbc.time_zone}</prop>
margarethaade7d4a2017-07-20 19:53:35 +0200130 <!-- <prop key="net.sf.ehcache.configurationResourceName">classpath:ehcache.xml</prop> -->
131 </props>
132 </property>
margaretha62055f72017-04-11 19:17:43 +0200133 </bean>
Michael Hanle4fc7752016-02-17 11:41:18 +0100134
margarethaade7d4a2017-07-20 19:53:35 +0200135 <tx:annotation-driven proxy-target-class="true"
136 transaction-manager="transactionManager" />
margaretha35e1ca22023-11-16 22:00:01 +0100137 <bean id="transactionManager"
138 class="org.springframework.orm.jpa.JpaTransactionManager">
139 <property name="entityManagerFactory"
140 ref="entityManagerFactory" />
margaretha62055f72017-04-11 19:17:43 +0200141 </bean>
Michael Hanle4fc7752016-02-17 11:41:18 +0100142
margarethaade7d4a2017-07-20 19:53:35 +0200143 <bean id="transactionTemplate"
144 class="org.springframework.transaction.support.TransactionTemplate">
145 <constructor-arg ref="transactionManager" />
146 </bean>
147
148 <!-- Data access objects -->
margaretha34954472018-10-24 20:05:17 +0200149 <bean id="adminDao" class="de.ids_mannheim.korap.dao.AdminDaoImpl" />
margaretha35e1ca22023-11-16 22:00:01 +0100150 <bean id="resourceDao"
151 class="de.ids_mannheim.korap.dao.ResourceDao" />
152 <bean id="accessScopeDao"
153 class="de.ids_mannheim.korap.oauth2.dao.AccessScopeDao" />
154 <bean id="authorizationDao"
155 class="de.ids_mannheim.korap.oauth2.dao.CachedAuthorizationDaoImpl" />
156
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
margaretha35e1ca22023-11-16 22:00:01 +0100161 <bean id="initializator"
162 class="de.ids_mannheim.korap.init.Initializator"
margaretha1b320452018-08-02 16:56:25 +0200163 init-method="initTest">
margarethab4ce6602018-04-26 20:23:57 +0200164 </bean>
165
margaretha6c2a20f2017-07-24 15:33:01 +0200166 <!-- Krill -->
margaretha35e1ca22023-11-16 22:00:01 +0100167 <bean id="search_krill"
168 class="de.ids_mannheim.korap.web.SearchKrill">
margaretha58e18632018-02-15 13:04:42 +0100169 <constructor-arg value="${krill.indexDir}" />
margaretha6c2a20f2017-07-24 15:33:01 +0200170 </bean>
171
margaretha6cd27f32019-01-24 14:47:47 +0100172 <!-- Validator -->
margaretha35e1ca22023-11-16 22:00:01 +0100173 <bean id="validator"
174 class="de.ids_mannheim.korap.validator.ApacheValidator" />
175
margaretha31a9f522018-04-03 20:40:45 +0200176 <!-- URLValidator -->
margaretha35e1ca22023-11-16 22:00:01 +0100177 <bean id="redirectURIValidator"
178 class="org.apache.commons.validator.routines.UrlValidator">
margarethae4034a82018-07-02 14:46:59 +0200179 <constructor-arg value="http,https" index="0" />
margaretha35e1ca22023-11-16 22:00:01 +0100180 <constructor-arg index="1" type="long"
181 value="#{T(org.apache.commons.validator.routines.UrlValidator).ALLOW_LOCAL_URLS +
182 T(org.apache.commons.validator.routines.UrlValidator).NO_FRAGMENTS}" />
margaretha31a9f522018-04-03 20:40:45 +0200183 </bean>
margaretha35e1ca22023-11-16 22:00:01 +0100184 <bean id="urlValidator"
185 class="org.apache.commons.validator.routines.UrlValidator">
margarethad7cab212018-07-02 19:01:43 +0200186 <constructor-arg value="http,https" />
187 </bean>
margaretha56e8e552017-12-05 16:31:21 +0100188
margaretha4fa4b062019-01-28 19:43:30 +0100189 <!-- Rewrite -->
margaretha35e1ca22023-11-16 22:00:01 +0100190 <bean id="foundryRewrite"
191 class="de.ids_mannheim.korap.rewrite.FoundryRewrite" />
192 <bean id="collectionRewrite"
193 class="de.ids_mannheim.korap.rewrite.CollectionRewrite" />
margaretha35e1ca22023-11-16 22:00:01 +0100194 <bean id="virtualCorpusRewrite"
195 class="de.ids_mannheim.korap.rewrite.VirtualCorpusRewrite" />
margaretha35e1ca22023-11-16 22:00:01 +0100196 <bean id="queryReferenceRewrite"
197 class="de.ids_mannheim.korap.rewrite.QueryReferenceRewrite" />
198
margaretha4fa4b062019-01-28 19:43:30 +0100199 <util:list id="rewriteTasks"
200 value-type="de.ids_mannheim.korap.rewrite.RewriteTask">
margaretha4fa4b062019-01-28 19:43:30 +0100201 <ref bean="foundryRewrite" />
202 <ref bean="collectionRewrite" />
203 <ref bean="virtualCorpusRewrite" />
Akronbee031a2020-10-29 16:58:14 +0100204 <ref bean="queryReferenceRewrite" />
margaretha4fa4b062019-01-28 19:43:30 +0100205 </util:list>
margaretha35e1ca22023-11-16 22:00:01 +0100206
207 <bean id="rewriteHandler"
208 class="de.ids_mannheim.korap.rewrite.RewriteHandler">
209 <constructor-arg ref="rewriteTasks" />
margaretha56e8e552017-12-05 16:31:21 +0100210 </bean>
211
margaretha35e1ca22023-11-16 22:00:01 +0100212 <bean id="kustvaktResponseHandler"
213 class="de.ids_mannheim.korap.web.KustvaktResponseHandler">
margaretha05122312018-04-16 15:01:34 +0200214 </bean>
margarethafb027f92018-04-23 20:00:13 +0200215
216 <!-- OAuth -->
margaretha35e1ca22023-11-16 22:00:01 +0100217 <bean id="oauth2ResponseHandler"
218 class="de.ids_mannheim.korap.web.OAuth2ResponseHandler">
margaretha58e18632018-02-15 13:04:42 +0100219 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +0100220
margaretha35e1ca22023-11-16 22:00:01 +0100221 <bean name="kustvakt_encryption"
222 class="de.ids_mannheim.korap.encryption.KustvaktEncryption">
margaretha62055f72017-04-11 19:17:43 +0200223 <constructor-arg ref="kustvakt_config" />
224 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +0100225
margaretha62055f72017-04-11 19:17:43 +0200226 <!-- authentication providers to use -->
margaretha58e18632018-02-15 13:04:42 +0100227 <bean id="basic_auth"
228 class="de.ids_mannheim.korap.authentication.BasicAuthentication" />
Michael Hanlbd852b82015-11-18 22:17:00 +0100229
230
margaretha62055f72017-04-11 19:17:43 +0200231 <bean id="session_auth"
margaretha139d0f72017-11-14 18:56:22 +0100232 class="de.ids_mannheim.korap.authentication.SessionAuthentication">
margaretha35e1ca22023-11-16 22:00:01 +0100233 <constructor-arg
234 type="de.ids_mannheim.korap.config.KustvaktConfiguration"
margaretha62055f72017-04-11 19:17:43 +0200235 ref="kustvakt_config" />
margaretha35e1ca22023-11-16 22:00:01 +0100236 <constructor-arg
237 type="de.ids_mannheim.korap.interfaces.EncryptionIface"
margaretha62055f72017-04-11 19:17:43 +0200238 ref="kustvakt_encryption" />
239 </bean>
margarethae4034a82018-07-02 14:46:59 +0200240
margarethacf306d32018-05-30 19:45:35 +0200241 <bean id="oauth2_auth"
242 class="de.ids_mannheim.korap.authentication.OAuth2Authentication" />
margarethae4034a82018-07-02 14:46:59 +0200243
Michael Hanlbd852b82015-11-18 22:17:00 +0100244
margaretha62055f72017-04-11 19:17:43 +0200245 <util:list id="kustvakt_authproviders"
246 value-type="de.ids_mannheim.korap.interfaces.AuthenticationIface">
247 <ref bean="basic_auth" />
248 <ref bean="session_auth" />
margarethacf306d32018-05-30 19:45:35 +0200249 <ref bean="oauth2_auth" />
margaretha62055f72017-04-11 19:17:43 +0200250 </util:list>
Michael Hanlbd852b82015-11-18 22:17:00 +0100251
margaretha62055f72017-04-11 19:17:43 +0200252 <!-- specify type for constructor argument -->
margaretha34954472018-10-24 20:05:17 +0200253 <bean id="authenticationManager"
margaretha139d0f72017-11-14 18:56:22 +0100254 class="de.ids_mannheim.korap.authentication.KustvaktAuthenticationManager">
margaretha35e1ca22023-11-16 22:00:01 +0100255 <constructor-arg
256 type="de.ids_mannheim.korap.interfaces.EncryptionIface"
margaretha62055f72017-04-11 19:17:43 +0200257 ref="kustvakt_encryption" />
258 <constructor-arg ref="kustvakt_config" />
margaretha62055f72017-04-11 19:17:43 +0200259 <!-- inject authentication providers to use -->
260 <property name="providers" ref="kustvakt_authproviders" />
261 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +0100262
margaretha62055f72017-04-11 19:17:43 +0200263 <!-- todo: if db interfaces not loaded via spring, does transaction even
264 work then? -->
265 <!-- the transactional advice (i.e. what 'happens'; see the <aop:advisor/>
266 bean below) -->
267 <tx:advice id="txAdvice" transaction-manager="txManager">
268 <!-- the transactional semantics... -->
269 <tx:attributes>
270 <!-- all methods starting with 'get' are read-only -->
margaretha35e1ca22023-11-16 22:00:01 +0100271 <tx:method name="get*" read-only="true"
272 rollback-for="KorAPException" />
margaretha62055f72017-04-11 19:17:43 +0200273 <!-- other methods use the default transaction settings (see below) -->
274 <tx:method name="*" rollback-for="KorAPException" />
275 </tx:attributes>
276 </tx:advice>
Michael Hanlbd852b82015-11-18 22:17:00 +0100277
margaretha62055f72017-04-11 19:17:43 +0200278 <!-- ensure that the above transactional advice runs for any execution of
279 an operation defined by the service interface -->
280 <aop:config>
281 <aop:pointcut id="service"
282 expression="execution(* de.ids_mannheim.korap.interfaces.db.*.*(..))" />
283 <aop:advisor advice-ref="txAdvice" pointcut-ref="service" />
284 </aop:config>
Michael Hanlbd852b82015-11-18 22:17:00 +0100285
margaretha62055f72017-04-11 19:17:43 +0200286 <!-- similarly, don't forget the PlatformTransactionManager -->
287 <bean id="txManager"
288 class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
289 <property name="dataSource" ref="dataSource" />
290 </bean>
Akronbee031a2020-10-29 16:58:14 +0100291</beans>