blob: 625460fcfafd5ba8916873449cdc9062e81d05fd [file] [log] [blame]
Michael Hanlca740d72015-06-16 10:04:58 +02001<?xml version="1.0" encoding="UTF-8"?>
2<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
margaretha14503cd2017-09-08 15:35:24 +02003 xmlns:p="http://www.springframework.org/schema/p"
4 xmlns:util="http://www.springframework.org/schema/util"
5 xmlns:aop="http://www.springframework.org/schema/aop"
6 xmlns:tx="http://www.springframework.org/schema/tx"
7 xmlns="http://www.springframework.org/schema/beans"
8 xmlns:context="http://www.springframework.org/schema/context"
margaretha543f2002017-07-14 00:27:15 +02009 xmlns:cache="http://www.springframework.org/schema/cache"
10 xsi:schemaLocation="http://www.springframework.org/schema/beans
11 http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
12 http://www.springframework.org/schema/tx
13 http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
14 http://www.springframework.org/schema/aop
15 http://www.springframework.org/schema/aop/spring-aop-4.0.xsd
16 http://www.springframework.org/schema/context
17 http://www.springframework.org/schema/context/spring-context-4.0.xsd
18 http://www.springframework.org/schema/util
19 http://www.springframework.org/schema/util/spring-util-4.0.xsd">
20
21 <context:component-scan base-package="de.ids_mannheim.korap" />
22 <context:annotation-config />
23
margarethaade7d4a2017-07-20 19:53:35 +020024 <!-- <bean id="test" class="de.ids_mannheim.korap.web.Test">
25 <property name="config" ref="kustvakt_config" />
26 </bean> -->
27
margaretha543f2002017-07-14 00:27:15 +020028 <bean id="props"
29 class="org.springframework.beans.factory.config.PropertiesFactoryBean">
30 <property name="ignoreResourceNotFound" value="true" />
31 <property name="locations">
32 <array>
33 <value>classpath:kustvakt.conf</value>
34 <value>file:./kustvakt.conf</value>
35 </array>
36 </property>
37 </bean>
38
39 <bean id="placeholders"
40 class="org.springframework.context.support.PropertySourcesPlaceholderConfigurer">
41 <property name="ignoreResourceNotFound" value="true" />
42 <property name="locations">
43 <array>
44 <value>classpath:jdbc.properties</value>
margarethaea68a0a2017-09-21 03:09:49 +020045 <value>file:./jdbc.properties</value>
margaretha543f2002017-07-14 00:27:15 +020046 <value>classpath:hibernate.properties</value>
margarethaade7d4a2017-07-20 19:53:35 +020047 <value>classpath:kustvakt.conf</value>
margaretha14503cd2017-09-08 15:35:24 +020048 <value>file:./kustvakt.conf</value>
margaretha543f2002017-07-14 00:27:15 +020049 </array>
50 </property>
51 </bean>
52
53 <bean id='cacheManager' class='org.springframework.cache.ehcache.EhCacheCacheManager'
54 p:cacheManager-ref='ehcache' />
55
56 <bean id='ehcache'
57 class='org.springframework.cache.ehcache.EhCacheManagerFactoryBean'
58 p:configLocation='classpath:ehcache.xml' p:shared='true' />
59
60 <!-- props are injected from default-config.xml -->
margaretha56e8e552017-12-05 16:31:21 +010061 <bean id="kustvakt_config" class="de.ids_mannheim.korap.config.FullConfiguration">
margarethaf68daa62017-09-21 02:11:24 +020062 <constructor-arg name="properties" ref="props" />
margaretha543f2002017-07-14 00:27:15 +020063 </bean>
64
65 <!--class="org.apache.commons.dbcp2.BasicDataSource" -->
66 <!-- org.springframework.jdbc.datasource.SingleConnectionDataSource -->
67 <bean id="dataSource" class="org.apache.commons.dbcp2.BasicDataSource"
68 lazy-init="true">
69 <property name="driverClassName" value="${jdbc.driverClassName}" />
70 <property name="url" value="${jdbc.url}" />
71 <property name="username" value="${jdbc.username}" />
72 <property name="password" value="${jdbc.password}" />
73 <!-- relevant for single connection datasource and sqlite -->
74 <!-- <property name="suppressClose"> <value>true</value> </property> -->
75 <!--<property name="initialSize" value="2"/> -->
76 <property name="maxTotal" value="4" />
77 <property name="maxIdle" value="2" />
78 <property name="minIdle" value="1" />
79 <property name="maxWaitMillis" value="15000" />
80 <!--<property name="poolPreparedStatements" value="true"/> -->
81 </bean>
82
83 <bean id="sqliteDataSource"
84 class="org.springframework.jdbc.datasource.SingleConnectionDataSource"
85 lazy-init="true">
86 <property name="driverClassName" value="${jdbc.driverClassName}" />
87 <property name="url" value="${jdbc.url}" />
88 <property name="username" value="${jdbc.username}" />
89 <property name="password" value="${jdbc.password}" />
90 <!-- relevant for single connection datasource and sqlite -->
91 <property name="suppressClose">
92 <value>true</value>
93 </property>
94 <!--<property name="initialSize" value="2"/> -->
95 <!--<property name="poolPreparedStatements" value="true"/> -->
96 </bean>
97
98 <!-- to configure database for sqlite, mysql, etc. migrations -->
99 <bean id="flyway" class="org.flywaydb.core.Flyway" init-method="migrate">
margarethaf6d5a822017-10-19 19:51:20 +0200100 <property name="baselineOnMigrate" value="true" />
margarethaecbe72d2017-07-26 17:13:32 +0200101 <!-- <property name="validateOnMigrate" value="false" /> -->
102 <!-- <property name="cleanOnValidationError" value="true" /> -->
margaretha543f2002017-07-14 00:27:15 +0200103 <property name="locations" value="${jdbc.schemaPath}" />
margaretha894a7d72017-11-08 19:24:20 +0100104 <!-- <property name="dataSource" ref="dataSource" /> -->
105 <property name="dataSource" ref="sqliteDataSource" />
margaretha543f2002017-07-14 00:27:15 +0200106 </bean>
margarethaf18298b2017-09-14 22:14:32 +0200107
108
margaretha543f2002017-07-14 00:27:15 +0200109 <bean id="kustvakt_db" class="de.ids_mannheim.korap.handlers.JDBCClient">
110 <constructor-arg index="0" ref="dataSource" />
111 <!-- deprecated property -->
112 <property name="database" value="${jdbc.database}" />
113 </bean>
114
115 <bean id="entityManagerFactory"
116 class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
margaretha894a7d72017-11-08 19:24:20 +0100117 <!-- <property name="dataSource" ref="dataSource" /> -->
118 <property name="dataSource" ref="sqliteDataSource" />
119
margaretha543f2002017-07-14 00:27:15 +0200120 <property name="packagesToScan" value="de.ids_mannheim.korap.entity" />
121 <property name="jpaVendorAdapter">
122 <bean id="jpaVendorAdapter"
123 class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
124 <property name="databasePlatform" value="${hibernate.dialect}" />
125 </bean>
126 </property>
127 <property name="jpaProperties">
128 <props>
129 <prop key="hibernate.dialect">${hibernate.dialect}</prop>
130 <prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop>
131 <prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
132 <prop key="hibernate.cache.use_query_cache">${hibernate.cache.use_query_cache}</prop>
133 <prop key="hibernate.cache.use_second_level_cache">${hibernate.cache.use_second_level_cache}
134 </prop>
135 <prop key="hibernate.cache.provider_class">${hibernate.cache.provider}</prop>
136 <prop key="hibernate.cache.region.factory_class">${hibernate.cache.region.factory}</prop>
137 <!-- <prop key="net.sf.ehcache.configurationResourceName">classpath:ehcache.xml</prop> -->
138 </props>
139 </property>
140 </bean>
141
142 <tx:annotation-driven proxy-target-class="true"
143 transaction-manager="transactionManager" />
margaretha894a7d72017-11-08 19:24:20 +0100144
margaretha543f2002017-07-14 00:27:15 +0200145 <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
146 <property name="entityManagerFactory" ref="entityManagerFactory" />
147 </bean>
148
149 <bean id="transactionTemplate"
150 class="org.springframework.transaction.support.TransactionTemplate">
151 <constructor-arg ref="transactionManager" />
152 </bean>
153
margarethaade7d4a2017-07-20 19:53:35 +0200154 <!-- Data access objects -->
155 <bean id="resourceDao" class="de.ids_mannheim.korap.dao.ResourceDao"/>
156 <!-- <bean id="annotationDao" class="de.ids_mannheim.korap.dao.AnnotationDao"/> -->
157
158 <!-- Krill -->
159 <bean id="search_krill" class="de.ids_mannheim.korap.web.SearchKrill">
160 <constructor-arg value="${krill.indexDir}"/>
margaretha543f2002017-07-14 00:27:15 +0200161 </bean>
162
margaretha56e8e552017-12-05 16:31:21 +0100163
164 <bean id="kustvakt_rewrite" class="de.ids_mannheim.korap.rewrite.FullRewriteHandler">
165 <constructor-arg ref="kustvakt_config" />
166 </bean>
167
margaretha543f2002017-07-14 00:27:15 +0200168 <bean id="kustvakt_auditing" class="de.ids_mannheim.korap.handlers.JDBCAuditing">
169 <constructor-arg ref="kustvakt_db" />
170 </bean>
171
margaretha894a7d72017-11-08 19:24:20 +0100172 <bean id="kustvakt_response"
margaretha56e8e552017-12-05 16:31:21 +0100173 class="de.ids_mannheim.korap.web.FullResponseHandler">
margaretha894a7d72017-11-08 19:24:20 +0100174 <constructor-arg index="0" name="iface" ref="kustvakt_auditing"/>
175 </bean>
176
margaretha543f2002017-07-14 00:27:15 +0200177 <bean id="kustvakt_userdb" class="de.ids_mannheim.korap.handlers.EntityDao">
178 <constructor-arg ref="kustvakt_db" />
179 </bean>
180
181 <bean id="kustvakt_admindb" class="de.ids_mannheim.korap.handlers.AdminDao">
182 <constructor-arg ref="kustvakt_db" />
183 </bean>
184
185 <bean id="resource_provider" class="de.ids_mannheim.korap.handlers.ResourceDao">
186 <constructor-arg ref="kustvakt_db" />
187 </bean>
188
189 <bean id="document_provider" class="de.ids_mannheim.korap.handlers.DocumentDao">
190 <constructor-arg ref="kustvakt_db" />
191 </bean>
192
193 <bean id="kustvakt_policies" class="de.ids_mannheim.korap.security.ac.PolicyDao">
194 <constructor-arg ref="kustvakt_db" />
195 </bean>
196
197 <bean name="kustvakt_encryption"
198 class="de.ids_mannheim.korap.interfaces.defaults.KustvaktEncryption">
199 <constructor-arg ref="kustvakt_config" />
200 </bean>
201
202 <!-- authentication providers to use -->
margaretha4de41192017-11-15 11:47:11 +0100203 <!-- <bean id="api_auth" class="de.ids_mannheim.korap.authentication.APIAuthentication">
204 <constructor-arg type="de.ids_mannheim.korap.config.KustvaktConfiguration"
205 ref="kustvakt_config" />
206 </bean> -->
207
208 <bean id="ldap_auth" class="de.ids_mannheim.korap.authentication.LdapAuth3">
margaretha543f2002017-07-14 00:27:15 +0200209 <constructor-arg type="de.ids_mannheim.korap.config.KustvaktConfiguration"
210 ref="kustvakt_config" />
211 </bean>
212
213 <bean id="openid_auth"
margaretha139d0f72017-11-14 18:56:22 +0100214 class="de.ids_mannheim.korap.authentication.OpenIDconnectAuthentication">
margaretha543f2002017-07-14 00:27:15 +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
margaretha4b5c1412017-11-15 20:55:04 +0100221 <bean id="basic_auth" class="de.ids_mannheim.korap.authentication.BasicAuthentication" />
Michael Hanle4fc7752016-02-17 11:41:18 +0100222
223
margaretha543f2002017-07-14 00:27:15 +0200224 <bean id="session_auth"
margaretha139d0f72017-11-14 18:56:22 +0100225 class="de.ids_mannheim.korap.authentication.SessionAuthentication">
margaretha543f2002017-07-14 00:27:15 +0200226 <constructor-arg type="de.ids_mannheim.korap.config.KustvaktConfiguration"
227 ref="kustvakt_config" />
228 <constructor-arg type="de.ids_mannheim.korap.interfaces.EncryptionIface"
229 ref="kustvakt_encryption" />
230 </bean>
Michael Hanlca740d72015-06-16 10:04:58 +0200231
margaretha543f2002017-07-14 00:27:15 +0200232 <util:list id="kustvakt_authproviders"
233 value-type="de.ids_mannheim.korap.interfaces.AuthenticationIface">
234 <ref bean="basic_auth" />
margaretha4de41192017-11-15 11:47:11 +0100235 <ref bean="ldap_auth" />
margaretha543f2002017-07-14 00:27:15 +0200236 <ref bean="session_auth" />
margaretha4de41192017-11-15 11:47:11 +0100237 <!-- <ref bean="api_auth" /> -->
margaretha543f2002017-07-14 00:27:15 +0200238 <ref bean="openid_auth" />
239 </util:list>
Michael Hanl72c7b832015-09-03 08:42:15 +0200240
241
margaretha543f2002017-07-14 00:27:15 +0200242 <bean id="userdata_details" class="de.ids_mannheim.korap.handlers.UserDetailsDao">
243 <constructor-arg ref="kustvakt_db" />
244 </bean>
Michael Hanl72c7b832015-09-03 08:42:15 +0200245
margaretha543f2002017-07-14 00:27:15 +0200246 <bean id="userdata_settings" class="de.ids_mannheim.korap.handlers.UserSettingsDao">
247 <constructor-arg ref="kustvakt_db" />
248 </bean>
249
250 <util:list id="kustvakt_userdata"
251 value-type="de.ids_mannheim.korap.interfaces.db.UserdataDbIface">
252 <ref bean="userdata_details" />
253 <ref bean="userdata_settings" />
254 </util:list>
Michael Hanl72c7b832015-09-03 08:42:15 +0200255
Michael Hanldaf86602016-05-12 14:31:52 +0200256
margaretha543f2002017-07-14 00:27:15 +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
margaretha543f2002017-07-14 00:27:15 +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">
margaretha543f2002017-07-14 00:27:15 +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 Hanldaf86602016-05-12 14:31:52 +0200279
margaretha543f2002017-07-14 00:27:15 +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 Hanldaf86602016-05-12 14:31:52 +0200293
margaretha543f2002017-07-14 00:27:15 +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 Hanlf8fcc7a2016-06-03 17:41:07 +0200301
margaretha543f2002017-07-14 00:27:15 +0200302 <!-- similarly, don't forget the PlatformTransactionManager -->
303 <bean id="txManager"
304 class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
margaretha894a7d72017-11-08 19:24:20 +0100305 <!-- <property name="dataSource" ref="dataSource" /> -->
306 <property name="dataSource" ref="sqliteDataSource" />
margaretha543f2002017-07-14 00:27:15 +0200307 </bean>
margarethaf68daa62017-09-21 02:11:24 +0200308
Michael Hanlca740d72015-06-16 10:04:58 +0200309</beans>