blob: 2ba0d1a4a9345c6bcb80ad717b39ec86dbc86586 [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
224 <bean id="mdGenerator" class="org.apache.oltu.oauth2.as.issuer.MD5Generator">
225 </bean>
226 <bean id="oauthIssuer" class="org.apache.oltu.oauth2.as.issuer.OAuthIssuerImpl">
227 <constructor-arg index="0" ref="mdGenerator" />
228 </bean>
229
230 <bean id="kustvakt_userdb" class="de.ids_mannheim.korap.handlers.EntityDao">
231 <constructor-arg ref="kustvakt_db" />
232 </bean>
233
234 <bean name="kustvakt_encryption" class="de.ids_mannheim.korap.encryption.KustvaktEncryption">
235 <constructor-arg ref="kustvakt_config" />
236 </bean>
237
238 <!-- authentication providers to use -->
239 <!-- <bean id="api_auth" class="de.ids_mannheim.korap.authentication.APIAuthentication">
240 <constructor-arg type="de.ids_mannheim.korap.config.KustvaktConfiguration"
241 ref="kustvakt_config" /> </bean> -->
242
243 <bean id="ldap_auth" class="de.ids_mannheim.korap.authentication.LdapAuth3">
244 <constructor-arg type="de.ids_mannheim.korap.config.KustvaktConfiguration"
245 ref="kustvakt_config" />
246 </bean>
247
248 <bean id="basic_auth"
249 class="de.ids_mannheim.korap.authentication.BasicAuthentication" />
250
251
252 <bean id="session_auth"
253 class="de.ids_mannheim.korap.authentication.SessionAuthentication">
254 <constructor-arg type="de.ids_mannheim.korap.config.KustvaktConfiguration"
255 ref="kustvakt_config" />
256 <constructor-arg type="de.ids_mannheim.korap.interfaces.EncryptionIface"
257 ref="kustvakt_encryption" />
258 </bean>
259
260 <bean id="oauth2_auth"
261 class="de.ids_mannheim.korap.authentication.OAuth2Authentication" />
262
263 <util:list id="kustvakt_authproviders"
264 value-type="de.ids_mannheim.korap.interfaces.AuthenticationIface">
265 <ref bean="basic_auth" />
266 <ref bean="ldap_auth" />
267 <!--
268 <ref bean="session_auth" />
269 <ref bean="api_auth" />
270 -->
271 <ref bean="oauth2_auth" />
272 </util:list>
273
274
275 <bean id="userdata_details" class="de.ids_mannheim.korap.handlers.UserDetailsDao">
276 <constructor-arg ref="kustvakt_db" />
277 </bean>
278
279 <bean id="userdata_settings" class="de.ids_mannheim.korap.handlers.UserSettingsDao">
280 <constructor-arg ref="kustvakt_db" />
281 </bean>
282
283 <util:list id="kustvakt_userdata"
284 value-type="de.ids_mannheim.korap.interfaces.db.UserdataDbIface">
285 <ref bean="userdata_details" />
286 <ref bean="userdata_settings" />
287 </util:list>
288
289 <!-- specify type for constructor argument -->
290 <bean id="authenticationManager"
291 class="de.ids_mannheim.korap.authentication.KustvaktAuthenticationManager">
292 <constructor-arg type="de.ids_mannheim.korap.interfaces.EntityHandlerIface"
293 ref="kustvakt_userdb" />
294 <constructor-arg type="de.ids_mannheim.korap.interfaces.EncryptionIface"
295 ref="kustvakt_encryption" />
296 <constructor-arg ref="kustvakt_config" />
margarethaceae6972022-05-31 10:57:11 +0200297 <constructor-arg ref="kustvakt_userdata" />
298 <!-- inject authentication providers to use -->
299 <property name="providers" ref="kustvakt_authproviders" />
300 </bean>
301
302 <!-- todo: if db interfaces not loaded via spring, does transaction even
303 work then? -->
304 <!-- the transactional advice (i.e. what 'happens'; see the <aop:advisor/>
305 bean below) -->
306 <tx:advice id="txAdvice" transaction-manager="txManager">
307 <!-- the transactional semantics... -->
308 <tx:attributes>
309 <!-- all methods starting with 'get' are read-only -->
310 <tx:method name="get*" read-only="true" rollback-for="KorAPException" />
311 <!-- other methods use the default transaction settings (see below) -->
312 <tx:method name="*" rollback-for="KorAPException" />
313 </tx:attributes>
314 </tx:advice>
315
316 <!-- ensure that the above transactional advice runs for any execution of
317 an operation defined by the service interface -->
318 <aop:config>
319 <aop:pointcut id="service"
320 expression="execution(* de.ids_mannheim.korap.interfaces.db.*.*(..))" />
321 <aop:advisor advice-ref="txAdvice" pointcut-ref="service" />
322 </aop:config>
323
324 <!-- similarly, don't forget the PlatformTransactionManager -->
325 <bean id="txManager"
326 class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
327 <!-- <property name="dataSource" ref="dataSource" /> -->
328 <property name="dataSource" ref="sqliteDataSource" />
329 </bean>
330
331 <!-- mail -->
332 <bean id="authenticator" class="de.ids_mannheim.korap.service.MailAuthenticator">
333 <constructor-arg index="0" value="${mail.username}" />
334 <constructor-arg index="1" value="${mail.password}" />
335 </bean>
336 <bean id="smtpSession" class="javax.mail.Session" factory-method="getInstance">
337 <constructor-arg index="0">
338 <props>
339 <prop key="mail.smtp.submitter">${mail.username}</prop>
340 <prop key="mail.smtp.auth">${mail.auth}</prop>
341 <prop key="mail.smtp.host">${mail.host}</prop>
342 <prop key="mail.smtp.port">${mail.port}</prop>
343 <prop key="mail.smtp.starttls.enable">${mail.starttls.enable}</prop>
344 <prop key="mail.smtp.connectiontimeout">${mail.connectiontimeout}</prop>
345 </props>
346 </constructor-arg>
347 <constructor-arg index="1" ref="authenticator" />
348 </bean>
349 <bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
350 <property name="username" value="${mail.username}" />
351 <property name="password" value="${mail.password}" />
352 <property name="session" ref="smtpSession" />
353 </bean>
354 <bean id="velocityEngine" class="org.apache.velocity.app.VelocityEngine">
355 <constructor-arg index="0">
356 <props>
357 <prop key="resource.loader">class</prop>
358 <prop key="class.resource.loader.class">org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
359 </prop>
360 </props>
361 </constructor-arg>
362 </bean>
363</beans>