blob: 0c09b1d6218bf9cd072b44fc20c5b52bc7875e49 [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" />
margaretha35e1ca22023-11-16 22:00:01 +0100220 <bean id="virtualCorpusRewrite"
221 class="de.ids_mannheim.korap.rewrite.VirtualCorpusRewrite" />
margaretha35e1ca22023-11-16 22:00:01 +0100222 <bean id="queryReferenceRewrite"
223 class="de.ids_mannheim.korap.rewrite.QueryReferenceRewrite" />
224
margaretha1960ea52023-02-28 11:20:15 +0100225 <util:list id="rewriteTasks"
226 value-type="de.ids_mannheim.korap.rewrite.RewriteTask">
margaretha1960ea52023-02-28 11:20:15 +0100227 <ref bean="foundryRewrite" />
margaretha1960ea52023-02-28 11:20:15 +0100228 <ref bean="virtualCorpusRewrite" />
229 <ref bean="queryReferenceRewrite" />
230 </util:list>
margaretha35e1ca22023-11-16 22:00:01 +0100231
232 <bean id="rewriteHandler"
233 class="de.ids_mannheim.korap.rewrite.RewriteHandler">
234 <constructor-arg ref="rewriteTasks" />
margaretha1960ea52023-02-28 11:20:15 +0100235 </bean>
236
margaretha35e1ca22023-11-16 22:00:01 +0100237 <bean id="kustvaktResponseHandler"
238 class="de.ids_mannheim.korap.web.KustvaktResponseHandler">
margaretha1960ea52023-02-28 11:20:15 +0100239 </bean>
240
241 <!-- OAuth -->
margaretha35e1ca22023-11-16 22:00:01 +0100242 <bean id="oauth2ResponseHandler"
243 class="de.ids_mannheim.korap.web.OAuth2ResponseHandler">
margaretha1960ea52023-02-28 11:20:15 +0100244 </bean>
245
margaretha35e1ca22023-11-16 22:00:01 +0100246 <bean name="kustvakt_encryption"
247 class="de.ids_mannheim.korap.encryption.KustvaktEncryption">
margaretha1960ea52023-02-28 11:20:15 +0100248 <constructor-arg ref="kustvakt_config" />
249 </bean>
250
251 <!-- authentication providers to use -->
252 <bean id="basic_auth"
253 class="de.ids_mannheim.korap.authentication.BasicAuthentication" />
254
255 <bean id="oauth2_auth"
256 class="de.ids_mannheim.korap.authentication.OAuth2Authentication" />
257
258
259 <util:list id="kustvakt_authproviders"
260 value-type="de.ids_mannheim.korap.interfaces.AuthenticationIface">
261 <ref bean="basic_auth" />
262 <ref bean="oauth2_auth" />
263 </util:list>
264
265
margaretha1960ea52023-02-28 11:20:15 +0100266 <!-- specify type for constructor argument -->
267 <bean id="authenticationManager"
268 class="de.ids_mannheim.korap.authentication.KustvaktAuthenticationManager">
margaretha35e1ca22023-11-16 22:00:01 +0100269 <constructor-arg
270 type="de.ids_mannheim.korap.interfaces.EncryptionIface"
margaretha1960ea52023-02-28 11:20:15 +0100271 ref="kustvakt_encryption" />
272 <constructor-arg ref="kustvakt_config" />
margaretha1960ea52023-02-28 11:20:15 +0100273 <!-- inject authentication providers to use -->
274 <property name="providers" ref="kustvakt_authproviders" />
275 </bean>
276
277 <!-- todo: if db interfaces not loaded via spring, does transaction even
278 work then? -->
279 <!-- the transactional advice (i.e. what 'happens'; see the <aop:advisor/>
280 bean below) -->
281 <tx:advice id="txAdvice" transaction-manager="txManager">
282 <!-- the transactional semantics... -->
283 <tx:attributes>
284 <!-- all methods starting with 'get' are read-only -->
margaretha35e1ca22023-11-16 22:00:01 +0100285 <tx:method name="get*" read-only="true"
286 rollback-for="KorAPException" />
margaretha1960ea52023-02-28 11:20:15 +0100287 <!-- other methods use the default transaction settings (see below) -->
288 <tx:method name="*" rollback-for="KorAPException" />
289 </tx:attributes>
290 </tx:advice>
291
292 <!-- ensure that the above transactional advice runs for any execution of
293 an operation defined by the service interface -->
294 <aop:config>
295 <aop:pointcut id="service"
296 expression="execution(* de.ids_mannheim.korap.interfaces.db.*.*(..))" />
297 <aop:advisor advice-ref="txAdvice" pointcut-ref="service" />
298 </aop:config>
299
300 <!-- similarly, don't forget the PlatformTransactionManager -->
301 <bean id="txManager"
302 class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
303 <property name="dataSource" ref="dataSource" />
304 </bean>
305
margaretha1960ea52023-02-28 11:20:15 +0100306</beans>