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