blob: 01a5ba8bd63e9ec8bcc74fee5a48df90b15dea8b [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>
margarethaf6d5a822017-10-19 19:51:20 +020039 <value>classpath:test-hibernate.properties</value>
margarethaf18298b2017-09-14 22:14:32 +020040 <value>classpath:kustvakt-test.conf</value>
margaretha62055f72017-04-11 19:17:43 +020041 </array>
42 </property>
43 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +010044
margaretha62055f72017-04-11 19:17:43 +020045 <bean id='cacheManager' class='org.springframework.cache.ehcache.EhCacheCacheManager'
46 p:cacheManager-ref='ehcache' />
Michael Hanlbd852b82015-11-18 22:17:00 +010047
margaretha62055f72017-04-11 19:17:43 +020048 <bean id='ehcache'
49 class='org.springframework.cache.ehcache.EhCacheManagerFactoryBean'
50 p:configLocation='classpath:ehcache.xml' p:shared='true' />
Michael Hanlbd852b82015-11-18 22:17:00 +010051
margaretha62055f72017-04-11 19:17:43 +020052 <!-- props are injected from default-config.xml -->
margaretha56e8e552017-12-05 16:31:21 +010053 <bean id="kustvakt_config" class="de.ids_mannheim.korap.config.FullConfiguration">
margarethaf68daa62017-09-21 02:11:24 +020054 <constructor-arg name="properties" ref="props" />
margaretha62055f72017-04-11 19:17:43 +020055 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +010056
margaretha6c2a20f2017-07-24 15:33:01 +020057 <bean id="dataSource" class="org.apache.commons.dbcp2.BasicDataSource"
58 lazy-init="true">
59 <property name="driverClassName" value="${jdbc.driverClassName}" />
60 <property name="url" value="${jdbc.url}" />
61 <property name="username" value="${jdbc.username}" />
62 <property name="password" value="${jdbc.password}" />
margaretha318fec32017-10-24 12:11:58 +020063 <property name="maxTotal" value="4" />
margaretha514e1412017-10-10 15:54:20 +020064 <property name="maxIdle" value="1" />
margaretha6c2a20f2017-07-24 15:33:01 +020065 <property name="minIdle" value="1" />
66 <property name="maxWaitMillis" value="15000" />
67 <!--<property name="poolPreparedStatements" value="true"/> -->
68 </bean>
69
margaretha514e1412017-10-10 15:54:20 +020070 <!-- use SingleConnection only for testing! -->
margaretha6c2a20f2017-07-24 15:33:01 +020071 <bean id="sqliteDataSource"
margaretha62055f72017-04-11 19:17:43 +020072 class="org.springframework.jdbc.datasource.SingleConnectionDataSource"
margaretha318fec32017-10-24 12:11:58 +020073 lazy-init="true">
margaretha514e1412017-10-10 15:54:20 +020074 <!-- <property name="driverClassName" value="${jdbc.driverClassName}" /> -->
margaretha6c2a20f2017-07-24 15:33:01 +020075 <property name="url" value="${jdbc.url}" />
76 <property name="username" value="${jdbc.username}" />
77 <property name="password" value="${jdbc.password}" />
margarethae6c711b2018-02-06 21:55:04 +010078 <property name="connectionProperties">
margaretha58e18632018-02-15 13:04:42 +010079 <props>
80 <prop key="date_string_format">yyyy-MM-dd HH:mm:ss</prop>
81 </props>
82 </property>
83
margaretha514e1412017-10-10 15:54:20 +020084 <!-- Sqlite can only have a single connection -->
margaretha62055f72017-04-11 19:17:43 +020085 <property name="suppressClose">
86 <value>true</value>
87 </property>
margaretha514e1412017-10-10 15:54:20 +020088 </bean>
margaretha58e18632018-02-15 13:04:42 +010089
margaretha514e1412017-10-10 15:54:20 +020090 <bean id="c3p0DataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
margaretha58e18632018-02-15 13:04:42 +010091 destroy-method="close">
92 <property name="driverClass" value="${jdbc.driverClassName}" />
margaretha514e1412017-10-10 15:54:20 +020093 <property name="jdbcUrl" value="${jdbc.url}" />
94 <property name="user" value="${jdbc.username}" />
95 <property name="password" value="${jdbc.password}" />
margaretha58e18632018-02-15 13:04:42 +010096 <property name="maxPoolSize" value="4" />
97 <property name="minPoolSize" value="1" />
98 <property name="maxStatements" value="1" />
99 <property name="testConnectionOnCheckout" value="true" />
margaretha62055f72017-04-11 19:17:43 +0200100 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +0100101
margaretha62055f72017-04-11 19:17:43 +0200102 <!-- to configure database for sqlite, mysql, etc. migrations -->
103 <bean id="flyway" class="org.flywaydb.core.Flyway" init-method="migrate">
margarethaf6d5a822017-10-19 19:51:20 +0200104 <!-- drop existing tables and create new tables -->
105 <property name="validateOnMigrate" value="true" />
106 <property name="cleanOnValidationError" value="true" />
107
margaretha514e1412017-10-10 15:54:20 +0200108 <property name="baselineOnMigrate" value="false" />
109 <property name="locations" value="${jdbc.schemaPath}" />
margaretha6c2a20f2017-07-24 15:33:01 +0200110 <property name="dataSource" ref="sqliteDataSource" />
margaretha318fec32017-10-24 12:11:58 +0200111 <!-- <property name="dataSource" ref="dataSource" /> -->
margaretha62055f72017-04-11 19:17:43 +0200112 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +0100113
margaretha62055f72017-04-11 19:17:43 +0200114 <bean id="kustvakt_db" class="de.ids_mannheim.korap.handlers.JDBCClient">
margaretha318fec32017-10-24 12:11:58 +0200115 <!-- <constructor-arg index="0" ref="dataSource" /> -->
margarethabc9caf42017-09-21 18:52:52 +0200116 <constructor-arg index="0" ref="sqliteDataSource" />
margaretha318fec32017-10-24 12:11:58 +0200117 <property name="database" value="${jdbc.database}" />
margaretha62055f72017-04-11 19:17:43 +0200118 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +0100119
margarethaade7d4a2017-07-20 19:53:35 +0200120 <bean id="entityManagerFactory"
121 class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
margaretha318fec32017-10-24 12:11:58 +0200122 <!-- <property name="dataSource" ref="dataSource" /> -->
123 <property name="dataSource" ref="sqliteDataSource" />
margarethaade7d4a2017-07-20 19:53:35 +0200124 <property name="packagesToScan" value="de.ids_mannheim.korap.entity" />
125 <property name="jpaVendorAdapter">
126 <bean id="jpaVendorAdapter"
127 class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
128 <property name="databasePlatform" value="${hibernate.dialect}" />
129 </bean>
130 </property>
131 <property name="jpaProperties">
132 <props>
133 <prop key="hibernate.dialect">${hibernate.dialect}</prop>
134 <prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop>
135 <prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
136 <prop key="hibernate.cache.use_query_cache">${hibernate.cache.use_query_cache}</prop>
137 <prop key="hibernate.cache.use_second_level_cache">${hibernate.cache.use_second_level_cache}
138 </prop>
139 <prop key="hibernate.cache.provider_class">${hibernate.cache.provider}</prop>
140 <prop key="hibernate.cache.region.factory_class">${hibernate.cache.region.factory}</prop>
141 <!-- <prop key="net.sf.ehcache.configurationResourceName">classpath:ehcache.xml</prop> -->
142 </props>
143 </property>
margaretha62055f72017-04-11 19:17:43 +0200144 </bean>
Michael Hanle4fc7752016-02-17 11:41:18 +0100145
margarethaade7d4a2017-07-20 19:53:35 +0200146 <tx:annotation-driven proxy-target-class="true"
147 transaction-manager="transactionManager" />
148 <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
149 <property name="entityManagerFactory" ref="entityManagerFactory" />
margaretha62055f72017-04-11 19:17:43 +0200150 </bean>
Michael Hanle4fc7752016-02-17 11:41:18 +0100151
margarethaade7d4a2017-07-20 19:53:35 +0200152 <bean id="transactionTemplate"
153 class="org.springframework.transaction.support.TransactionTemplate">
154 <constructor-arg ref="transactionManager" />
155 </bean>
156
157 <!-- Data access objects -->
margaretha58e18632018-02-15 13:04:42 +0100158 <bean id="resourceDao" class="de.ids_mannheim.korap.dao.ResourceDao" />
margarethaade7d4a2017-07-20 19:53:35 +0200159 <!-- <bean id="annotationDao" class="de.ids_mannheim.korap.dao.AnnotationDao"/> -->
160
margaretha6c2a20f2017-07-24 15:33:01 +0200161 <!-- Krill -->
162 <bean id="search_krill" class="de.ids_mannheim.korap.web.SearchKrill">
margaretha58e18632018-02-15 13:04:42 +0100163 <constructor-arg value="${krill.indexDir}" />
margaretha6c2a20f2017-07-24 15:33:01 +0200164 </bean>
165
margaretha56e8e552017-12-05 16:31:21 +0100166
167 <bean id="kustvakt_rewrite" class="de.ids_mannheim.korap.rewrite.FullRewriteHandler">
168 <constructor-arg ref="kustvakt_config" />
169 </bean>
170
margaretha62055f72017-04-11 19:17:43 +0200171 <bean id="kustvakt_auditing" class="de.ids_mannheim.korap.handlers.JDBCAuditing">
172 <constructor-arg ref="kustvakt_db" />
173 </bean>
margaretha58e18632018-02-15 13:04:42 +0100174
175 <bean id="kustvakt_response" class="de.ids_mannheim.korap.web.FullResponseHandler">
176 <constructor-arg index="0" name="iface" ref="kustvakt_auditing" />
177 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +0100178
margaretha62055f72017-04-11 19:17:43 +0200179 <bean id="kustvakt_userdb" class="de.ids_mannheim.korap.handlers.EntityDao">
180 <constructor-arg ref="kustvakt_db" />
181 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +0100182
margaretha62055f72017-04-11 19:17:43 +0200183 <bean id="kustvakt_admindb" class="de.ids_mannheim.korap.handlers.AdminDao">
184 <constructor-arg ref="kustvakt_db" />
185 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +0100186
margaretha62055f72017-04-11 19:17:43 +0200187 <bean id="resource_provider" class="de.ids_mannheim.korap.handlers.ResourceDao">
188 <constructor-arg ref="kustvakt_db" />
189 </bean>
Michael Hanlf8fcc7a2016-06-03 17:41:07 +0200190
margaretha62055f72017-04-11 19:17:43 +0200191 <bean id="document_provider" class="de.ids_mannheim.korap.handlers.DocumentDao">
192 <constructor-arg ref="kustvakt_db" />
193 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +0100194
margaretha62055f72017-04-11 19:17:43 +0200195 <bean id="kustvakt_policies" class="de.ids_mannheim.korap.security.ac.PolicyDao">
196 <constructor-arg ref="kustvakt_db" />
197 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +0100198
margaretha62055f72017-04-11 19:17:43 +0200199 <bean name="kustvakt_encryption"
200 class="de.ids_mannheim.korap.interfaces.defaults.KustvaktEncryption">
201 <constructor-arg ref="kustvakt_config" />
202 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +0100203
margaretha62055f72017-04-11 19:17:43 +0200204 <!-- authentication providers to use -->
margaretha58e18632018-02-15 13:04:42 +0100205 <!-- <bean id="api_auth" class="de.ids_mannheim.korap.authentication.APIAuthentication">
206 <constructor-arg type="de.ids_mannheim.korap.config.KustvaktConfiguration"
207 ref="kustvakt_config" /> </bean> -->
margaretha4de41192017-11-15 11:47:11 +0100208 <bean id="ldap_auth" class="de.ids_mannheim.korap.authentication.LdapAuth3">
margaretha62055f72017-04-11 19:17:43 +0200209 <constructor-arg type="de.ids_mannheim.korap.config.KustvaktConfiguration"
210 ref="kustvakt_config" />
211 </bean>
margaretha58e18632018-02-15 13:04:42 +0100212
margaretha62055f72017-04-11 19:17:43 +0200213 <bean id="openid_auth"
margaretha139d0f72017-11-14 18:56:22 +0100214 class="de.ids_mannheim.korap.authentication.OpenIDconnectAuthentication">
margaretha62055f72017-04-11 19:17:43 +0200215 <constructor-arg type="de.ids_mannheim.korap.config.KustvaktConfiguration"
216 ref="kustvakt_config" />
217 <constructor-arg
218 type="de.ids_mannheim.korap.interfaces.db.PersistenceClient" ref="kustvakt_db" />
219 </bean>
220
margaretha58e18632018-02-15 13:04:42 +0100221 <bean id="basic_auth"
222 class="de.ids_mannheim.korap.authentication.BasicAuthentication" />
Michael Hanlbd852b82015-11-18 22:17:00 +0100223
224
margaretha62055f72017-04-11 19:17:43 +0200225 <bean id="session_auth"
margaretha139d0f72017-11-14 18:56:22 +0100226 class="de.ids_mannheim.korap.authentication.SessionAuthentication">
margaretha62055f72017-04-11 19:17:43 +0200227 <constructor-arg type="de.ids_mannheim.korap.config.KustvaktConfiguration"
228 ref="kustvakt_config" />
229 <constructor-arg type="de.ids_mannheim.korap.interfaces.EncryptionIface"
230 ref="kustvakt_encryption" />
231 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +0100232
margaretha62055f72017-04-11 19:17:43 +0200233 <util:list id="kustvakt_authproviders"
234 value-type="de.ids_mannheim.korap.interfaces.AuthenticationIface">
235 <ref bean="basic_auth" />
margaretha4de41192017-11-15 11:47:11 +0100236 <ref bean="ldap_auth" />
margaretha62055f72017-04-11 19:17:43 +0200237 <ref bean="session_auth" />
margaretha4de41192017-11-15 11:47:11 +0100238 <!-- <ref bean="api_auth" /> -->
margaretha62055f72017-04-11 19:17:43 +0200239 <ref bean="openid_auth" />
240 </util:list>
Michael Hanlbd852b82015-11-18 22:17:00 +0100241
margarethaade7d4a2017-07-20 19:53:35 +0200242
margaretha62055f72017-04-11 19:17:43 +0200243 <bean id="userdata_details" class="de.ids_mannheim.korap.handlers.UserDetailsDao">
margarethaade7d4a2017-07-20 19:53:35 +0200244 <constructor-arg ref="kustvakt_db" />
margaretha62055f72017-04-11 19:17:43 +0200245 </bean>
margarethaade7d4a2017-07-20 19:53:35 +0200246
margaretha62055f72017-04-11 19:17:43 +0200247 <bean id="userdata_settings" class="de.ids_mannheim.korap.handlers.UserSettingsDao">
margarethaade7d4a2017-07-20 19:53:35 +0200248 <constructor-arg ref="kustvakt_db" />
margaretha62055f72017-04-11 19:17:43 +0200249 </bean>
Michael Hanldaf86602016-05-12 14:31:52 +0200250
margaretha62055f72017-04-11 19:17:43 +0200251 <util:list id="kustvakt_userdata"
252 value-type="de.ids_mannheim.korap.interfaces.db.UserdataDbIface">
253 <ref bean="userdata_details" />
254 <ref bean="userdata_settings" />
255 </util:list>
Michael Hanldaf86602016-05-12 14:31:52 +0200256
margaretha62055f72017-04-11 19:17:43 +0200257 <util:list id="kustvakt_resources"
258 value-type="de.ids_mannheim.korap.interfaces.db.ResourceOperationIface">
259 <ref bean="document_provider" />
260 <ref bean="resource_provider" />
261 </util:list>
Michael Hanlf8fcc7a2016-06-03 17:41:07 +0200262
margaretha62055f72017-04-11 19:17:43 +0200263 <!-- specify type for constructor argument -->
264 <bean id="kustvakt_authenticationmanager"
margaretha139d0f72017-11-14 18:56:22 +0100265 class="de.ids_mannheim.korap.authentication.KustvaktAuthenticationManager">
margaretha62055f72017-04-11 19:17:43 +0200266 <constructor-arg
267 type="de.ids_mannheim.korap.interfaces.db.EntityHandlerIface" ref="kustvakt_userdb" />
268 <constructor-arg
269 type="de.ids_mannheim.korap.interfaces.db.AdminHandlerIface" ref="kustvakt_admindb" />
270 <constructor-arg type="de.ids_mannheim.korap.interfaces.EncryptionIface"
271 ref="kustvakt_encryption" />
272 <constructor-arg ref="kustvakt_config" />
273 <constructor-arg type="de.ids_mannheim.korap.interfaces.db.AuditingIface"
274 ref="kustvakt_auditing" />
275 <constructor-arg ref="kustvakt_userdata" />
276 <!-- inject authentication providers to use -->
277 <property name="providers" ref="kustvakt_authproviders" />
278 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +0100279
margaretha62055f72017-04-11 19:17:43 +0200280 <!-- todo: if db interfaces not loaded via spring, does transaction even
281 work then? -->
282 <!-- the transactional advice (i.e. what 'happens'; see the <aop:advisor/>
283 bean below) -->
284 <tx:advice id="txAdvice" transaction-manager="txManager">
285 <!-- the transactional semantics... -->
286 <tx:attributes>
287 <!-- all methods starting with 'get' are read-only -->
288 <tx:method name="get*" read-only="true" rollback-for="KorAPException" />
289 <!-- other methods use the default transaction settings (see below) -->
290 <tx:method name="*" rollback-for="KorAPException" />
291 </tx:attributes>
292 </tx:advice>
Michael Hanlbd852b82015-11-18 22:17:00 +0100293
margaretha62055f72017-04-11 19:17:43 +0200294 <!-- ensure that the above transactional advice runs for any execution of
295 an operation defined by the service interface -->
296 <aop:config>
297 <aop:pointcut id="service"
298 expression="execution(* de.ids_mannheim.korap.interfaces.db.*.*(..))" />
299 <aop:advisor advice-ref="txAdvice" pointcut-ref="service" />
300 </aop:config>
Michael Hanlbd852b82015-11-18 22:17:00 +0100301
margaretha62055f72017-04-11 19:17:43 +0200302 <!-- similarly, don't forget the PlatformTransactionManager -->
303 <bean id="txManager"
304 class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
305 <property name="dataSource" ref="dataSource" />
306 </bean>
margaretha58e18632018-02-15 13:04:42 +0100307
308 <!-- mail -->
309 <!-- <bean id="smtpSession" class="org.springframework.jndi.JndiObjectFactoryBean">
310 <property name="jndiName" value="java:comp/env/mail/jetty" />
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> -->
Michael Hanlbd852b82015-11-18 22:17:00 +0100324</beans>