blob: 383f3780c1816527ce26a837531ac7b35ea744e1 [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>
margaretha4b883ec2023-09-25 12:21:24 +020047
48 <!--
margaretha1960ea52023-02-28 11:20:15 +010049 <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' />
margaretha4b883ec2023-09-25 12:21:24 +020055 -->
margaretha1960ea52023-02-28 11:20:15 +010056 <bean id="dataSource" class="org.apache.commons.dbcp2.BasicDataSource"
57 lazy-init="true">
58 <!-- <property name="driverClassName" value="${jdbc.driverClassName}" /> -->
59 <property name="url" value="${jdbc.url}" />
60 <property name="username" value="${jdbc.username}" />
61 <property name="password" value="${jdbc.password}" />
62 <property name="maxTotal" value="4" />
63 <property name="maxIdle" value="1" />
64 <property name="minIdle" value="1" />
65 <property name="maxWaitMillis" value="15000" />
66 <!--<property name="poolPreparedStatements" value="true"/> -->
67 </bean>
68
69 <!-- use SingleConnection only for testing! -->
70 <bean id="sqliteDataSource"
71 class="org.springframework.jdbc.datasource.SingleConnectionDataSource"
72 lazy-init="true">
73 <!-- <property name="driverClassName" value="${jdbc.driverClassName}" /> -->
74 <property name="url" value="${jdbc.url}" />
75 <property name="username" value="${jdbc.username}" />
76 <property name="password" value="${jdbc.password}" />
77 <property name="connectionProperties">
78 <props>
79 <prop key="date_string_format">yyyy-MM-dd HH:mm:ss</prop>
80 </props>
81 </property>
82
83 <!-- Sqlite can only have a single connection -->
84 <property name="suppressClose">
85 <value>true</value>
86 </property>
87 </bean>
88
89 <bean id="c3p0DataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
90 destroy-method="close">
91 <property name="driverClass" value="${jdbc.driverClassName}" />
92 <property name="jdbcUrl" value="${jdbc.url}" />
93 <property name="user" value="${jdbc.username}" />
94 <property name="password" value="${jdbc.password}" />
95 <property name="maxPoolSize" value="4" />
96 <property name="minPoolSize" value="1" />
97 <property name="maxStatements" value="1" />
98 <property name="testConnectionOnCheckout" value="true" />
99 </bean>
100
101 <!-- to configure database for sqlite, mysql, etc. migrations -->
102 <bean id="flywayConfig" class="org.flywaydb.core.api.configuration.ClassicConfiguration">
103 <!-- drop existing tables and create new tables -->
104 <property name="validateOnMigrate" value="true" />
105 <property name="cleanOnValidationError" value="true" />
106 <property name="baselineOnMigrate" value="false" />
107 <property name="locations" 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" init-method="migrate">
114 <constructor-arg ref="flywayConfig"/>
115 </bean>
116
117
margaretha1960ea52023-02-28 11:20:15 +0100118 <bean id="entityManagerFactory"
119 class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
120 <!-- <property name="dataSource" ref="dataSource" /> -->
121 <property name="dataSource" ref="sqliteDataSource" />
122 <property name="packagesToScan">
123 <array>
margaretha5b708792023-05-12 16:55:29 +0200124 <value>de.ids_mannheim.korap.core.entity</value>
margaretha1960ea52023-02-28 11:20:15 +0100125 <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 <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
154 <property name="entityManagerFactory" ref="entityManagerFactory" />
155 </bean>
156
157 <bean id="transactionTemplate"
158 class="org.springframework.transaction.support.TransactionTemplate">
159 <constructor-arg ref="transactionManager" />
160 </bean>
161
162 <!-- Data access objects -->
163 <bean id="adminDao" class="de.ids_mannheim.korap.dao.AdminDaoImpl" />
164 <bean id="resourceDao" class="de.ids_mannheim.korap.dao.ResourceDao" />
165 <bean id="accessScopeDao" class="de.ids_mannheim.korap.oauth2.dao.AccessScopeDao" />
166 <bean id="authorizationDao" class="de.ids_mannheim.korap.oauth2.dao.CachedAuthorizationDaoImpl" />
167
168 <!-- Services -->
169 <bean id="scopeService" class="de.ids_mannheim.korap.oauth2.service.OAuth2ScopeServiceImpl" />
170
171
172 <!-- Controller -->
173
174
175 <!-- props are injected from default-config.xml -->
176 <bean id="kustvakt_config" class="de.ids_mannheim.korap.config.FullConfiguration">
177 <constructor-arg name="properties" ref="props" />
178 </bean>
179
180 <bean id="initializator" class="de.ids_mannheim.de.init.Initializator"
181 init-method="initTest">
182 </bean>
183
184 <!-- Krill -->
185 <bean id="search_krill" class="de.ids_mannheim.korap.web.SearchKrill">
186 <constructor-arg value="${krill.indexDir}" />
187 </bean>
188
189 <!-- Validator -->
190 <bean id="validator" class="de.ids_mannheim.korap.validator.ApacheValidator"/>
191
192 <!-- URLValidator -->
193 <bean id="redirectURIValidator" class="org.apache.commons.validator.routines.UrlValidator">
194 <constructor-arg value="http,https" index="0" />
195 <constructor-arg index="1" type="long"
196 value="#{T(org.apache.commons.validator.routines.UrlValidator).ALLOW_LOCAL_URLS +
197 T(org.apache.commons.validator.routines.UrlValidator).NO_FRAGMENTS}"/>
198 </bean>
199 <bean id="urlValidator" class="org.apache.commons.validator.routines.UrlValidator">
200 <constructor-arg value="http,https" />
201 </bean>
202
203 <!-- Rewrite -->
204 <bean id="foundryRewrite" class="de.ids_mannheim.korap.rewrite.FoundryRewrite"/>
205 <bean id="collectionRewrite" class="de.ids_mannheim.korap.rewrite.CollectionRewrite"/>
206 <bean id="collectionCleanRewrite" class="de.ids_mannheim.korap.rewrite.CollectionCleanRewrite"/>
207 <bean id="virtualCorpusRewrite" class="de.ids_mannheim.korap.rewrite.VirtualCorpusRewrite"/>
208 <bean id="collectionConstraint" class="de.ids_mannheim.korap.rewrite.CollectionConstraint"/>
209 <bean id="queryReferenceRewrite" class="de.ids_mannheim.korap.rewrite.QueryReferenceRewrite"/>
210
211 <util:list id="rewriteTasks"
212 value-type="de.ids_mannheim.korap.rewrite.RewriteTask">
213 <!-- <ref bean="collectionConstraint" />
214 <ref bean="collectionCleanRewrite" /> -->
215 <ref bean="foundryRewrite" />
216 <!-- <ref bean="collectionRewrite" /> -->
217 <ref bean="virtualCorpusRewrite" />
218 <ref bean="queryReferenceRewrite" />
219 </util:list>
220
221 <bean id="rewriteHandler" class="de.ids_mannheim.korap.rewrite.RewriteHandler">
222 <constructor-arg ref="rewriteTasks"/>
223 </bean>
224
margaretha1960ea52023-02-28 11:20:15 +0100225 <bean id="kustvaktResponseHandler" class="de.ids_mannheim.korap.web.KustvaktResponseHandler">
margaretha1960ea52023-02-28 11:20:15 +0100226 </bean>
227
228 <!-- OAuth -->
229 <bean id="oauth2ResponseHandler" class="de.ids_mannheim.korap.web.OAuth2ResponseHandler">
margaretha1960ea52023-02-28 11:20:15 +0100230 </bean>
231
232 <bean id="mdGenerator" class="org.apache.oltu.oauth2.as.issuer.MD5Generator">
233 </bean>
234 <bean id="oauthIssuer" class="org.apache.oltu.oauth2.as.issuer.OAuthIssuerImpl">
235 <constructor-arg index="0" ref="mdGenerator" />
236 </bean>
237
margaretha1960ea52023-02-28 11:20:15 +0100238 <bean name="kustvakt_encryption" class="de.ids_mannheim.korap.encryption.KustvaktEncryption">
239 <constructor-arg ref="kustvakt_config" />
240 </bean>
241
242 <!-- authentication providers to use -->
243 <bean id="basic_auth"
244 class="de.ids_mannheim.korap.authentication.BasicAuthentication" />
245
246 <bean id="oauth2_auth"
247 class="de.ids_mannheim.korap.authentication.OAuth2Authentication" />
248
249
250 <util:list id="kustvakt_authproviders"
251 value-type="de.ids_mannheim.korap.interfaces.AuthenticationIface">
252 <ref bean="basic_auth" />
253 <ref bean="oauth2_auth" />
254 </util:list>
255
256
margaretha1960ea52023-02-28 11:20:15 +0100257 <!-- specify type for constructor argument -->
258 <bean id="authenticationManager"
259 class="de.ids_mannheim.korap.authentication.KustvaktAuthenticationManager">
margaretha1960ea52023-02-28 11:20:15 +0100260 <constructor-arg type="de.ids_mannheim.korap.interfaces.EncryptionIface"
261 ref="kustvakt_encryption" />
262 <constructor-arg ref="kustvakt_config" />
margaretha1960ea52023-02-28 11:20:15 +0100263 <!-- inject authentication providers to use -->
264 <property name="providers" ref="kustvakt_authproviders" />
265 </bean>
266
267 <!-- todo: if db interfaces not loaded via spring, does transaction even
268 work then? -->
269 <!-- the transactional advice (i.e. what 'happens'; see the <aop:advisor/>
270 bean below) -->
271 <tx:advice id="txAdvice" transaction-manager="txManager">
272 <!-- the transactional semantics... -->
273 <tx:attributes>
274 <!-- all methods starting with 'get' are read-only -->
275 <tx:method name="get*" read-only="true" rollback-for="KorAPException" />
276 <!-- other methods use the default transaction settings (see below) -->
277 <tx:method name="*" rollback-for="KorAPException" />
278 </tx:attributes>
279 </tx:advice>
280
281 <!-- ensure that the above transactional advice runs for any execution of
282 an operation defined by the service interface -->
283 <aop:config>
284 <aop:pointcut id="service"
285 expression="execution(* de.ids_mannheim.korap.interfaces.db.*.*(..))" />
286 <aop:advisor advice-ref="txAdvice" pointcut-ref="service" />
287 </aop:config>
288
289 <!-- similarly, don't forget the PlatformTransactionManager -->
290 <bean id="txManager"
291 class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
292 <property name="dataSource" ref="dataSource" />
293 </bean>
294
295 <!-- mail -->
296 <bean id="authenticator" class="de.ids_mannheim.korap.service.MailAuthenticator">
297 <constructor-arg index="0" value="${mail.username}" />
298 <constructor-arg index="1" value="${mail.password}" />
299 </bean>
margaretha4b883ec2023-09-25 12:21:24 +0200300 <bean id="smtpSession" class="jakarta.mail.Session" factory-method="getInstance">
margaretha1960ea52023-02-28 11:20:15 +0100301 <constructor-arg index="0">
302 <props>
303 <prop key="mail.smtp.submitter">${mail.username}</prop>
304 <prop key="mail.smtp.auth">${mail.auth}</prop>
305 <prop key="mail.smtp.host">${mail.host}</prop>
306 <prop key="mail.smtp.port">${mail.port}</prop>
307 <prop key="mail.smtp.starttls.enable">${mail.starttls.enable}</prop>
308 <prop key="mail.smtp.connectiontimeout">${mail.connectiontimeout}</prop>
309 </props>
310 </constructor-arg>
311 <constructor-arg index="1" ref="authenticator" />
312 </bean>
313 <bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
314 <property name="session" ref="smtpSession" />
315 </bean>
316 <bean id="velocityEngine" class="org.apache.velocity.app.VelocityEngine">
317 <constructor-arg index="0">
318 <props>
319 <prop key="resource.loader">class</prop>
320 <prop key="class.resource.loader.class">org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
321 </prop>
322 </props>
323 </constructor-arg>
324 </bean>
325</beans>