blob: 83291a9e9b9249109516d4d44a6161630a60da5f [file] [log] [blame]
Michael Hanlbd852b82015-11-18 22:17:00 +01001<?xml version="1.0" encoding="UTF-8"?>
2<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
margaretha62055f72017-04-11 19:17:43 +02003 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"
margarethaade7d4a2017-07-20 19:53:35 +02005 xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context"
6 xmlns:cache="http://www.springframework.org/schema/cache"
margaretha62055f72017-04-11 19:17:43 +02007 xsi:schemaLocation="http://www.springframework.org/schema/beans
margarethaade7d4a2017-07-20 19:53:35 +02008 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">
Michael Hanlbd852b82015-11-18 22:17:00 +010017
margarethaade7d4a2017-07-20 19:53:35 +020018 <context:component-scan base-package="de.ids_mannheim.korap" />
19 <context:annotation-config />
Michael Hanlbd852b82015-11-18 22:17:00 +010020
margaretha62055f72017-04-11 19:17:43 +020021 <bean id="props"
22 class="org.springframework.beans.factory.config.PropertiesFactoryBean">
23 <property name="ignoreResourceNotFound" value="true" />
24 <property name="locations">
25 <array>
margaretha0c47c652017-04-19 18:44:40 +020026 <value>classpath:kustvakt-test.conf</value>
27 <value>file:./kustvakt-test.conf</value>
margaretha62055f72017-04-11 19:17:43 +020028 </array>
29 </property>
30 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +010031
margarethaade7d4a2017-07-20 19:53:35 +020032 <bean id="placeholders"
33 class="org.springframework.context.support.PropertySourcesPlaceholderConfigurer">
margaretha62055f72017-04-11 19:17:43 +020034 <property name="ignoreResourceNotFound" value="true" />
35 <property name="locations">
36 <array>
margaretha6c2a20f2017-07-24 15:33:01 +020037 <value>classpath:test-jdbc.properties</value>
margaretha1f106f62017-10-18 22:27:30 +020038 <value>file:./test-jdbc.properties</value>
margarethaaecee1b2018-02-20 14:44:21 +010039 <value>classpath:properties/mail.properties</value>
40 <value>file:./mail.properties</value>
margarethaf6d5a822017-10-19 19:51:20 +020041 <value>classpath:test-hibernate.properties</value>
margarethaf18298b2017-09-14 22:14:32 +020042 <value>classpath:kustvakt-test.conf</value>
margaretha62055f72017-04-11 19:17:43 +020043 </array>
44 </property>
45 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +010046
margaretha62055f72017-04-11 19:17:43 +020047 <bean id='cacheManager' class='org.springframework.cache.ehcache.EhCacheCacheManager'
48 p:cacheManager-ref='ehcache' />
Michael Hanlbd852b82015-11-18 22:17:00 +010049
margaretha62055f72017-04-11 19:17:43 +020050 <bean id='ehcache'
51 class='org.springframework.cache.ehcache.EhCacheManagerFactoryBean'
52 p:configLocation='classpath:ehcache.xml' p:shared='true' />
Michael Hanlbd852b82015-11-18 22:17:00 +010053
margaretha62055f72017-04-11 19:17:43 +020054 <!-- props are injected from default-config.xml -->
margaretha56e8e552017-12-05 16:31:21 +010055 <bean id="kustvakt_config" class="de.ids_mannheim.korap.config.FullConfiguration">
margarethaf68daa62017-09-21 02:11:24 +020056 <constructor-arg name="properties" ref="props" />
margaretha62055f72017-04-11 19:17:43 +020057 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +010058
margaretha6c2a20f2017-07-24 15:33:01 +020059 <bean id="dataSource" class="org.apache.commons.dbcp2.BasicDataSource"
60 lazy-init="true">
margaretha4edc70e2018-03-14 22:34:29 +010061 <!-- <property name="driverClassName" value="${jdbc.driverClassName}" /> -->
margaretha6c2a20f2017-07-24 15:33:01 +020062 <property name="url" value="${jdbc.url}" />
63 <property name="username" value="${jdbc.username}" />
64 <property name="password" value="${jdbc.password}" />
margaretha318fec32017-10-24 12:11:58 +020065 <property name="maxTotal" value="4" />
margaretha514e1412017-10-10 15:54:20 +020066 <property name="maxIdle" value="1" />
margaretha6c2a20f2017-07-24 15:33:01 +020067 <property name="minIdle" value="1" />
68 <property name="maxWaitMillis" value="15000" />
69 <!--<property name="poolPreparedStatements" value="true"/> -->
70 </bean>
71
margaretha514e1412017-10-10 15:54:20 +020072 <!-- use SingleConnection only for testing! -->
margaretha6c2a20f2017-07-24 15:33:01 +020073 <bean id="sqliteDataSource"
margaretha62055f72017-04-11 19:17:43 +020074 class="org.springframework.jdbc.datasource.SingleConnectionDataSource"
margaretha318fec32017-10-24 12:11:58 +020075 lazy-init="true">
margaretha514e1412017-10-10 15:54:20 +020076 <!-- <property name="driverClassName" value="${jdbc.driverClassName}" /> -->
margaretha6c2a20f2017-07-24 15:33:01 +020077 <property name="url" value="${jdbc.url}" />
78 <property name="username" value="${jdbc.username}" />
79 <property name="password" value="${jdbc.password}" />
margarethae6c711b2018-02-06 21:55:04 +010080 <property name="connectionProperties">
margaretha58e18632018-02-15 13:04:42 +010081 <props>
82 <prop key="date_string_format">yyyy-MM-dd HH:mm:ss</prop>
83 </props>
84 </property>
85
margaretha514e1412017-10-10 15:54:20 +020086 <!-- Sqlite can only have a single connection -->
margaretha62055f72017-04-11 19:17:43 +020087 <property name="suppressClose">
88 <value>true</value>
89 </property>
margaretha514e1412017-10-10 15:54:20 +020090 </bean>
margaretha58e18632018-02-15 13:04:42 +010091
margaretha514e1412017-10-10 15:54:20 +020092 <bean id="c3p0DataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
margaretha58e18632018-02-15 13:04:42 +010093 destroy-method="close">
94 <property name="driverClass" value="${jdbc.driverClassName}" />
margaretha514e1412017-10-10 15:54:20 +020095 <property name="jdbcUrl" value="${jdbc.url}" />
96 <property name="user" value="${jdbc.username}" />
97 <property name="password" value="${jdbc.password}" />
margaretha58e18632018-02-15 13:04:42 +010098 <property name="maxPoolSize" value="4" />
99 <property name="minPoolSize" value="1" />
100 <property name="maxStatements" value="1" />
101 <property name="testConnectionOnCheckout" value="true" />
margaretha62055f72017-04-11 19:17:43 +0200102 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +0100103
margaretha62055f72017-04-11 19:17:43 +0200104 <!-- to configure database for sqlite, mysql, etc. migrations -->
105 <bean id="flyway" class="org.flywaydb.core.Flyway" init-method="migrate">
margarethaf6d5a822017-10-19 19:51:20 +0200106 <!-- drop existing tables and create new tables -->
107 <property name="validateOnMigrate" value="true" />
108 <property name="cleanOnValidationError" value="true" />
109
margaretha514e1412017-10-10 15:54:20 +0200110 <property name="baselineOnMigrate" value="false" />
111 <property name="locations" value="${jdbc.schemaPath}" />
margaretha6c2a20f2017-07-24 15:33:01 +0200112 <property name="dataSource" ref="sqliteDataSource" />
margaretha318fec32017-10-24 12:11:58 +0200113 <!-- <property name="dataSource" ref="dataSource" /> -->
margaretha62055f72017-04-11 19:17:43 +0200114 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +0100115
margaretha62055f72017-04-11 19:17:43 +0200116 <bean id="kustvakt_db" class="de.ids_mannheim.korap.handlers.JDBCClient">
margaretha318fec32017-10-24 12:11:58 +0200117 <!-- <constructor-arg index="0" ref="dataSource" /> -->
margarethabc9caf42017-09-21 18:52:52 +0200118 <constructor-arg index="0" ref="sqliteDataSource" />
margaretha318fec32017-10-24 12:11:58 +0200119 <property name="database" value="${jdbc.database}" />
margaretha62055f72017-04-11 19:17:43 +0200120 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +0100121
margarethaade7d4a2017-07-20 19:53:35 +0200122 <bean id="entityManagerFactory"
123 class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
margaretha318fec32017-10-24 12:11:58 +0200124 <!-- <property name="dataSource" ref="dataSource" /> -->
125 <property name="dataSource" ref="sqliteDataSource" />
margarethaade7d4a2017-07-20 19:53:35 +0200126 <property name="packagesToScan" value="de.ids_mannheim.korap.entity" />
127 <property name="jpaVendorAdapter">
128 <bean id="jpaVendorAdapter"
129 class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
130 <property name="databasePlatform" value="${hibernate.dialect}" />
131 </bean>
132 </property>
133 <property name="jpaProperties">
134 <props>
135 <prop key="hibernate.dialect">${hibernate.dialect}</prop>
136 <prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop>
137 <prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
138 <prop key="hibernate.cache.use_query_cache">${hibernate.cache.use_query_cache}</prop>
139 <prop key="hibernate.cache.use_second_level_cache">${hibernate.cache.use_second_level_cache}
140 </prop>
141 <prop key="hibernate.cache.provider_class">${hibernate.cache.provider}</prop>
142 <prop key="hibernate.cache.region.factory_class">${hibernate.cache.region.factory}</prop>
143 <!-- <prop key="net.sf.ehcache.configurationResourceName">classpath:ehcache.xml</prop> -->
144 </props>
145 </property>
margaretha62055f72017-04-11 19:17:43 +0200146 </bean>
Michael Hanle4fc7752016-02-17 11:41:18 +0100147
margarethaade7d4a2017-07-20 19:53:35 +0200148 <tx:annotation-driven proxy-target-class="true"
149 transaction-manager="transactionManager" />
150 <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
151 <property name="entityManagerFactory" ref="entityManagerFactory" />
margaretha62055f72017-04-11 19:17:43 +0200152 </bean>
Michael Hanle4fc7752016-02-17 11:41:18 +0100153
margarethaade7d4a2017-07-20 19:53:35 +0200154 <bean id="transactionTemplate"
155 class="org.springframework.transaction.support.TransactionTemplate">
156 <constructor-arg ref="transactionManager" />
157 </bean>
158
159 <!-- Data access objects -->
margaretha58e18632018-02-15 13:04:42 +0100160 <bean id="resourceDao" class="de.ids_mannheim.korap.dao.ResourceDao" />
margarethaade7d4a2017-07-20 19:53:35 +0200161 <!-- <bean id="annotationDao" class="de.ids_mannheim.korap.dao.AnnotationDao"/> -->
162
margaretha6c2a20f2017-07-24 15:33:01 +0200163 <!-- Krill -->
164 <bean id="search_krill" class="de.ids_mannheim.korap.web.SearchKrill">
margaretha58e18632018-02-15 13:04:42 +0100165 <constructor-arg value="${krill.indexDir}" />
margaretha6c2a20f2017-07-24 15:33:01 +0200166 </bean>
167
margaretha56e8e552017-12-05 16:31:21 +0100168
169 <bean id="kustvakt_rewrite" class="de.ids_mannheim.korap.rewrite.FullRewriteHandler">
170 <constructor-arg ref="kustvakt_config" />
171 </bean>
172
margaretha62055f72017-04-11 19:17:43 +0200173 <bean id="kustvakt_auditing" class="de.ids_mannheim.korap.handlers.JDBCAuditing">
174 <constructor-arg ref="kustvakt_db" />
175 </bean>
margaretha58e18632018-02-15 13:04:42 +0100176
177 <bean id="kustvakt_response" class="de.ids_mannheim.korap.web.FullResponseHandler">
178 <constructor-arg index="0" name="iface" ref="kustvakt_auditing" />
179 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +0100180
margaretha62055f72017-04-11 19:17:43 +0200181 <bean id="kustvakt_userdb" class="de.ids_mannheim.korap.handlers.EntityDao">
182 <constructor-arg ref="kustvakt_db" />
183 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +0100184
margaretha62055f72017-04-11 19:17:43 +0200185 <bean id="resource_provider" class="de.ids_mannheim.korap.handlers.ResourceDao">
186 <constructor-arg ref="kustvakt_db" />
187 </bean>
Michael Hanlf8fcc7a2016-06-03 17:41:07 +0200188
margaretha62055f72017-04-11 19:17:43 +0200189 <bean id="document_provider" class="de.ids_mannheim.korap.handlers.DocumentDao">
190 <constructor-arg ref="kustvakt_db" />
191 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +0100192
margaretha62055f72017-04-11 19:17:43 +0200193 <bean name="kustvakt_encryption"
194 class="de.ids_mannheim.korap.interfaces.defaults.KustvaktEncryption">
195 <constructor-arg ref="kustvakt_config" />
196 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +0100197
margaretha62055f72017-04-11 19:17:43 +0200198 <!-- authentication providers to use -->
margaretha58e18632018-02-15 13:04:42 +0100199 <!-- <bean id="api_auth" class="de.ids_mannheim.korap.authentication.APIAuthentication">
200 <constructor-arg type="de.ids_mannheim.korap.config.KustvaktConfiguration"
201 ref="kustvakt_config" /> </bean> -->
margaretha4de41192017-11-15 11:47:11 +0100202 <bean id="ldap_auth" class="de.ids_mannheim.korap.authentication.LdapAuth3">
margaretha62055f72017-04-11 19:17:43 +0200203 <constructor-arg type="de.ids_mannheim.korap.config.KustvaktConfiguration"
204 ref="kustvakt_config" />
205 </bean>
margaretha58e18632018-02-15 13:04:42 +0100206
margaretha62055f72017-04-11 19:17:43 +0200207 <bean id="openid_auth"
margaretha139d0f72017-11-14 18:56:22 +0100208 class="de.ids_mannheim.korap.authentication.OpenIDconnectAuthentication">
margaretha62055f72017-04-11 19:17:43 +0200209 <constructor-arg type="de.ids_mannheim.korap.config.KustvaktConfiguration"
210 ref="kustvakt_config" />
211 <constructor-arg
212 type="de.ids_mannheim.korap.interfaces.db.PersistenceClient" ref="kustvakt_db" />
213 </bean>
214
margaretha58e18632018-02-15 13:04:42 +0100215 <bean id="basic_auth"
216 class="de.ids_mannheim.korap.authentication.BasicAuthentication" />
Michael Hanlbd852b82015-11-18 22:17:00 +0100217
218
margaretha62055f72017-04-11 19:17:43 +0200219 <bean id="session_auth"
margaretha139d0f72017-11-14 18:56:22 +0100220 class="de.ids_mannheim.korap.authentication.SessionAuthentication">
margaretha62055f72017-04-11 19:17:43 +0200221 <constructor-arg type="de.ids_mannheim.korap.config.KustvaktConfiguration"
222 ref="kustvakt_config" />
223 <constructor-arg type="de.ids_mannheim.korap.interfaces.EncryptionIface"
224 ref="kustvakt_encryption" />
225 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +0100226
margaretha62055f72017-04-11 19:17:43 +0200227 <util:list id="kustvakt_authproviders"
228 value-type="de.ids_mannheim.korap.interfaces.AuthenticationIface">
229 <ref bean="basic_auth" />
margaretha4de41192017-11-15 11:47:11 +0100230 <ref bean="ldap_auth" />
margaretha62055f72017-04-11 19:17:43 +0200231 <ref bean="session_auth" />
margaretha4de41192017-11-15 11:47:11 +0100232 <!-- <ref bean="api_auth" /> -->
margaretha62055f72017-04-11 19:17:43 +0200233 <ref bean="openid_auth" />
234 </util:list>
Michael Hanlbd852b82015-11-18 22:17:00 +0100235
margarethaade7d4a2017-07-20 19:53:35 +0200236
margaretha62055f72017-04-11 19:17:43 +0200237 <bean id="userdata_details" class="de.ids_mannheim.korap.handlers.UserDetailsDao">
margarethaade7d4a2017-07-20 19:53:35 +0200238 <constructor-arg ref="kustvakt_db" />
margaretha62055f72017-04-11 19:17:43 +0200239 </bean>
margarethaade7d4a2017-07-20 19:53:35 +0200240
margaretha62055f72017-04-11 19:17:43 +0200241 <bean id="userdata_settings" class="de.ids_mannheim.korap.handlers.UserSettingsDao">
margarethaade7d4a2017-07-20 19:53:35 +0200242 <constructor-arg ref="kustvakt_db" />
margaretha62055f72017-04-11 19:17:43 +0200243 </bean>
Michael Hanldaf86602016-05-12 14:31:52 +0200244
margaretha62055f72017-04-11 19:17:43 +0200245 <util:list id="kustvakt_userdata"
246 value-type="de.ids_mannheim.korap.interfaces.db.UserdataDbIface">
247 <ref bean="userdata_details" />
248 <ref bean="userdata_settings" />
249 </util:list>
Michael Hanldaf86602016-05-12 14:31:52 +0200250
margaretha62055f72017-04-11 19:17:43 +0200251 <util:list id="kustvakt_resources"
252 value-type="de.ids_mannheim.korap.interfaces.db.ResourceOperationIface">
253 <ref bean="document_provider" />
254 <ref bean="resource_provider" />
255 </util:list>
Michael Hanlf8fcc7a2016-06-03 17:41:07 +0200256
margaretha62055f72017-04-11 19:17:43 +0200257 <!-- specify type for constructor argument -->
258 <bean id="kustvakt_authenticationmanager"
margaretha139d0f72017-11-14 18:56:22 +0100259 class="de.ids_mannheim.korap.authentication.KustvaktAuthenticationManager">
margaretha62055f72017-04-11 19:17:43 +0200260 <constructor-arg
margaretha69e8adc2018-03-15 15:14:22 +0100261 type="de.ids_mannheim.korap.interfaces.EntityHandlerIface" ref="kustvakt_userdb" />
margaretha62055f72017-04-11 19:17:43 +0200262 <constructor-arg type="de.ids_mannheim.korap.interfaces.EncryptionIface"
263 ref="kustvakt_encryption" />
264 <constructor-arg ref="kustvakt_config" />
265 <constructor-arg type="de.ids_mannheim.korap.interfaces.db.AuditingIface"
266 ref="kustvakt_auditing" />
267 <constructor-arg ref="kustvakt_userdata" />
268 <!-- inject authentication providers to use -->
269 <property name="providers" ref="kustvakt_authproviders" />
270 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +0100271
margaretha62055f72017-04-11 19:17:43 +0200272 <!-- todo: if db interfaces not loaded via spring, does transaction even
273 work then? -->
274 <!-- the transactional advice (i.e. what 'happens'; see the <aop:advisor/>
275 bean below) -->
276 <tx:advice id="txAdvice" transaction-manager="txManager">
277 <!-- the transactional semantics... -->
278 <tx:attributes>
279 <!-- all methods starting with 'get' are read-only -->
280 <tx:method name="get*" read-only="true" rollback-for="KorAPException" />
281 <!-- other methods use the default transaction settings (see below) -->
282 <tx:method name="*" rollback-for="KorAPException" />
283 </tx:attributes>
284 </tx:advice>
Michael Hanlbd852b82015-11-18 22:17:00 +0100285
margaretha62055f72017-04-11 19:17:43 +0200286 <!-- ensure that the above transactional advice runs for any execution of
287 an operation defined by the service interface -->
288 <aop:config>
289 <aop:pointcut id="service"
290 expression="execution(* de.ids_mannheim.korap.interfaces.db.*.*(..))" />
291 <aop:advisor advice-ref="txAdvice" pointcut-ref="service" />
292 </aop:config>
Michael Hanlbd852b82015-11-18 22:17:00 +0100293
margaretha62055f72017-04-11 19:17:43 +0200294 <!-- similarly, don't forget the PlatformTransactionManager -->
295 <bean id="txManager"
296 class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
297 <property name="dataSource" ref="dataSource" />
298 </bean>
margaretha58e18632018-02-15 13:04:42 +0100299
300 <!-- mail -->
margarethaaecee1b2018-02-20 14:44:21 +0100301 <bean id="authenticator" class="de.ids_mannheim.korap.service.MailAuthenticator">
302 <constructor-arg index="0" value="${mail.username}"/>
303 <constructor-arg index="1" value="${mail.password}"/>
304 </bean>
305 <bean id="smtpSession" class="javax.mail.Session" factory-method="getInstance">
306 <constructor-arg index="0">
307 <props>
308 <prop key="mail.smtp.submitter">${mail.username}</prop>
309 <prop key="mail.smtp.auth">${mail.auth}</prop>
310 <prop key="mail.smtp.host">${mail.host}</prop>
311 <prop key="mail.smtp.port">${mail.port}</prop>
312 <prop key="mail.smtp.starttls.enable">${mail.starttls.enable}</prop>
313 <prop key="mail.smtp.connectiontimeout">${mail.connectiontimeout}</prop>
314 </props>
315 </constructor-arg>
316 <constructor-arg index="1" ref="authenticator"/>
margaretha58e18632018-02-15 13:04:42 +0100317 </bean>
318 <bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
319 <property name="session" ref="smtpSession" />
320 </bean>
321 <bean id="velocityEngine" class="org.apache.velocity.app.VelocityEngine">
322 <constructor-arg index="0">
323 <props>
324 <prop key="resource.loader">class</prop>
325 <prop key="class.resource.loader.class">org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
326 </prop>
327 </props>
328 </constructor-arg>
margarethaaecee1b2018-02-20 14:44:21 +0100329 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +0100330</beans>