blob: 3c9c9ae8bdfdaef07573401f82ffc24166972637 [file] [log] [blame]
margaretha1960ea52023-02-28 11:20:15 +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"
margaretha1960ea52023-02-28 11:20:15 +01009 xmlns:cache="http://www.springframework.org/schema/cache"
10 xsi:schemaLocation="http://www.springframework.org/schema/beans
11 http://www.springframework.org/schema/beans/spring-beans.xsd
12 http://www.springframework.org/schema/tx
13 http://www.springframework.org/schema/tx/spring-tx.xsd
14 http://www.springframework.org/schema/aop
15 http://www.springframework.org/schema/aop/spring-aop.xsd
16 http://www.springframework.org/schema/context
17 http://www.springframework.org/schema/context/spring-context.xsd
18 http://www.springframework.org/schema/util
19 http://www.springframework.org/schema/util/spring-util.xsd">
20
margaretha35e1ca22023-11-16 22:00:01 +010021 <context:component-scan
22 base-package="de.ids_mannheim.korap" />
margaretha1960ea52023-02-28 11:20:15 +010023 <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>file:./kustvakt-icc.conf</value>
31 <value>classpath:kustvakt-icc.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>
41 <value>classpath:test-jdbc.properties</value>
margaretha29060842025-04-07 09:09:42 +020042 <value>file:./data/jdbc.properties</value>
margaretha4e1d4762023-05-09 13:38:32 +020043 <value>classpath:properties/hibernate.properties</value>
margaretha1960ea52023-02-28 11:20:15 +010044 <value>classpath:kustvakt-icc.conf</value>
margaretha29060842025-04-07 09:09:42 +020045 <value>file:./data/kustvakt-icc.conf</value>
margaretha1960ea52023-02-28 11:20:15 +010046 </array>
47 </property>
48 </bean>
margaretha1960ea52023-02-28 11:20:15 +010049
margaretha29060842025-04-07 09:09:42 +020050
51 <!-- props are injected from default-config.xml -->
52 <bean id="kustvakt_config"
53 class="de.ids_mannheim.korap.config.FullConfiguration">
54 <constructor-arg name="properties" ref="props" />
55 </bean>
56
margaretha35e1ca22023-11-16 22:00:01 +010057 <bean id="dataSource"
58 class="org.apache.commons.dbcp2.BasicDataSource" lazy-init="true">
margaretha1960ea52023-02-28 11:20:15 +010059 <!-- <property name="driverClassName" value="${jdbc.driverClassName}" /> -->
60 <property name="url" value="${jdbc.url}" />
61 <property name="username" value="${jdbc.username}" />
62 <property name="password" value="${jdbc.password}" />
63 <property name="maxTotal" value="4" />
64 <property name="maxIdle" value="1" />
65 <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"
margaretha1960ea52023-02-28 11:20:15 +010072 destroy-method="close">
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="1" />
80 <property name="testConnectionOnCheckout" value="true" />
81 </bean>
82
83 <!-- 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">
margaretha1960ea52023-02-28 11:20:15 +010086 <!-- drop existing tables and create new tables -->
87 <property name="validateOnMigrate" value="true" />
88 <property name="cleanOnValidationError" value="true" />
89 <property name="baselineOnMigrate" value="false" />
margaretha29060842025-04-07 09:09:42 +020090 <property name="cleanDisabled" value="false" />
margaretha35e1ca22023-11-16 22:00:01 +010091 <property name="locations"
92 value="#{'${jdbc.schemaPath}'.split(',')}" />
margaretha29060842025-04-07 09:09:42 +020093 <property name="dataSource" ref="dataSource" />
margaretha1960ea52023-02-28 11:20:15 +010094 <property name="outOfOrder" value="true" />
95 </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" />
margaretha1960ea52023-02-28 11:20:15 +0100100 </bean>
margaretha35e1ca22023-11-16 22:00:01 +0100101
margaretha1960ea52023-02-28 11:20:15 +0100102
margaretha1960ea52023-02-28 11:20:15 +0100103 <bean id="entityManagerFactory"
104 class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
margaretha29060842025-04-07 09:09:42 +0200105 <property name="dataSource" ref="dataSource" />
margaretha1960ea52023-02-28 11:20:15 +0100106 <property name="packagesToScan">
107 <array>
margaretha5b708792023-05-12 16:55:29 +0200108 <value>de.ids_mannheim.korap.core.entity</value>
margaretha1960ea52023-02-28 11:20:15 +0100109 <value>de.ids_mannheim.korap.entity</value>
110 <value>de.ids_mannheim.korap.oauth2.entity</value>
111 </array>
112 </property>
113 <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}" />
margaretha1960ea52023-02-28 11:20:15 +0100118 </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>
130 <prop key="hibernate.jdbc.time_zone">${hibernate.jdbc.time_zone}</prop>
131 <!-- <prop key="net.sf.ehcache.configurationResourceName">classpath:ehcache.xml</prop> -->
132 </props>
133 </property>
134 </bean>
135
136 <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" />
margaretha1960ea52023-02-28 11:20:15 +0100142 </bean>
143
144 <bean id="transactionTemplate"
145 class="org.springframework.transaction.support.TransactionTemplate">
146 <constructor-arg ref="transactionManager" />
147 </bean>
148
149 <!-- Data access objects -->
150 <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
margaretha1960ea52023-02-28 11:20:15 +0100158 <!-- 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"
margaretha1960ea52023-02-28 11:20:15 +0100164 init-method="initTest">
165 </bean>
166
167 <!-- Krill -->
margaretha35e1ca22023-11-16 22:00:01 +0100168 <bean id="search_krill"
169 class="de.ids_mannheim.korap.web.SearchKrill">
margaretha1960ea52023-02-28 11:20:15 +0100170 <constructor-arg value="${krill.indexDir}" />
171 </bean>
172
173 <!-- Validator -->
margaretha35e1ca22023-11-16 22:00:01 +0100174 <bean id="validator"
175 class="de.ids_mannheim.korap.validator.ApacheValidator" />
176
margaretha1960ea52023-02-28 11:20:15 +0100177 <!-- URLValidator -->
margaretha35e1ca22023-11-16 22:00:01 +0100178 <bean id="redirectURIValidator"
179 class="org.apache.commons.validator.routines.UrlValidator">
margaretha1960ea52023-02-28 11:20:15 +0100180 <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}" />
margaretha1960ea52023-02-28 11:20:15 +0100184 </bean>
margaretha35e1ca22023-11-16 22:00:01 +0100185 <bean id="urlValidator"
186 class="org.apache.commons.validator.routines.UrlValidator">
margaretha1960ea52023-02-28 11:20:15 +0100187 <constructor-arg value="http,https" />
188 </bean>
189
190 <!-- Rewrite -->
margaretha35e1ca22023-11-16 22:00:01 +0100191 <bean id="foundryRewrite"
192 class="de.ids_mannheim.korap.rewrite.FoundryRewrite" />
margaretha35e1ca22023-11-16 22:00:01 +0100193 <bean id="virtualCorpusRewrite"
194 class="de.ids_mannheim.korap.rewrite.VirtualCorpusRewrite" />
margaretha35e1ca22023-11-16 22:00:01 +0100195 <bean id="queryReferenceRewrite"
196 class="de.ids_mannheim.korap.rewrite.QueryReferenceRewrite" />
margaretha29060842025-04-07 09:09:42 +0200197 <bean id="queryContextRewrite"
198 class="de.ids_mannheim.korap.rewrite.QueryContextRewrite" />
199
margaretha35e1ca22023-11-16 22:00:01 +0100200
margaretha1960ea52023-02-28 11:20:15 +0100201 <util:list id="rewriteTasks"
202 value-type="de.ids_mannheim.korap.rewrite.RewriteTask">
margaretha1960ea52023-02-28 11:20:15 +0100203 <ref bean="foundryRewrite" />
margaretha1960ea52023-02-28 11:20:15 +0100204 <ref bean="virtualCorpusRewrite" />
205 <ref bean="queryReferenceRewrite" />
margaretha29060842025-04-07 09:09:42 +0200206 <ref bean="queryContextRewrite" />
margaretha1960ea52023-02-28 11:20:15 +0100207 </util:list>
margaretha35e1ca22023-11-16 22:00:01 +0100208
209 <bean id="rewriteHandler"
210 class="de.ids_mannheim.korap.rewrite.RewriteHandler">
211 <constructor-arg ref="rewriteTasks" />
margaretha1960ea52023-02-28 11:20:15 +0100212 </bean>
213
margaretha29060842025-04-07 09:09:42 +0200214 <util:list id="statisticsRewriteTasks"
215 value-type="de.ids_mannheim.korap.rewrite.RewriteTask">
216 <ref bean="foundryRewrite" />
217 <ref bean="virtualCorpusRewrite" />
218 <ref bean="queryReferenceRewrite" />
219 </util:list>
220
221 <bean id="statisticsRewriteHandler"
222 class="de.ids_mannheim.korap.rewrite.RewriteHandler">
223 <constructor-arg ref="statisticsRewriteTasks" />
224 </bean>
225
margaretha35e1ca22023-11-16 22:00:01 +0100226 <bean id="kustvaktResponseHandler"
227 class="de.ids_mannheim.korap.web.KustvaktResponseHandler">
margaretha1960ea52023-02-28 11:20:15 +0100228 </bean>
229
230 <!-- OAuth -->
margaretha35e1ca22023-11-16 22:00:01 +0100231 <bean id="oauth2ResponseHandler"
232 class="de.ids_mannheim.korap.web.OAuth2ResponseHandler">
margaretha1960ea52023-02-28 11:20:15 +0100233 </bean>
234
margaretha35e1ca22023-11-16 22:00:01 +0100235 <bean name="kustvakt_encryption"
236 class="de.ids_mannheim.korap.encryption.KustvaktEncryption">
margaretha1960ea52023-02-28 11:20:15 +0100237 <constructor-arg ref="kustvakt_config" />
238 </bean>
239
240 <!-- authentication providers to use -->
241 <bean id="basic_auth"
242 class="de.ids_mannheim.korap.authentication.BasicAuthentication" />
243
244 <bean id="oauth2_auth"
245 class="de.ids_mannheim.korap.authentication.OAuth2Authentication" />
246
247
248 <util:list id="kustvakt_authproviders"
249 value-type="de.ids_mannheim.korap.interfaces.AuthenticationIface">
250 <ref bean="basic_auth" />
251 <ref bean="oauth2_auth" />
252 </util:list>
253
254
margaretha1960ea52023-02-28 11:20:15 +0100255 <!-- specify type for constructor argument -->
256 <bean id="authenticationManager"
257 class="de.ids_mannheim.korap.authentication.KustvaktAuthenticationManager">
margaretha35e1ca22023-11-16 22:00:01 +0100258 <constructor-arg
259 type="de.ids_mannheim.korap.interfaces.EncryptionIface"
margaretha1960ea52023-02-28 11:20:15 +0100260 ref="kustvakt_encryption" />
261 <constructor-arg ref="kustvakt_config" />
margaretha1960ea52023-02-28 11:20:15 +0100262 <!-- inject authentication providers to use -->
263 <property name="providers" ref="kustvakt_authproviders" />
264 </bean>
265
266 <!-- todo: if db interfaces not loaded via spring, does transaction even
267 work then? -->
268 <!-- the transactional advice (i.e. what 'happens'; see the <aop:advisor/>
269 bean below) -->
270 <tx:advice id="txAdvice" transaction-manager="txManager">
271 <!-- the transactional semantics... -->
272 <tx:attributes>
273 <!-- all methods starting with 'get' are read-only -->
margaretha35e1ca22023-11-16 22:00:01 +0100274 <tx:method name="get*" read-only="true"
275 rollback-for="KorAPException" />
margaretha1960ea52023-02-28 11:20:15 +0100276 <!-- other methods use the default transaction settings (see below) -->
277 <tx:method name="*" rollback-for="KorAPException" />
278 </tx:attributes>
279 </tx:advice>
280
281 <!-- ensure that the above transactional advice runs for any execution of
282 an operation defined by the service interface -->
283 <aop:config>
284 <aop:pointcut id="service"
285 expression="execution(* de.ids_mannheim.korap.interfaces.db.*.*(..))" />
286 <aop:advisor advice-ref="txAdvice" pointcut-ref="service" />
287 </aop:config>
288
289 <!-- similarly, don't forget the PlatformTransactionManager -->
290 <bean id="txManager"
291 class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
292 <property name="dataSource" ref="dataSource" />
293 </bean>
294
margaretha1960ea52023-02-28 11:20:15 +0100295</beans>