blob: fed99a6a062c5f4fedd92752ca35f688bcec65e4 [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
margaretha1960ea52023-02-28 11:20:15 +0100117 <bean id="entityManagerFactory"
118 class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
119 <!-- <property name="dataSource" ref="dataSource" /> -->
120 <property name="dataSource" ref="sqliteDataSource" />
121 <property name="packagesToScan">
122 <array>
margaretha5b708792023-05-12 16:55:29 +0200123 <value>de.ids_mannheim.korap.core.entity</value>
margaretha1960ea52023-02-28 11:20:15 +0100124 <value>de.ids_mannheim.korap.entity</value>
125 <value>de.ids_mannheim.korap.oauth2.entity</value>
126 </array>
127 </property>
128 <property name="jpaVendorAdapter">
129 <bean id="jpaVendorAdapter"
130 class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
131 <property name="databasePlatform" value="${hibernate.dialect}" />
132 </bean>
133 </property>
134 <property name="jpaProperties">
135 <props>
136 <prop key="hibernate.dialect">${hibernate.dialect}</prop>
137 <prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop>
138 <prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
139 <prop key="hibernate.cache.use_query_cache">${hibernate.cache.use_query_cache}</prop>
140 <prop key="hibernate.cache.use_second_level_cache">${hibernate.cache.use_second_level_cache}
141 </prop>
142 <prop key="hibernate.cache.provider_class">${hibernate.cache.provider}</prop>
143 <prop key="hibernate.cache.region.factory_class">${hibernate.cache.region.factory}</prop>
144 <prop key="hibernate.jdbc.time_zone">${hibernate.jdbc.time_zone}</prop>
145 <!-- <prop key="net.sf.ehcache.configurationResourceName">classpath:ehcache.xml</prop> -->
146 </props>
147 </property>
148 </bean>
149
150 <tx:annotation-driven proxy-target-class="true"
151 transaction-manager="transactionManager" />
152 <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
153 <property name="entityManagerFactory" ref="entityManagerFactory" />
154 </bean>
155
156 <bean id="transactionTemplate"
157 class="org.springframework.transaction.support.TransactionTemplate">
158 <constructor-arg ref="transactionManager" />
159 </bean>
160
161 <!-- Data access objects -->
162 <bean id="adminDao" class="de.ids_mannheim.korap.dao.AdminDaoImpl" />
163 <bean id="resourceDao" class="de.ids_mannheim.korap.dao.ResourceDao" />
164 <bean id="accessScopeDao" class="de.ids_mannheim.korap.oauth2.dao.AccessScopeDao" />
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
171 <!-- Controller -->
172
173
174 <!-- props are injected from default-config.xml -->
175 <bean id="kustvakt_config" class="de.ids_mannheim.korap.config.FullConfiguration">
176 <constructor-arg name="properties" ref="props" />
177 </bean>
178
179 <bean id="initializator" class="de.ids_mannheim.de.init.Initializator"
180 init-method="initTest">
181 </bean>
182
183 <!-- Krill -->
184 <bean id="search_krill" class="de.ids_mannheim.korap.web.SearchKrill">
185 <constructor-arg value="${krill.indexDir}" />
186 </bean>
187
188 <!-- Validator -->
189 <bean id="validator" class="de.ids_mannheim.korap.validator.ApacheValidator"/>
190
191 <!-- URLValidator -->
192 <bean id="redirectURIValidator" class="org.apache.commons.validator.routines.UrlValidator">
193 <constructor-arg value="http,https" index="0" />
194 <constructor-arg index="1" type="long"
195 value="#{T(org.apache.commons.validator.routines.UrlValidator).ALLOW_LOCAL_URLS +
196 T(org.apache.commons.validator.routines.UrlValidator).NO_FRAGMENTS}"/>
197 </bean>
198 <bean id="urlValidator" class="org.apache.commons.validator.routines.UrlValidator">
199 <constructor-arg value="http,https" />
200 </bean>
201
202 <!-- Rewrite -->
203 <bean id="foundryRewrite" class="de.ids_mannheim.korap.rewrite.FoundryRewrite"/>
204 <bean id="collectionRewrite" class="de.ids_mannheim.korap.rewrite.CollectionRewrite"/>
205 <bean id="collectionCleanRewrite" class="de.ids_mannheim.korap.rewrite.CollectionCleanRewrite"/>
206 <bean id="virtualCorpusRewrite" class="de.ids_mannheim.korap.rewrite.VirtualCorpusRewrite"/>
207 <bean id="collectionConstraint" class="de.ids_mannheim.korap.rewrite.CollectionConstraint"/>
208 <bean id="queryReferenceRewrite" class="de.ids_mannheim.korap.rewrite.QueryReferenceRewrite"/>
209
210 <util:list id="rewriteTasks"
211 value-type="de.ids_mannheim.korap.rewrite.RewriteTask">
212 <!-- <ref bean="collectionConstraint" />
213 <ref bean="collectionCleanRewrite" /> -->
214 <ref bean="foundryRewrite" />
215 <!-- <ref bean="collectionRewrite" /> -->
216 <ref bean="virtualCorpusRewrite" />
217 <ref bean="queryReferenceRewrite" />
218 </util:list>
219
220 <bean id="rewriteHandler" class="de.ids_mannheim.korap.rewrite.RewriteHandler">
221 <constructor-arg ref="rewriteTasks"/>
222 </bean>
223
margaretha1960ea52023-02-28 11:20:15 +0100224 <bean id="kustvaktResponseHandler" class="de.ids_mannheim.korap.web.KustvaktResponseHandler">
margaretha1960ea52023-02-28 11:20:15 +0100225 </bean>
226
227 <!-- OAuth -->
228 <bean id="oauth2ResponseHandler" class="de.ids_mannheim.korap.web.OAuth2ResponseHandler">
margaretha1960ea52023-02-28 11:20:15 +0100229 </bean>
230
231 <bean id="mdGenerator" class="org.apache.oltu.oauth2.as.issuer.MD5Generator">
232 </bean>
233 <bean id="oauthIssuer" class="org.apache.oltu.oauth2.as.issuer.OAuthIssuerImpl">
234 <constructor-arg index="0" ref="mdGenerator" />
235 </bean>
236
margaretha1960ea52023-02-28 11:20:15 +0100237 <bean name="kustvakt_encryption" class="de.ids_mannheim.korap.encryption.KustvaktEncryption">
238 <constructor-arg ref="kustvakt_config" />
239 </bean>
240
241 <!-- authentication providers to use -->
242 <bean id="basic_auth"
243 class="de.ids_mannheim.korap.authentication.BasicAuthentication" />
244
245 <bean id="oauth2_auth"
246 class="de.ids_mannheim.korap.authentication.OAuth2Authentication" />
247
248
249 <util:list id="kustvakt_authproviders"
250 value-type="de.ids_mannheim.korap.interfaces.AuthenticationIface">
251 <ref bean="basic_auth" />
252 <ref bean="oauth2_auth" />
253 </util:list>
254
255
margaretha1960ea52023-02-28 11:20:15 +0100256 <!-- specify type for constructor argument -->
257 <bean id="authenticationManager"
258 class="de.ids_mannheim.korap.authentication.KustvaktAuthenticationManager">
margaretha1960ea52023-02-28 11:20:15 +0100259 <constructor-arg type="de.ids_mannheim.korap.interfaces.EncryptionIface"
260 ref="kustvakt_encryption" />
261 <constructor-arg ref="kustvakt_config" />
margaretha1960ea52023-02-28 11:20:15 +0100262 <!-- inject authentication providers to use -->
263 <property name="providers" ref="kustvakt_authproviders" />
264 </bean>
265
266 <!-- todo: if db interfaces not loaded via spring, does transaction even
267 work then? -->
268 <!-- the transactional advice (i.e. what 'happens'; see the <aop:advisor/>
269 bean below) -->
270 <tx:advice id="txAdvice" transaction-manager="txManager">
271 <!-- the transactional semantics... -->
272 <tx:attributes>
273 <!-- all methods starting with 'get' are read-only -->
274 <tx:method name="get*" read-only="true" rollback-for="KorAPException" />
275 <!-- other methods use the default transaction settings (see below) -->
276 <tx:method name="*" rollback-for="KorAPException" />
277 </tx:attributes>
278 </tx:advice>
279
280 <!-- ensure that the above transactional advice runs for any execution of
281 an operation defined by the service interface -->
282 <aop:config>
283 <aop:pointcut id="service"
284 expression="execution(* de.ids_mannheim.korap.interfaces.db.*.*(..))" />
285 <aop:advisor advice-ref="txAdvice" pointcut-ref="service" />
286 </aop:config>
287
288 <!-- similarly, don't forget the PlatformTransactionManager -->
289 <bean id="txManager"
290 class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
291 <property name="dataSource" ref="dataSource" />
292 </bean>
293
294 <!-- mail -->
295 <bean id="authenticator" class="de.ids_mannheim.korap.service.MailAuthenticator">
296 <constructor-arg index="0" value="${mail.username}" />
297 <constructor-arg index="1" value="${mail.password}" />
298 </bean>
299 <bean id="smtpSession" class="javax.mail.Session" factory-method="getInstance">
300 <constructor-arg index="0">
301 <props>
302 <prop key="mail.smtp.submitter">${mail.username}</prop>
303 <prop key="mail.smtp.auth">${mail.auth}</prop>
304 <prop key="mail.smtp.host">${mail.host}</prop>
305 <prop key="mail.smtp.port">${mail.port}</prop>
306 <prop key="mail.smtp.starttls.enable">${mail.starttls.enable}</prop>
307 <prop key="mail.smtp.connectiontimeout">${mail.connectiontimeout}</prop>
308 </props>
309 </constructor-arg>
310 <constructor-arg index="1" ref="authenticator" />
311 </bean>
312 <bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
313 <property name="session" ref="smtpSession" />
314 </bean>
315 <bean id="velocityEngine" class="org.apache.velocity.app.VelocityEngine">
316 <constructor-arg index="0">
317 <props>
318 <prop key="resource.loader">class</prop>
319 <prop key="class.resource.loader.class">org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
320 </prop>
321 </props>
322 </constructor-arg>
323 </bean>
324</beans>