blob: 4924c3cdfcf5da035017ecd24fbf79194171c453 [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>
margaretha4e1d4762023-05-09 13:38:32 +020043 <value>classpath:properties/hibernate.properties</value>
margaretha1960ea52023-02-28 11:20:15 +010044 <value>file:./kustvakt-icc.conf</value>
45 <value>classpath:kustvakt-icc.conf</value>
46 </array>
47 </property>
48 </bean>
margaretha1960ea52023-02-28 11:20:15 +010049
margaretha35e1ca22023-11-16 22:00:01 +010050 <!-- <bean id='cacheManager' class='org.springframework.cache.ehcache.EhCacheCacheManager'
51 p:cacheManager-ref='ehcache' /> <bean id='ehcache' class='org.springframework.cache.ehcache.EhCacheManagerFactoryBean'
52 p:configLocation='classpath:ehcache.xml' p:shared='true' /> -->
53 <bean id="dataSource"
54 class="org.apache.commons.dbcp2.BasicDataSource" lazy-init="true">
margaretha1960ea52023-02-28 11:20:15 +010055 <!-- <property name="driverClassName" value="${jdbc.driverClassName}" /> -->
56 <property name="url" value="${jdbc.url}" />
57 <property name="username" value="${jdbc.username}" />
58 <property name="password" value="${jdbc.password}" />
59 <property name="maxTotal" value="4" />
60 <property name="maxIdle" value="1" />
61 <property name="minIdle" value="1" />
62 <property name="maxWaitMillis" value="15000" />
63 <!--<property name="poolPreparedStatements" value="true"/> -->
64 </bean>
65
66 <!-- use SingleConnection only for testing! -->
67 <bean id="sqliteDataSource"
68 class="org.springframework.jdbc.datasource.SingleConnectionDataSource"
69 lazy-init="true">
70 <!-- <property name="driverClassName" value="${jdbc.driverClassName}" /> -->
71 <property name="url" value="${jdbc.url}" />
72 <property name="username" value="${jdbc.username}" />
73 <property name="password" value="${jdbc.password}" />
74 <property name="connectionProperties">
75 <props>
76 <prop key="date_string_format">yyyy-MM-dd HH:mm:ss</prop>
77 </props>
78 </property>
79
80 <!-- Sqlite can only have a single connection -->
81 <property name="suppressClose">
82 <value>true</value>
83 </property>
84 </bean>
85
margaretha35e1ca22023-11-16 22:00:01 +010086 <bean id="c3p0DataSource"
87 class="com.mchange.v2.c3p0.ComboPooledDataSource"
margaretha1960ea52023-02-28 11:20:15 +010088 destroy-method="close">
89 <property name="driverClass" value="${jdbc.driverClassName}" />
90 <property name="jdbcUrl" value="${jdbc.url}" />
91 <property name="user" value="${jdbc.username}" />
92 <property name="password" value="${jdbc.password}" />
93 <property name="maxPoolSize" value="4" />
94 <property name="minPoolSize" value="1" />
95 <property name="maxStatements" value="1" />
96 <property name="testConnectionOnCheckout" value="true" />
97 </bean>
98
99 <!-- to configure database for sqlite, mysql, etc. migrations -->
margaretha35e1ca22023-11-16 22:00:01 +0100100 <bean id="flywayConfig"
101 class="org.flywaydb.core.api.configuration.ClassicConfiguration">
margaretha1960ea52023-02-28 11:20:15 +0100102 <!-- drop existing tables and create new tables -->
103 <property name="validateOnMigrate" value="true" />
104 <property name="cleanOnValidationError" value="true" />
105 <property name="baselineOnMigrate" value="false" />
margaretha35e1ca22023-11-16 22:00:01 +0100106 <property name="locations"
107 value="#{'${jdbc.schemaPath}'.split(',')}" />
margaretha1960ea52023-02-28 11:20:15 +0100108 <property name="dataSource" ref="sqliteDataSource" />
109 <!-- <property name="dataSource" ref="dataSource" /> -->
110 <property name="outOfOrder" value="true" />
111 </bean>
margaretha35e1ca22023-11-16 22:00:01 +0100112
113 <bean id="flyway" class="org.flywaydb.core.Flyway"
114 init-method="migrate">
115 <constructor-arg ref="flywayConfig" />
margaretha1960ea52023-02-28 11:20:15 +0100116 </bean>
margaretha35e1ca22023-11-16 22:00:01 +0100117
margaretha1960ea52023-02-28 11:20:15 +0100118
margaretha1960ea52023-02-28 11:20:15 +0100119 <bean id="entityManagerFactory"
120 class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
121 <!-- <property name="dataSource" ref="dataSource" /> -->
122 <property name="dataSource" ref="sqliteDataSource" />
123 <property name="packagesToScan">
124 <array>
margaretha5b708792023-05-12 16:55:29 +0200125 <value>de.ids_mannheim.korap.core.entity</value>
margaretha1960ea52023-02-28 11:20:15 +0100126 <value>de.ids_mannheim.korap.entity</value>
127 <value>de.ids_mannheim.korap.oauth2.entity</value>
128 </array>
129 </property>
130 <property name="jpaVendorAdapter">
131 <bean id="jpaVendorAdapter"
132 class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
margaretha35e1ca22023-11-16 22:00:01 +0100133 <property name="databasePlatform"
134 value="${hibernate.dialect}" />
margaretha1960ea52023-02-28 11:20:15 +0100135 </bean>
136 </property>
137 <property name="jpaProperties">
138 <props>
139 <prop key="hibernate.dialect">${hibernate.dialect}</prop>
140 <prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop>
141 <prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
142 <prop key="hibernate.cache.use_query_cache">${hibernate.cache.use_query_cache}</prop>
143 <prop key="hibernate.cache.use_second_level_cache">${hibernate.cache.use_second_level_cache}
144 </prop>
145 <prop key="hibernate.cache.provider_class">${hibernate.cache.provider}</prop>
146 <prop key="hibernate.cache.region.factory_class">${hibernate.cache.region.factory}</prop>
147 <prop key="hibernate.jdbc.time_zone">${hibernate.jdbc.time_zone}</prop>
148 <!-- <prop key="net.sf.ehcache.configurationResourceName">classpath:ehcache.xml</prop> -->
149 </props>
150 </property>
151 </bean>
152
153 <tx:annotation-driven proxy-target-class="true"
154 transaction-manager="transactionManager" />
margaretha35e1ca22023-11-16 22:00:01 +0100155 <bean id="transactionManager"
156 class="org.springframework.orm.jpa.JpaTransactionManager">
157 <property name="entityManagerFactory"
158 ref="entityManagerFactory" />
margaretha1960ea52023-02-28 11:20:15 +0100159 </bean>
160
161 <bean id="transactionTemplate"
162 class="org.springframework.transaction.support.TransactionTemplate">
163 <constructor-arg ref="transactionManager" />
164 </bean>
165
166 <!-- Data access objects -->
167 <bean id="adminDao" class="de.ids_mannheim.korap.dao.AdminDaoImpl" />
margaretha35e1ca22023-11-16 22:00:01 +0100168 <bean id="resourceDao"
169 class="de.ids_mannheim.korap.dao.ResourceDao" />
170 <bean id="accessScopeDao"
171 class="de.ids_mannheim.korap.oauth2.dao.AccessScopeDao" />
172 <bean id="authorizationDao"
173 class="de.ids_mannheim.korap.oauth2.dao.CachedAuthorizationDaoImpl" />
174
margaretha1960ea52023-02-28 11:20:15 +0100175 <!-- Services -->
margaretha35e1ca22023-11-16 22:00:01 +0100176 <bean id="scopeService"
177 class="de.ids_mannheim.korap.oauth2.service.OAuth2ScopeServiceImpl" />
178
179
margaretha1960ea52023-02-28 11:20:15 +0100180 <!-- Controller -->
margaretha35e1ca22023-11-16 22:00:01 +0100181
182
margaretha1960ea52023-02-28 11:20:15 +0100183 <!-- props are injected from default-config.xml -->
margaretha35e1ca22023-11-16 22:00:01 +0100184 <bean id="kustvakt_config"
185 class="de.ids_mannheim.korap.config.FullConfiguration">
margaretha1960ea52023-02-28 11:20:15 +0100186 <constructor-arg name="properties" ref="props" />
187 </bean>
188
margaretha35e1ca22023-11-16 22:00:01 +0100189 <bean id="initializator"
190 class="de.ids_mannheim.korap.init.Initializator"
margaretha1960ea52023-02-28 11:20:15 +0100191 init-method="initTest">
192 </bean>
193
194 <!-- Krill -->
margaretha35e1ca22023-11-16 22:00:01 +0100195 <bean id="search_krill"
196 class="de.ids_mannheim.korap.web.SearchKrill">
margaretha1960ea52023-02-28 11:20:15 +0100197 <constructor-arg value="${krill.indexDir}" />
198 </bean>
199
200 <!-- Validator -->
margaretha35e1ca22023-11-16 22:00:01 +0100201 <bean id="validator"
202 class="de.ids_mannheim.korap.validator.ApacheValidator" />
203
margaretha1960ea52023-02-28 11:20:15 +0100204 <!-- URLValidator -->
margaretha35e1ca22023-11-16 22:00:01 +0100205 <bean id="redirectURIValidator"
206 class="org.apache.commons.validator.routines.UrlValidator">
margaretha1960ea52023-02-28 11:20:15 +0100207 <constructor-arg value="http,https" index="0" />
margaretha35e1ca22023-11-16 22:00:01 +0100208 <constructor-arg index="1" type="long"
209 value="#{T(org.apache.commons.validator.routines.UrlValidator).ALLOW_LOCAL_URLS +
210 T(org.apache.commons.validator.routines.UrlValidator).NO_FRAGMENTS}" />
margaretha1960ea52023-02-28 11:20:15 +0100211 </bean>
margaretha35e1ca22023-11-16 22:00:01 +0100212 <bean id="urlValidator"
213 class="org.apache.commons.validator.routines.UrlValidator">
margaretha1960ea52023-02-28 11:20:15 +0100214 <constructor-arg value="http,https" />
215 </bean>
216
217 <!-- Rewrite -->
margaretha35e1ca22023-11-16 22:00:01 +0100218 <bean id="foundryRewrite"
219 class="de.ids_mannheim.korap.rewrite.FoundryRewrite" />
220 <bean id="collectionRewrite"
221 class="de.ids_mannheim.korap.rewrite.CollectionRewrite" />
222 <bean id="collectionCleanRewrite"
223 class="de.ids_mannheim.korap.rewrite.CollectionCleanRewrite" />
224 <bean id="virtualCorpusRewrite"
225 class="de.ids_mannheim.korap.rewrite.VirtualCorpusRewrite" />
226 <bean id="collectionConstraint"
227 class="de.ids_mannheim.korap.rewrite.CollectionConstraint" />
228 <bean id="queryReferenceRewrite"
229 class="de.ids_mannheim.korap.rewrite.QueryReferenceRewrite" />
230
margaretha1960ea52023-02-28 11:20:15 +0100231 <util:list id="rewriteTasks"
232 value-type="de.ids_mannheim.korap.rewrite.RewriteTask">
margaretha35e1ca22023-11-16 22:00:01 +0100233 <!-- <ref bean="collectionConstraint" /> <ref bean="collectionCleanRewrite"
234 /> -->
margaretha1960ea52023-02-28 11:20:15 +0100235 <ref bean="foundryRewrite" />
236 <!-- <ref bean="collectionRewrite" /> -->
237 <ref bean="virtualCorpusRewrite" />
238 <ref bean="queryReferenceRewrite" />
239 </util:list>
margaretha35e1ca22023-11-16 22:00:01 +0100240
241 <bean id="rewriteHandler"
242 class="de.ids_mannheim.korap.rewrite.RewriteHandler">
243 <constructor-arg ref="rewriteTasks" />
margaretha1960ea52023-02-28 11:20:15 +0100244 </bean>
245
margaretha35e1ca22023-11-16 22:00:01 +0100246 <bean id="kustvaktResponseHandler"
247 class="de.ids_mannheim.korap.web.KustvaktResponseHandler">
margaretha1960ea52023-02-28 11:20:15 +0100248 </bean>
249
250 <!-- OAuth -->
margaretha35e1ca22023-11-16 22:00:01 +0100251 <bean id="oauth2ResponseHandler"
252 class="de.ids_mannheim.korap.web.OAuth2ResponseHandler">
margaretha1960ea52023-02-28 11:20:15 +0100253 </bean>
254
margaretha35e1ca22023-11-16 22:00:01 +0100255 <bean name="kustvakt_encryption"
256 class="de.ids_mannheim.korap.encryption.KustvaktEncryption">
margaretha1960ea52023-02-28 11:20:15 +0100257 <constructor-arg ref="kustvakt_config" />
258 </bean>
259
260 <!-- authentication providers to use -->
261 <bean id="basic_auth"
262 class="de.ids_mannheim.korap.authentication.BasicAuthentication" />
263
264 <bean id="oauth2_auth"
265 class="de.ids_mannheim.korap.authentication.OAuth2Authentication" />
266
267
268 <util:list id="kustvakt_authproviders"
269 value-type="de.ids_mannheim.korap.interfaces.AuthenticationIface">
270 <ref bean="basic_auth" />
271 <ref bean="oauth2_auth" />
272 </util:list>
273
274
margaretha1960ea52023-02-28 11:20:15 +0100275 <!-- specify type for constructor argument -->
276 <bean id="authenticationManager"
277 class="de.ids_mannheim.korap.authentication.KustvaktAuthenticationManager">
margaretha35e1ca22023-11-16 22:00:01 +0100278 <constructor-arg
279 type="de.ids_mannheim.korap.interfaces.EncryptionIface"
margaretha1960ea52023-02-28 11:20:15 +0100280 ref="kustvakt_encryption" />
281 <constructor-arg ref="kustvakt_config" />
margaretha1960ea52023-02-28 11:20:15 +0100282 <!-- inject authentication providers to use -->
283 <property name="providers" ref="kustvakt_authproviders" />
284 </bean>
285
286 <!-- todo: if db interfaces not loaded via spring, does transaction even
287 work then? -->
288 <!-- the transactional advice (i.e. what 'happens'; see the <aop:advisor/>
289 bean below) -->
290 <tx:advice id="txAdvice" transaction-manager="txManager">
291 <!-- the transactional semantics... -->
292 <tx:attributes>
293 <!-- all methods starting with 'get' are read-only -->
margaretha35e1ca22023-11-16 22:00:01 +0100294 <tx:method name="get*" read-only="true"
295 rollback-for="KorAPException" />
margaretha1960ea52023-02-28 11:20:15 +0100296 <!-- other methods use the default transaction settings (see below) -->
297 <tx:method name="*" rollback-for="KorAPException" />
298 </tx:attributes>
299 </tx:advice>
300
301 <!-- ensure that the above transactional advice runs for any execution of
302 an operation defined by the service interface -->
303 <aop:config>
304 <aop:pointcut id="service"
305 expression="execution(* de.ids_mannheim.korap.interfaces.db.*.*(..))" />
306 <aop:advisor advice-ref="txAdvice" pointcut-ref="service" />
307 </aop:config>
308
309 <!-- similarly, don't forget the PlatformTransactionManager -->
310 <bean id="txManager"
311 class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
312 <property name="dataSource" ref="dataSource" />
313 </bean>
314
margaretha1960ea52023-02-28 11:20:15 +0100315</beans>