blob: 1f8bebafc27b2dc4cfb8f406e4cccb8842bf4482 [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>
margaretha64755022024-06-18 10:30:59 +020042 <value>file:./data/test-jdbc.properties</value>
margarethaf6d5a822017-10-19 19:51:20 +020043 <value>classpath:test-hibernate.properties</value>
margaretha64755022024-06-18 10:30:59 +020044 <value>file:./data/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>
margaretha64755022024-06-18 10:30:59 +020047 <value>file:./data/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" />
margarethad0f4af82024-11-19 12:13:24 +0100199 <bean id="queryContextRewrite"
200 class="de.ids_mannheim.korap.rewrite.QueryContextRewrite" />
201
margaretha35e1ca22023-11-16 22:00:01 +0100202
margaretha4fa4b062019-01-28 19:43:30 +0100203 <util:list id="rewriteTasks"
204 value-type="de.ids_mannheim.korap.rewrite.RewriteTask">
margaretha4fa4b062019-01-28 19:43:30 +0100205 <ref bean="foundryRewrite" />
206 <ref bean="collectionRewrite" />
207 <ref bean="virtualCorpusRewrite" />
Akronbee031a2020-10-29 16:58:14 +0100208 <ref bean="queryReferenceRewrite" />
margarethad0f4af82024-11-19 12:13:24 +0100209 <ref bean="queryContextRewrite" />
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>
Akronbee031a2020-10-29 16:58:14 +0100296</beans>