blob: ac4d373c579058a2845bb92bdc00de74b4f88a2f [file] [log] [blame]
margaretha46e2c952024-05-23 09:09:54 +02001<?xml version="1.0" encoding="UTF-8"?>
2<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3 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"
9 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
21 <context:component-scan
22 base-package="de.ids_mannheim.korap" />
23 <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>classpath:kustvakt-dnb.conf</value>
31 <value>file:./kustvakt-dnb.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:./test-jdbc.properties</value>
margaretha46e2c952024-05-23 09:09:54 +020043 <value>classpath:test-hibernate.properties</value>
44 <value>file:./kustvakt-dnb.conf</value>
45 <value>classpath:kustvakt-dnb.conf</value>
46 </array>
47 </property>
48 </bean>
49
50 <!-- <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
54 <bean id="dataSource"
55 class="org.apache.commons.dbcp2.BasicDataSource" lazy-init="true">
56 <!-- <property name="driverClassName" value="${jdbc.driverClassName}" /> -->
57 <property name="url" value="${jdbc.url}" />
58 <property name="username" value="${jdbc.username}" />
59 <property name="password" value="${jdbc.password}" />
60 <property name="maxTotal" value="4" />
61 <property name="maxIdle" value="1" />
62 <property name="minIdle" value="1" />
63 <property name="maxWaitMillis" value="15000" />
64 <!--<property name="poolPreparedStatements" value="true"/> -->
65 </bean>
66
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 -->
86 <bean id="c3p0DataSource"
87 class="com.mchange.v2.c3p0.ComboPooledDataSource"
88 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 -->
100 <bean id="flywayConfig"
101 class="org.flywaydb.core.api.configuration.ClassicConfiguration">
102 <!-- 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" />
106 <property name="locations"
107 value="#{'${jdbc.schemaPath}'.split(',')}" />
108 <!-- <property name="dataSource" ref="sqliteDataSource" /> -->
109 <property name="dataSource" ref="dataSource" />
110 <property name="outOfOrder" value="true" />
111 </bean>
112
113 <bean id="flyway" class="org.flywaydb.core.Flyway"
114 init-method="migrate">
115 <constructor-arg ref="flywayConfig" />
116 </bean>
117
118
119 <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>
125 <value>de.ids_mannheim.korap.core.entity</value>
126 <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">
133 <property name="databasePlatform"
134 value="${hibernate.dialect}" />
135 </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" />
155 <bean id="transactionManager"
156 class="org.springframework.orm.jpa.JpaTransactionManager">
157 <property name="entityManagerFactory"
158 ref="entityManagerFactory" />
159 </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" />
168 <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
175 <!-- Services -->
176 <bean id="scopeService"
177 class="de.ids_mannheim.korap.oauth2.service.OAuth2ScopeServiceImpl" />
178
179 <!-- props are injected from default-config.xml -->
180 <bean id="kustvakt_config"
181 class="de.ids_mannheim.korap.config.FullConfiguration">
182 <constructor-arg name="properties" ref="props" />
183 </bean>
184
185 <bean id="initializator"
186 class="de.ids_mannheim.korap.init.Initializator"
187 init-method="initTest">
188 </bean>
189
190 <!-- Krill -->
191 <bean id="search_krill"
192 class="de.ids_mannheim.korap.web.SearchKrill">
193 <constructor-arg value="${krill.indexDir}" />
194 </bean>
195
196 <!-- Validator -->
197 <bean id="validator"
198 class="de.ids_mannheim.korap.validator.ApacheValidator" />
199
200 <!-- URLValidator -->
201 <bean id="redirectURIValidator"
202 class="org.apache.commons.validator.routines.UrlValidator">
203 <constructor-arg value="http,https" index="0" />
204 <constructor-arg index="1" type="long"
205 value="#{T(org.apache.commons.validator.routines.UrlValidator).ALLOW_LOCAL_URLS +
206 T(org.apache.commons.validator.routines.UrlValidator).NO_FRAGMENTS}" />
207 </bean>
208 <bean id="urlValidator"
209 class="org.apache.commons.validator.routines.UrlValidator">
210 <constructor-arg value="http,https" />
211 </bean>
212
213 <!-- Rewrite -->
214 <bean id="foundryRewrite"
215 class="de.ids_mannheim.korap.rewrite.FoundryRewrite" />
216 <bean id="collectionRewrite"
217 class="de.ids_mannheim.korap.rewrite.CollectionRewrite" />
218 <bean id="collectionCleanRewrite"
219 class="de.ids_mannheim.korap.rewrite.CollectionCleanRewrite" />
220 <bean id="virtualCorpusRewrite"
221 class="de.ids_mannheim.korap.rewrite.VirtualCorpusRewrite" />
222 <bean id="collectionConstraint"
223 class="de.ids_mannheim.korap.rewrite.CollectionConstraint" />
224 <bean id="queryReferenceRewrite"
225 class="de.ids_mannheim.korap.rewrite.QueryReferenceRewrite" />
226
227 <util:list id="rewriteTasks"
228 value-type="de.ids_mannheim.korap.rewrite.RewriteTask">
229 <!-- <ref bean="collectionConstraint" /> <ref bean="collectionCleanRewrite"
230 /> -->
231 <ref bean="foundryRewrite" />
232 <ref bean="collectionRewrite" />
233 <ref bean="virtualCorpusRewrite" />
234 <ref bean="queryReferenceRewrite" />
235 </util:list>
236
237 <bean id="rewriteHandler"
238 class="de.ids_mannheim.korap.rewrite.RewriteHandler">
239 <constructor-arg ref="rewriteTasks" />
240 </bean>
241
242 <bean id="kustvaktResponseHandler"
243 class="de.ids_mannheim.korap.web.KustvaktResponseHandler">
244 </bean>
245
246 <!-- OAuth -->
247 <bean id="oauth2ResponseHandler"
248 class="de.ids_mannheim.korap.web.OAuth2ResponseHandler">
249 </bean>
250
251 <bean name="kustvakt_encryption"
252 class="de.ids_mannheim.korap.encryption.KustvaktEncryption">
253 <constructor-arg ref="kustvakt_config" />
254 </bean>
255
256 <!-- authentication providers to use -->
257 <bean id="basic_auth"
258 class="de.ids_mannheim.korap.authentication.BasicAuthentication" />
259
260
261 <bean id="session_auth"
262 class="de.ids_mannheim.korap.authentication.SessionAuthentication">
263 <constructor-arg
264 type="de.ids_mannheim.korap.config.KustvaktConfiguration"
265 ref="kustvakt_config" />
266 <constructor-arg
267 type="de.ids_mannheim.korap.interfaces.EncryptionIface"
268 ref="kustvakt_encryption" />
269 </bean>
270
271 <bean id="oauth2_auth"
272 class="de.ids_mannheim.korap.authentication.OAuth2Authentication" />
273
274
275 <util:list id="kustvakt_authproviders"
276 value-type="de.ids_mannheim.korap.interfaces.AuthenticationIface">
277 <ref bean="basic_auth" />
278 <ref bean="session_auth" />
279 <ref bean="oauth2_auth" />
280 </util:list>
281
282 <!-- specify type for constructor argument -->
283 <bean id="authenticationManager"
284 class="de.ids_mannheim.korap.authentication.KustvaktAuthenticationManager">
285 <constructor-arg
286 type="de.ids_mannheim.korap.interfaces.EncryptionIface"
287 ref="kustvakt_encryption" />
288 <constructor-arg ref="kustvakt_config" />
289 <!-- inject authentication providers to use -->
290 <property name="providers" ref="kustvakt_authproviders" />
291 </bean>
292
293 <!-- todo: if db interfaces not loaded via spring, does transaction even
294 work then? -->
295 <!-- the transactional advice (i.e. what 'happens'; see the <aop:advisor/>
296 bean below) -->
297 <tx:advice id="txAdvice" transaction-manager="txManager">
298 <!-- the transactional semantics... -->
299 <tx:attributes>
300 <!-- all methods starting with 'get' are read-only -->
301 <tx:method name="get*" read-only="true"
302 rollback-for="KorAPException" />
303 <!-- other methods use the default transaction settings (see below) -->
304 <tx:method name="*" rollback-for="KorAPException" />
305 </tx:attributes>
306 </tx:advice>
307
308 <!-- ensure that the above transactional advice runs for any execution of
309 an operation defined by the service interface -->
310 <aop:config>
311 <aop:pointcut id="service"
312 expression="execution(* de.ids_mannheim.korap.interfaces.db.*.*(..))" />
313 <aop:advisor advice-ref="txAdvice" pointcut-ref="service" />
314 </aop:config>
315
316 <!-- similarly, don't forget the PlatformTransactionManager -->
317 <bean id="txManager"
318 class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
319 <property name="dataSource" ref="dataSource" />
320 </bean>
321
margaretha46e2c952024-05-23 09:09:54 +0200322</beans>