blob: 252ba8a30437850957f74ab18f088a6d988ebc8f [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>
42 <value>file:./jdbc.properties</value>
43 <value>classpath:properties/mail.properties</value>
44 <value>file:./mail.properties</value>
margaretha4e1d4762023-05-09 13:38:32 +020045 <value>classpath:properties/hibernate.properties</value>
margaretha1960ea52023-02-28 11:20:15 +010046 <value>file:./kustvakt-icc.conf</value>
47 <value>classpath:kustvakt-icc.conf</value>
48 </array>
49 </property>
50 </bean>
margaretha1960ea52023-02-28 11:20:15 +010051
margaretha35e1ca22023-11-16 22:00:01 +010052 <!-- <bean id='cacheManager' class='org.springframework.cache.ehcache.EhCacheCacheManager'
53 p:cacheManager-ref='ehcache' /> <bean id='ehcache' class='org.springframework.cache.ehcache.EhCacheManagerFactoryBean'
54 p:configLocation='classpath:ehcache.xml' p:shared='true' /> -->
55 <bean id="dataSource"
56 class="org.apache.commons.dbcp2.BasicDataSource" lazy-init="true">
margaretha1960ea52023-02-28 11:20:15 +010057 <!-- <property name="driverClassName" value="${jdbc.driverClassName}" /> -->
58 <property name="url" value="${jdbc.url}" />
59 <property name="username" value="${jdbc.username}" />
60 <property name="password" value="${jdbc.password}" />
61 <property name="maxTotal" value="4" />
62 <property name="maxIdle" value="1" />
63 <property name="minIdle" value="1" />
64 <property name="maxWaitMillis" value="15000" />
65 <!--<property name="poolPreparedStatements" value="true"/> -->
66 </bean>
67
68 <!-- use SingleConnection only for testing! -->
69 <bean id="sqliteDataSource"
70 class="org.springframework.jdbc.datasource.SingleConnectionDataSource"
71 lazy-init="true">
72 <!-- <property name="driverClassName" value="${jdbc.driverClassName}" /> -->
73 <property name="url" value="${jdbc.url}" />
74 <property name="username" value="${jdbc.username}" />
75 <property name="password" value="${jdbc.password}" />
76 <property name="connectionProperties">
77 <props>
78 <prop key="date_string_format">yyyy-MM-dd HH:mm:ss</prop>
79 </props>
80 </property>
81
82 <!-- Sqlite can only have a single connection -->
83 <property name="suppressClose">
84 <value>true</value>
85 </property>
86 </bean>
87
margaretha35e1ca22023-11-16 22:00:01 +010088 <bean id="c3p0DataSource"
89 class="com.mchange.v2.c3p0.ComboPooledDataSource"
margaretha1960ea52023-02-28 11:20:15 +010090 destroy-method="close">
91 <property name="driverClass" value="${jdbc.driverClassName}" />
92 <property name="jdbcUrl" value="${jdbc.url}" />
93 <property name="user" value="${jdbc.username}" />
94 <property name="password" value="${jdbc.password}" />
95 <property name="maxPoolSize" value="4" />
96 <property name="minPoolSize" value="1" />
97 <property name="maxStatements" value="1" />
98 <property name="testConnectionOnCheckout" value="true" />
99 </bean>
100
101 <!-- to configure database for sqlite, mysql, etc. migrations -->
margaretha35e1ca22023-11-16 22:00:01 +0100102 <bean id="flywayConfig"
103 class="org.flywaydb.core.api.configuration.ClassicConfiguration">
margaretha1960ea52023-02-28 11:20:15 +0100104 <!-- drop existing tables and create new tables -->
105 <property name="validateOnMigrate" value="true" />
106 <property name="cleanOnValidationError" value="true" />
107 <property name="baselineOnMigrate" value="false" />
margaretha35e1ca22023-11-16 22:00:01 +0100108 <property name="locations"
109 value="#{'${jdbc.schemaPath}'.split(',')}" />
margaretha1960ea52023-02-28 11:20:15 +0100110 <property name="dataSource" ref="sqliteDataSource" />
111 <!-- <property name="dataSource" ref="dataSource" /> -->
112 <property name="outOfOrder" value="true" />
113 </bean>
margaretha35e1ca22023-11-16 22:00:01 +0100114
115 <bean id="flyway" class="org.flywaydb.core.Flyway"
116 init-method="migrate">
117 <constructor-arg ref="flywayConfig" />
margaretha1960ea52023-02-28 11:20:15 +0100118 </bean>
margaretha35e1ca22023-11-16 22:00:01 +0100119
margaretha1960ea52023-02-28 11:20:15 +0100120
margaretha1960ea52023-02-28 11:20:15 +0100121 <bean id="entityManagerFactory"
122 class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
123 <!-- <property name="dataSource" ref="dataSource" /> -->
124 <property name="dataSource" ref="sqliteDataSource" />
125 <property name="packagesToScan">
126 <array>
margaretha5b708792023-05-12 16:55:29 +0200127 <value>de.ids_mannheim.korap.core.entity</value>
margaretha1960ea52023-02-28 11:20:15 +0100128 <value>de.ids_mannheim.korap.entity</value>
129 <value>de.ids_mannheim.korap.oauth2.entity</value>
130 </array>
131 </property>
132 <property name="jpaVendorAdapter">
133 <bean id="jpaVendorAdapter"
134 class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
margaretha35e1ca22023-11-16 22:00:01 +0100135 <property name="databasePlatform"
136 value="${hibernate.dialect}" />
margaretha1960ea52023-02-28 11:20:15 +0100137 </bean>
138 </property>
139 <property name="jpaProperties">
140 <props>
141 <prop key="hibernate.dialect">${hibernate.dialect}</prop>
142 <prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop>
143 <prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
144 <prop key="hibernate.cache.use_query_cache">${hibernate.cache.use_query_cache}</prop>
145 <prop key="hibernate.cache.use_second_level_cache">${hibernate.cache.use_second_level_cache}
146 </prop>
147 <prop key="hibernate.cache.provider_class">${hibernate.cache.provider}</prop>
148 <prop key="hibernate.cache.region.factory_class">${hibernate.cache.region.factory}</prop>
149 <prop key="hibernate.jdbc.time_zone">${hibernate.jdbc.time_zone}</prop>
150 <!-- <prop key="net.sf.ehcache.configurationResourceName">classpath:ehcache.xml</prop> -->
151 </props>
152 </property>
153 </bean>
154
155 <tx:annotation-driven proxy-target-class="true"
156 transaction-manager="transactionManager" />
margaretha35e1ca22023-11-16 22:00:01 +0100157 <bean id="transactionManager"
158 class="org.springframework.orm.jpa.JpaTransactionManager">
159 <property name="entityManagerFactory"
160 ref="entityManagerFactory" />
margaretha1960ea52023-02-28 11:20:15 +0100161 </bean>
162
163 <bean id="transactionTemplate"
164 class="org.springframework.transaction.support.TransactionTemplate">
165 <constructor-arg ref="transactionManager" />
166 </bean>
167
168 <!-- Data access objects -->
169 <bean id="adminDao" class="de.ids_mannheim.korap.dao.AdminDaoImpl" />
margaretha35e1ca22023-11-16 22:00:01 +0100170 <bean id="resourceDao"
171 class="de.ids_mannheim.korap.dao.ResourceDao" />
172 <bean id="accessScopeDao"
173 class="de.ids_mannheim.korap.oauth2.dao.AccessScopeDao" />
174 <bean id="authorizationDao"
175 class="de.ids_mannheim.korap.oauth2.dao.CachedAuthorizationDaoImpl" />
176
margaretha1960ea52023-02-28 11:20:15 +0100177 <!-- Services -->
margaretha35e1ca22023-11-16 22:00:01 +0100178 <bean id="scopeService"
179 class="de.ids_mannheim.korap.oauth2.service.OAuth2ScopeServiceImpl" />
180
181
margaretha1960ea52023-02-28 11:20:15 +0100182 <!-- Controller -->
margaretha35e1ca22023-11-16 22:00:01 +0100183
184
margaretha1960ea52023-02-28 11:20:15 +0100185 <!-- props are injected from default-config.xml -->
margaretha35e1ca22023-11-16 22:00:01 +0100186 <bean id="kustvakt_config"
187 class="de.ids_mannheim.korap.config.FullConfiguration">
margaretha1960ea52023-02-28 11:20:15 +0100188 <constructor-arg name="properties" ref="props" />
189 </bean>
190
margaretha35e1ca22023-11-16 22:00:01 +0100191 <bean id="initializator"
192 class="de.ids_mannheim.korap.init.Initializator"
margaretha1960ea52023-02-28 11:20:15 +0100193 init-method="initTest">
194 </bean>
195
196 <!-- Krill -->
margaretha35e1ca22023-11-16 22:00:01 +0100197 <bean id="search_krill"
198 class="de.ids_mannheim.korap.web.SearchKrill">
margaretha1960ea52023-02-28 11:20:15 +0100199 <constructor-arg value="${krill.indexDir}" />
200 </bean>
201
202 <!-- Validator -->
margaretha35e1ca22023-11-16 22:00:01 +0100203 <bean id="validator"
204 class="de.ids_mannheim.korap.validator.ApacheValidator" />
205
margaretha1960ea52023-02-28 11:20:15 +0100206 <!-- URLValidator -->
margaretha35e1ca22023-11-16 22:00:01 +0100207 <bean id="redirectURIValidator"
208 class="org.apache.commons.validator.routines.UrlValidator">
margaretha1960ea52023-02-28 11:20:15 +0100209 <constructor-arg value="http,https" index="0" />
margaretha35e1ca22023-11-16 22:00:01 +0100210 <constructor-arg index="1" type="long"
211 value="#{T(org.apache.commons.validator.routines.UrlValidator).ALLOW_LOCAL_URLS +
212 T(org.apache.commons.validator.routines.UrlValidator).NO_FRAGMENTS}" />
margaretha1960ea52023-02-28 11:20:15 +0100213 </bean>
margaretha35e1ca22023-11-16 22:00:01 +0100214 <bean id="urlValidator"
215 class="org.apache.commons.validator.routines.UrlValidator">
margaretha1960ea52023-02-28 11:20:15 +0100216 <constructor-arg value="http,https" />
217 </bean>
218
219 <!-- Rewrite -->
margaretha35e1ca22023-11-16 22:00:01 +0100220 <bean id="foundryRewrite"
221 class="de.ids_mannheim.korap.rewrite.FoundryRewrite" />
222 <bean id="collectionRewrite"
223 class="de.ids_mannheim.korap.rewrite.CollectionRewrite" />
224 <bean id="collectionCleanRewrite"
225 class="de.ids_mannheim.korap.rewrite.CollectionCleanRewrite" />
226 <bean id="virtualCorpusRewrite"
227 class="de.ids_mannheim.korap.rewrite.VirtualCorpusRewrite" />
228 <bean id="collectionConstraint"
229 class="de.ids_mannheim.korap.rewrite.CollectionConstraint" />
230 <bean id="queryReferenceRewrite"
231 class="de.ids_mannheim.korap.rewrite.QueryReferenceRewrite" />
232
margaretha1960ea52023-02-28 11:20:15 +0100233 <util:list id="rewriteTasks"
234 value-type="de.ids_mannheim.korap.rewrite.RewriteTask">
margaretha35e1ca22023-11-16 22:00:01 +0100235 <!-- <ref bean="collectionConstraint" /> <ref bean="collectionCleanRewrite"
236 /> -->
margaretha1960ea52023-02-28 11:20:15 +0100237 <ref bean="foundryRewrite" />
238 <!-- <ref bean="collectionRewrite" /> -->
239 <ref bean="virtualCorpusRewrite" />
240 <ref bean="queryReferenceRewrite" />
241 </util:list>
margaretha35e1ca22023-11-16 22:00:01 +0100242
243 <bean id="rewriteHandler"
244 class="de.ids_mannheim.korap.rewrite.RewriteHandler">
245 <constructor-arg ref="rewriteTasks" />
margaretha1960ea52023-02-28 11:20:15 +0100246 </bean>
247
margaretha35e1ca22023-11-16 22:00:01 +0100248 <bean id="kustvaktResponseHandler"
249 class="de.ids_mannheim.korap.web.KustvaktResponseHandler">
margaretha1960ea52023-02-28 11:20:15 +0100250 </bean>
251
252 <!-- OAuth -->
margaretha35e1ca22023-11-16 22:00:01 +0100253 <bean id="oauth2ResponseHandler"
254 class="de.ids_mannheim.korap.web.OAuth2ResponseHandler">
margaretha1960ea52023-02-28 11:20:15 +0100255 </bean>
256
margaretha35e1ca22023-11-16 22:00:01 +0100257 <bean name="kustvakt_encryption"
258 class="de.ids_mannheim.korap.encryption.KustvaktEncryption">
margaretha1960ea52023-02-28 11:20:15 +0100259 <constructor-arg ref="kustvakt_config" />
260 </bean>
261
262 <!-- authentication providers to use -->
263 <bean id="basic_auth"
264 class="de.ids_mannheim.korap.authentication.BasicAuthentication" />
265
266 <bean id="oauth2_auth"
267 class="de.ids_mannheim.korap.authentication.OAuth2Authentication" />
268
269
270 <util:list id="kustvakt_authproviders"
271 value-type="de.ids_mannheim.korap.interfaces.AuthenticationIface">
272 <ref bean="basic_auth" />
273 <ref bean="oauth2_auth" />
274 </util:list>
275
276
margaretha1960ea52023-02-28 11:20:15 +0100277 <!-- specify type for constructor argument -->
278 <bean id="authenticationManager"
279 class="de.ids_mannheim.korap.authentication.KustvaktAuthenticationManager">
margaretha35e1ca22023-11-16 22:00:01 +0100280 <constructor-arg
281 type="de.ids_mannheim.korap.interfaces.EncryptionIface"
margaretha1960ea52023-02-28 11:20:15 +0100282 ref="kustvakt_encryption" />
283 <constructor-arg ref="kustvakt_config" />
margaretha1960ea52023-02-28 11:20:15 +0100284 <!-- inject authentication providers to use -->
285 <property name="providers" ref="kustvakt_authproviders" />
286 </bean>
287
288 <!-- todo: if db interfaces not loaded via spring, does transaction even
289 work then? -->
290 <!-- the transactional advice (i.e. what 'happens'; see the <aop:advisor/>
291 bean below) -->
292 <tx:advice id="txAdvice" transaction-manager="txManager">
293 <!-- the transactional semantics... -->
294 <tx:attributes>
295 <!-- all methods starting with 'get' are read-only -->
margaretha35e1ca22023-11-16 22:00:01 +0100296 <tx:method name="get*" read-only="true"
297 rollback-for="KorAPException" />
margaretha1960ea52023-02-28 11:20:15 +0100298 <!-- other methods use the default transaction settings (see below) -->
299 <tx:method name="*" rollback-for="KorAPException" />
300 </tx:attributes>
301 </tx:advice>
302
303 <!-- ensure that the above transactional advice runs for any execution of
304 an operation defined by the service interface -->
305 <aop:config>
306 <aop:pointcut id="service"
307 expression="execution(* de.ids_mannheim.korap.interfaces.db.*.*(..))" />
308 <aop:advisor advice-ref="txAdvice" pointcut-ref="service" />
309 </aop:config>
310
311 <!-- similarly, don't forget the PlatformTransactionManager -->
312 <bean id="txManager"
313 class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
314 <property name="dataSource" ref="dataSource" />
315 </bean>
316
margaretha1960ea52023-02-28 11:20:15 +0100317</beans>