blob: c8cfdaaad5129c1c1acd2c12c8588726b02744e5 [file] [log] [blame]
margarethaceae6972022-05-31 10:57:11 +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" xmlns:util="http://www.springframework.org/schema/util"
4 xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
5 xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context"
6 xmlns:cache="http://www.springframework.org/schema/cache"
7 xsi:schemaLocation="http://www.springframework.org/schema/beans
8 http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
9 http://www.springframework.org/schema/tx
10 http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
11 http://www.springframework.org/schema/aop
12 http://www.springframework.org/schema/aop/spring-aop-4.0.xsd
13 http://www.springframework.org/schema/context
14 http://www.springframework.org/schema/context/spring-context-4.0.xsd
15 http://www.springframework.org/schema/util
16 http://www.springframework.org/schema/util/spring-util-4.0.xsd">
17
18 <context:component-scan base-package="de.ids_mannheim.korap" />
19 <context:annotation-config />
20
21 <bean id="props"
22 class="org.springframework.beans.factory.config.PropertiesFactoryBean">
23 <property name="ignoreResourceNotFound" value="true" />
24 <property name="locations">
25 <array>
26 <value>classpath:kustvakt.conf</value>
27 <value>file:./kustvakt.conf</value>
28 </array>
29 </property>
30 </bean>
31
32 <bean id="placeholders"
33 class="org.springframework.context.support.PropertySourcesPlaceholderConfigurer">
34 <property name="ignoreResourceNotFound" value="true" />
35 <property name="locations">
36 <array>
37 <value>classpath:properties/basic-jdbc.properties</value>
38 <value>file:./basic-jdbc.properties</value>
39 <value>classpath:properties/mail.properties</value>
40 <value>file:./mail.properties</value>
margarethacc7feb62023-05-09 08:57:46 +020041 <value>classpath:properties/hibernate.properties</value>
margarethaceae6972022-05-31 10:57:11 +020042
43 <value>classpath:kustvakt.conf</value>
44 <value>file:./kustvakt.conf</value>
45 </array>
46 </property>
47 </bean>
48
49 <bean id='cacheManager' class='org.springframework.cache.ehcache.EhCacheCacheManager'
50 p:cacheManager-ref='ehcache' />
51
52 <bean id='ehcache'
53 class='org.springframework.cache.ehcache.EhCacheManagerFactoryBean'
54 p:configLocation='classpath:ehcache.xml' p:shared='true' />
55
56 <!--class="org.apache.commons.dbcp2.BasicDataSource" -->
57 <!-- org.springframework.jdbc.datasource.SingleConnectionDataSource -->
58 <bean id="dataSource" class="org.apache.commons.dbcp2.BasicDataSource"
59 lazy-init="true">
60 <property name="driverClassName" value="${jdbc.driverClassName}" />
61 <property name="url" value="${jdbc.url}" />
62 <property name="username" value="${jdbc.username}" />
63 <property name="password" value="${jdbc.password}" />
64 <!-- relevant for single connection datasource and sqlite -->
65 <!-- <property name="suppressClose"> <value>true</value> </property> -->
66 <!--<property name="initialSize" value="2"/> -->
67 <property name="maxTotal" value="4" />
68 <property name="maxIdle" value="2" />
69 <property name="minIdle" value="1" />
70 <property name="maxWaitMillis" value="15000" />
71 <!--<property name="poolPreparedStatements" value="true"/> -->
72 </bean>
73
74 <bean id="sqliteDataSource"
75 class="org.springframework.jdbc.datasource.SingleConnectionDataSource"
76 lazy-init="true">
77 <property name="driverClassName" value="${jdbc.driverClassName}" />
78 <property name="url" value="${jdbc.url}" />
79 <property name="username" value="${jdbc.username}" />
80 <property name="password" value="${jdbc.password}" />
81 <property name="connectionProperties">
82 <props>
83 <prop key="date_string_format">yyyy-MM-dd HH:mm:ss</prop>
84 </props>
85 </property>
86
87 <!-- relevant for single connection datasource and sqlite -->
88 <property name="suppressClose">
89 <value>true</value>
90 </property>
91 <!--<property name="initialSize" value="2"/> -->
92 <!--<property name="poolPreparedStatements" value="true"/> -->
93 </bean>
94
95 <!-- to configure database for sqlite, mysql, etc. migrations -->
96 <bean id="flywayConfig" class="org.flywaydb.core.api.configuration.ClassicConfiguration">
97 <property name="baselineOnMigrate" value="true" />
98 <!-- <property name="validateOnMigrate" value="false" /> -->
99 <!-- <property name="cleanOnValidationError" value="true" /> -->
100 <property name="locations" value="#{'${jdbc.schemaPath}'.split(',')}"/>
101 <!-- <property name="dataSource" ref="dataSource" /> -->
102 <property name="dataSource" ref="sqliteDataSource" />
103 <property name="outOfOrder" value="true"/>
104 </bean>
105
106 <bean id="flyway" class="org.flywaydb.core.Flyway" init-method="migrate">
107 <constructor-arg ref="flywayConfig"/>
108 </bean>
109
110
111 <bean id="kustvakt_db" class="de.ids_mannheim.korap.handlers.JDBCClient">
112 <constructor-arg index="0" ref="dataSource" />
113 <!-- deprecated property -->
114 <property name="database" value="${jdbc.database}" />
115 </bean>
116
117 <bean id="entityManagerFactory"
118 class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
119 depends-on="flyway">
120 <!-- <property name="dataSource" ref="dataSource" /> -->
121 <property name="dataSource" ref="sqliteDataSource" />
122
123 <property name="packagesToScan">
124 <array>
125 <value>de.ids_mannheim.korap.entity</value>
126 <value>de.ids_mannheim.korap.oauth2.entity</value>
127 </array>
128 </property>
129 <property name="jpaVendorAdapter">
130 <bean id="jpaVendorAdapter"
131 class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
132 <property name="databasePlatform" value="${hibernate.dialect}" />
133 </bean>
134 </property>
135 <property name="jpaProperties">
136 <props>
137 <prop key="hibernate.dialect">${hibernate.dialect}</prop>
138 <prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop>
139 <prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
140 <prop key="hibernate.cache.use_query_cache">${hibernate.cache.use_query_cache}</prop>
141 <prop key="hibernate.cache.use_second_level_cache">${hibernate.cache.use_second_level_cache}
142 </prop>
143 <prop key="hibernate.cache.provider_class">${hibernate.cache.provider}</prop>
144 <prop key="hibernate.cache.region.factory_class">${hibernate.cache.region.factory}</prop>
145 <prop key="hibernate.jdbc.time_zone">${hibernate.jdbc.time_zone}</prop>
146 <!-- <prop key="net.sf.ehcache.configurationResourceName">classpath:ehcache.xml</prop> -->
147 </props>
148 </property>
149 </bean>
150
151 <tx:annotation-driven proxy-target-class="true"
152 transaction-manager="transactionManager" />
153
154 <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
155 <property name="entityManagerFactory" ref="entityManagerFactory" />
156 </bean>
157
158 <bean id="transactionTemplate"
159 class="org.springframework.transaction.support.TransactionTemplate">
160 <constructor-arg ref="transactionManager" />
161 </bean>
162
163 <!-- Data access objects -->
164 <bean id="adminDao" class="de.ids_mannheim.korap.dao.AdminDaoImpl" />
165 <bean id="authorizationDao" class="de.ids_mannheim.korap.oauth2.dao.CachedAuthorizationDaoImpl" />
166
167 <!-- Services -->
168 <bean id="scopeService" class="de.ids_mannheim.korap.oauth2.service.OAuth2ScopeServiceImpl" />
169
170 <!-- props are injected from default-config.xml -->
171 <bean id="kustvakt_config" class="de.ids_mannheim.korap.config.FullConfiguration">
172 <constructor-arg name="properties" ref="props" />
173 </bean>
174
175 <bean id="initializator" class="de.ids_mannheim.de.init.Initializator"
176 init-method="init">
177 </bean>
178
179 <!-- Krill -->
180 <bean id="search_krill" class="de.ids_mannheim.korap.web.SearchKrill">
181 <constructor-arg value="${krill.indexDir}" />
182 </bean>
183
184 <!-- Validator -->
185 <bean id="validator" class="de.ids_mannheim.korap.validator.ApacheValidator"/>
186
187 <!-- URLValidator -->
188 <bean id="redirectURIValidator" class="org.apache.commons.validator.routines.UrlValidator">
189 <constructor-arg value="http,https" index="0" />
190 <constructor-arg index="1" type="long">
191 <util:constant
192 static-field="org.apache.commons.validator.routines.UrlValidator.NO_FRAGMENTS" />
193 </constructor-arg>
194 </bean>
195 <bean id="urlValidator" class="org.apache.commons.validator.routines.UrlValidator">
196 <constructor-arg value="http,https" />
197 </bean>
198
199 <!-- Rewrite -->
200 <bean id="foundryRewrite" class="de.ids_mannheim.korap.rewrite.FoundryRewrite"/>
201 <bean id="collectionRewrite" class="de.ids_mannheim.korap.rewrite.CollectionRewrite"/>
202 <bean id="virtualCorpusRewrite" class="de.ids_mannheim.korap.rewrite.VirtualCorpusRewrite"/>
203 <bean id="queryReferenceRewrite" class="de.ids_mannheim.korap.rewrite.QueryReferenceRewrite"/>
204
205 <util:list id="rewriteTasks"
206 value-type="de.ids_mannheim.korap.rewrite.RewriteTask">
207 <ref bean="foundryRewrite" />
208 <ref bean="collectionRewrite" />
209 <ref bean="virtualCorpusRewrite" />
210 <ref bean="queryReferenceRewrite" />
211 </util:list>
212
213 <bean id="rewriteHandler" class="de.ids_mannheim.korap.rewrite.RewriteHandler">
214 <constructor-arg ref="rewriteTasks"/>
215 </bean>
216
margarethaceae6972022-05-31 10:57:11 +0200217 <bean id="kustvaktResponseHandler" class="de.ids_mannheim.korap.web.KustvaktResponseHandler">
margarethaceae6972022-05-31 10:57:11 +0200218 </bean>
219
220 <!-- OAuth -->
221 <bean id="oauth2ResponseHandler" class="de.ids_mannheim.korap.web.OAuth2ResponseHandler">
margarethaceae6972022-05-31 10:57:11 +0200222 </bean>
223
margarethaceae6972022-05-31 10:57:11 +0200224 <bean id="kustvakt_userdb" class="de.ids_mannheim.korap.handlers.EntityDao">
225 <constructor-arg ref="kustvakt_db" />
226 </bean>
227
228 <bean name="kustvakt_encryption" class="de.ids_mannheim.korap.encryption.KustvaktEncryption">
229 <constructor-arg ref="kustvakt_config" />
230 </bean>
231
232 <!-- authentication providers to use -->
233 <!-- <bean id="api_auth" class="de.ids_mannheim.korap.authentication.APIAuthentication">
234 <constructor-arg type="de.ids_mannheim.korap.config.KustvaktConfiguration"
235 ref="kustvakt_config" /> </bean> -->
236
237 <bean id="ldap_auth" class="de.ids_mannheim.korap.authentication.LdapAuth3">
238 <constructor-arg type="de.ids_mannheim.korap.config.KustvaktConfiguration"
239 ref="kustvakt_config" />
240 </bean>
241
242 <bean id="basic_auth"
243 class="de.ids_mannheim.korap.authentication.BasicAuthentication" />
244
245
246 <bean id="session_auth"
247 class="de.ids_mannheim.korap.authentication.SessionAuthentication">
248 <constructor-arg type="de.ids_mannheim.korap.config.KustvaktConfiguration"
249 ref="kustvakt_config" />
250 <constructor-arg type="de.ids_mannheim.korap.interfaces.EncryptionIface"
251 ref="kustvakt_encryption" />
252 </bean>
253
254 <bean id="oauth2_auth"
255 class="de.ids_mannheim.korap.authentication.OAuth2Authentication" />
256
257 <util:list id="kustvakt_authproviders"
258 value-type="de.ids_mannheim.korap.interfaces.AuthenticationIface">
259 <ref bean="basic_auth" />
260 <ref bean="ldap_auth" />
261 <!--
262 <ref bean="session_auth" />
263 <ref bean="api_auth" />
264 -->
265 <ref bean="oauth2_auth" />
266 </util:list>
267
268
269 <bean id="userdata_details" class="de.ids_mannheim.korap.handlers.UserDetailsDao">
270 <constructor-arg ref="kustvakt_db" />
271 </bean>
272
273 <bean id="userdata_settings" class="de.ids_mannheim.korap.handlers.UserSettingsDao">
274 <constructor-arg ref="kustvakt_db" />
275 </bean>
276
277 <util:list id="kustvakt_userdata"
278 value-type="de.ids_mannheim.korap.interfaces.db.UserdataDbIface">
279 <ref bean="userdata_details" />
280 <ref bean="userdata_settings" />
281 </util:list>
282
283 <!-- specify type for constructor argument -->
284 <bean id="authenticationManager"
285 class="de.ids_mannheim.korap.authentication.KustvaktAuthenticationManager">
286 <constructor-arg type="de.ids_mannheim.korap.interfaces.EntityHandlerIface"
287 ref="kustvakt_userdb" />
288 <constructor-arg type="de.ids_mannheim.korap.interfaces.EncryptionIface"
289 ref="kustvakt_encryption" />
290 <constructor-arg ref="kustvakt_config" />
margarethaceae6972022-05-31 10:57:11 +0200291 <constructor-arg ref="kustvakt_userdata" />
292 <!-- inject authentication providers to use -->
293 <property name="providers" ref="kustvakt_authproviders" />
294 </bean>
295
296 <!-- todo: if db interfaces not loaded via spring, does transaction even
297 work then? -->
298 <!-- the transactional advice (i.e. what 'happens'; see the <aop:advisor/>
299 bean below) -->
300 <tx:advice id="txAdvice" transaction-manager="txManager">
301 <!-- the transactional semantics... -->
302 <tx:attributes>
303 <!-- all methods starting with 'get' are read-only -->
304 <tx:method name="get*" read-only="true" rollback-for="KorAPException" />
305 <!-- other methods use the default transaction settings (see below) -->
306 <tx:method name="*" rollback-for="KorAPException" />
307 </tx:attributes>
308 </tx:advice>
309
310 <!-- ensure that the above transactional advice runs for any execution of
311 an operation defined by the service interface -->
312 <aop:config>
313 <aop:pointcut id="service"
314 expression="execution(* de.ids_mannheim.korap.interfaces.db.*.*(..))" />
315 <aop:advisor advice-ref="txAdvice" pointcut-ref="service" />
316 </aop:config>
317
318 <!-- similarly, don't forget the PlatformTransactionManager -->
319 <bean id="txManager"
320 class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
321 <!-- <property name="dataSource" ref="dataSource" /> -->
322 <property name="dataSource" ref="sqliteDataSource" />
323 </bean>
324
325 <!-- mail -->
326 <bean id="authenticator" class="de.ids_mannheim.korap.service.MailAuthenticator">
327 <constructor-arg index="0" value="${mail.username}" />
328 <constructor-arg index="1" value="${mail.password}" />
329 </bean>
margaretha4b883ec2023-09-25 12:21:24 +0200330 <bean id="smtpSession" class="jakarta.mail.Session" factory-method="getInstance">
margarethaceae6972022-05-31 10:57:11 +0200331 <constructor-arg index="0">
332 <props>
333 <prop key="mail.smtp.submitter">${mail.username}</prop>
334 <prop key="mail.smtp.auth">${mail.auth}</prop>
335 <prop key="mail.smtp.host">${mail.host}</prop>
336 <prop key="mail.smtp.port">${mail.port}</prop>
337 <prop key="mail.smtp.starttls.enable">${mail.starttls.enable}</prop>
338 <prop key="mail.smtp.connectiontimeout">${mail.connectiontimeout}</prop>
339 </props>
340 </constructor-arg>
341 <constructor-arg index="1" ref="authenticator" />
342 </bean>
343 <bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
344 <property name="username" value="${mail.username}" />
345 <property name="password" value="${mail.password}" />
346 <property name="session" ref="smtpSession" />
347 </bean>
348 <bean id="velocityEngine" class="org.apache.velocity.app.VelocityEngine">
349 <constructor-arg index="0">
350 <props>
351 <prop key="resource.loader">class</prop>
352 <prop key="class.resource.loader.class">org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
353 </prop>
354 </props>
355 </constructor-arg>
356 </bean>
357</beans>