blob: 8c6464dcd53021bc22542c3abbd22e7ec0319119 [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>
37 <value>classpath:jdbc.properties</value>
margarethaade7d4a2017-07-20 19:53:35 +020038 <value>classpath:hibernate.properties</value>
39 <!-- <value>file:./jdbc.properties</value> -->
margaretha62055f72017-04-11 19:17:43 +020040 </array>
41 </property>
42 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +010043
margaretha62055f72017-04-11 19:17:43 +020044 <bean id='cacheManager' class='org.springframework.cache.ehcache.EhCacheCacheManager'
45 p:cacheManager-ref='ehcache' />
Michael Hanlbd852b82015-11-18 22:17:00 +010046
margaretha62055f72017-04-11 19:17:43 +020047 <bean id='ehcache'
48 class='org.springframework.cache.ehcache.EhCacheManagerFactoryBean'
49 p:configLocation='classpath:ehcache.xml' p:shared='true' />
Michael Hanlbd852b82015-11-18 22:17:00 +010050
margaretha62055f72017-04-11 19:17:43 +020051 <!-- props are injected from default-config.xml -->
52 <bean id="kustvakt_config" class="de.ids_mannheim.korap.config.KustvaktConfiguration">
53 <property name="properties" ref="props" />
54 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +010055
margaretha62055f72017-04-11 19:17:43 +020056 <!--class="org.apache.commons.dbcp2.BasicDataSource" -->
57 <!-- org.springframework.jdbc.datasource.SingleConnectionDataSource -->
58 <!-- org.springframework.jdbc.datasource.DriverManagerDataSource -->
59 <bean id="dataSource"
60 class="org.springframework.jdbc.datasource.SingleConnectionDataSource"
61 lazy-init="false">
62 <property name="driverClassName" value="org.sqlite.JDBC" />
63 <property name="url" value="jdbc:sqlite::memory:" />
64 <!--<property name="initialSize" value="1" /> -->
65 <!--<property name="maxTotal" value="1" /> -->
66 <!--<property name="maxIdle" value="1" /> -->
67 <!--<property name="username" value="${jdbc.username}"/> -->
68 <!--<property name="password" value="${jdbc.password}"/> -->
69 <!-- relevant for single connection datasource and sqlite -->
70 <property name="suppressClose">
71 <value>true</value>
72 </property>
73 <!--<property name="initialSize" value="2"/> -->
margaretha62055f72017-04-11 19:17:43 +020074 <!--<property name="poolPreparedStatements" value="true"/> -->
75 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +010076
margaretha62055f72017-04-11 19:17:43 +020077 <!-- to configure database for sqlite, mysql, etc. migrations -->
78 <bean id="flyway" class="org.flywaydb.core.Flyway" init-method="migrate">
79 <property name="baselineOnMigrate" value="false" />
80 <property name="locations" value="classpath:db.sqlite" />
81 <property name="dataSource" ref="dataSource" />
82 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +010083
margaretha62055f72017-04-11 19:17:43 +020084 <bean id="kustvakt_db" class="de.ids_mannheim.korap.handlers.JDBCClient">
85 <constructor-arg index="0" ref="dataSource" />
86 <property name="database" value="jdbc:sqlite::memory:" />
87 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +010088
margarethaade7d4a2017-07-20 19:53:35 +020089 <bean id="entityManagerFactory"
90 class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
91 <property name="dataSource" ref="dataSource" />
92 <property name="packagesToScan" value="de.ids_mannheim.korap.entity" />
93 <property name="jpaVendorAdapter">
94 <bean id="jpaVendorAdapter"
95 class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
96 <property name="databasePlatform" value="${hibernate.dialect}" />
97 </bean>
98 </property>
99 <property name="jpaProperties">
100 <props>
101 <prop key="hibernate.dialect">${hibernate.dialect}</prop>
102 <prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop>
103 <prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
104 <prop key="hibernate.cache.use_query_cache">${hibernate.cache.use_query_cache}</prop>
105 <prop key="hibernate.cache.use_second_level_cache">${hibernate.cache.use_second_level_cache}
106 </prop>
107 <prop key="hibernate.cache.provider_class">${hibernate.cache.provider}</prop>
108 <prop key="hibernate.cache.region.factory_class">${hibernate.cache.region.factory}</prop>
109 <!-- <prop key="net.sf.ehcache.configurationResourceName">classpath:ehcache.xml</prop> -->
110 </props>
111 </property>
margaretha62055f72017-04-11 19:17:43 +0200112 </bean>
Michael Hanle4fc7752016-02-17 11:41:18 +0100113
margarethaade7d4a2017-07-20 19:53:35 +0200114 <tx:annotation-driven proxy-target-class="true"
115 transaction-manager="transactionManager" />
116 <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
117 <property name="entityManagerFactory" ref="entityManagerFactory" />
margaretha62055f72017-04-11 19:17:43 +0200118 </bean>
Michael Hanle4fc7752016-02-17 11:41:18 +0100119
margarethaade7d4a2017-07-20 19:53:35 +0200120 <bean id="transactionTemplate"
121 class="org.springframework.transaction.support.TransactionTemplate">
122 <constructor-arg ref="transactionManager" />
123 </bean>
124
125 <!-- Data access objects -->
126 <bean id="resourceDao" class="de.ids_mannheim.korap.dao.ResourceDao"/>
127 <!-- <bean id="annotationDao" class="de.ids_mannheim.korap.dao.AnnotationDao"/> -->
128
margaretha62055f72017-04-11 19:17:43 +0200129 <bean id="kustvakt_auditing" class="de.ids_mannheim.korap.handlers.JDBCAuditing">
130 <constructor-arg ref="kustvakt_db" />
131 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +0100132
margaretha62055f72017-04-11 19:17:43 +0200133 <bean id="kustvakt_userdb" class="de.ids_mannheim.korap.handlers.EntityDao">
134 <constructor-arg ref="kustvakt_db" />
135 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +0100136
margaretha62055f72017-04-11 19:17:43 +0200137 <bean id="kustvakt_admindb" class="de.ids_mannheim.korap.handlers.AdminDao">
138 <constructor-arg ref="kustvakt_db" />
139 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +0100140
margaretha62055f72017-04-11 19:17:43 +0200141 <bean id="resource_provider" class="de.ids_mannheim.korap.handlers.ResourceDao">
142 <constructor-arg ref="kustvakt_db" />
143 </bean>
Michael Hanlf8fcc7a2016-06-03 17:41:07 +0200144
margaretha62055f72017-04-11 19:17:43 +0200145 <bean id="document_provider" class="de.ids_mannheim.korap.handlers.DocumentDao">
146 <constructor-arg ref="kustvakt_db" />
147 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +0100148
margaretha62055f72017-04-11 19:17:43 +0200149 <bean id="kustvakt_policies" class="de.ids_mannheim.korap.security.ac.PolicyDao">
150 <constructor-arg ref="kustvakt_db" />
151 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +0100152
margaretha62055f72017-04-11 19:17:43 +0200153 <bean name="kustvakt_encryption"
154 class="de.ids_mannheim.korap.interfaces.defaults.KustvaktEncryption">
155 <constructor-arg ref="kustvakt_config" />
156 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +0100157
margaretha62055f72017-04-11 19:17:43 +0200158 <!-- authentication providers to use -->
159 <bean id="api_auth" class="de.ids_mannheim.korap.security.auth.APIAuthentication">
160 <constructor-arg type="de.ids_mannheim.korap.config.KustvaktConfiguration"
161 ref="kustvakt_config" />
162 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +0100163
margaretha62055f72017-04-11 19:17:43 +0200164 <bean id="openid_auth"
165 class="de.ids_mannheim.korap.security.auth.OpenIDconnectAuthentication">
166 <constructor-arg type="de.ids_mannheim.korap.config.KustvaktConfiguration"
167 ref="kustvakt_config" />
168 <constructor-arg
169 type="de.ids_mannheim.korap.interfaces.db.PersistenceClient" ref="kustvakt_db" />
170 </bean>
171
172 <bean id="basic_auth" class="de.ids_mannheim.korap.security.auth.BasicHttpAuth" />
Michael Hanlbd852b82015-11-18 22:17:00 +0100173
174
margaretha62055f72017-04-11 19:17:43 +0200175 <bean id="session_auth"
176 class="de.ids_mannheim.korap.security.auth.SessionAuthentication">
177 <constructor-arg type="de.ids_mannheim.korap.config.KustvaktConfiguration"
178 ref="kustvakt_config" />
179 <constructor-arg type="de.ids_mannheim.korap.interfaces.EncryptionIface"
180 ref="kustvakt_encryption" />
181 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +0100182
margaretha62055f72017-04-11 19:17:43 +0200183 <util:list id="kustvakt_authproviders"
184 value-type="de.ids_mannheim.korap.interfaces.AuthenticationIface">
185 <ref bean="basic_auth" />
186 <ref bean="session_auth" />
187 <ref bean="api_auth" />
188 <ref bean="openid_auth" />
189 </util:list>
Michael Hanlbd852b82015-11-18 22:17:00 +0100190
margarethaade7d4a2017-07-20 19:53:35 +0200191
margaretha62055f72017-04-11 19:17:43 +0200192 <bean id="userdata_details" class="de.ids_mannheim.korap.handlers.UserDetailsDao">
margarethaade7d4a2017-07-20 19:53:35 +0200193 <constructor-arg ref="kustvakt_db" />
margaretha62055f72017-04-11 19:17:43 +0200194 </bean>
margarethaade7d4a2017-07-20 19:53:35 +0200195
margaretha62055f72017-04-11 19:17:43 +0200196 <bean id="userdata_settings" class="de.ids_mannheim.korap.handlers.UserSettingsDao">
margarethaade7d4a2017-07-20 19:53:35 +0200197 <constructor-arg ref="kustvakt_db" />
margaretha62055f72017-04-11 19:17:43 +0200198 </bean>
Michael Hanldaf86602016-05-12 14:31:52 +0200199
margaretha62055f72017-04-11 19:17:43 +0200200 <util:list id="kustvakt_userdata"
201 value-type="de.ids_mannheim.korap.interfaces.db.UserdataDbIface">
202 <ref bean="userdata_details" />
203 <ref bean="userdata_settings" />
204 </util:list>
Michael Hanldaf86602016-05-12 14:31:52 +0200205
margaretha62055f72017-04-11 19:17:43 +0200206 <util:list id="kustvakt_resources"
207 value-type="de.ids_mannheim.korap.interfaces.db.ResourceOperationIface">
208 <ref bean="document_provider" />
209 <ref bean="resource_provider" />
210 </util:list>
Michael Hanlf8fcc7a2016-06-03 17:41:07 +0200211
margaretha62055f72017-04-11 19:17:43 +0200212 <!-- specify type for constructor argument -->
213 <bean id="kustvakt_authenticationmanager"
214 class="de.ids_mannheim.korap.security.auth.KustvaktAuthenticationManager">
215 <constructor-arg
216 type="de.ids_mannheim.korap.interfaces.db.EntityHandlerIface" ref="kustvakt_userdb" />
217 <constructor-arg
218 type="de.ids_mannheim.korap.interfaces.db.AdminHandlerIface" ref="kustvakt_admindb" />
219 <constructor-arg type="de.ids_mannheim.korap.interfaces.EncryptionIface"
220 ref="kustvakt_encryption" />
221 <constructor-arg ref="kustvakt_config" />
222 <constructor-arg type="de.ids_mannheim.korap.interfaces.db.AuditingIface"
223 ref="kustvakt_auditing" />
224 <constructor-arg ref="kustvakt_userdata" />
225 <!-- inject authentication providers to use -->
226 <property name="providers" ref="kustvakt_authproviders" />
227 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +0100228
margaretha62055f72017-04-11 19:17:43 +0200229 <!-- todo: if db interfaces not loaded via spring, does transaction even
230 work then? -->
231 <!-- the transactional advice (i.e. what 'happens'; see the <aop:advisor/>
232 bean below) -->
233 <tx:advice id="txAdvice" transaction-manager="txManager">
234 <!-- the transactional semantics... -->
235 <tx:attributes>
236 <!-- all methods starting with 'get' are read-only -->
237 <tx:method name="get*" read-only="true" rollback-for="KorAPException" />
238 <!-- other methods use the default transaction settings (see below) -->
239 <tx:method name="*" rollback-for="KorAPException" />
240 </tx:attributes>
241 </tx:advice>
Michael Hanlbd852b82015-11-18 22:17:00 +0100242
margaretha62055f72017-04-11 19:17:43 +0200243 <!-- ensure that the above transactional advice runs for any execution of
244 an operation defined by the service interface -->
245 <aop:config>
246 <aop:pointcut id="service"
247 expression="execution(* de.ids_mannheim.korap.interfaces.db.*.*(..))" />
248 <aop:advisor advice-ref="txAdvice" pointcut-ref="service" />
249 </aop:config>
Michael Hanlbd852b82015-11-18 22:17:00 +0100250
margaretha62055f72017-04-11 19:17:43 +0200251 <!-- similarly, don't forget the PlatformTransactionManager -->
252 <bean id="txManager"
253 class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
254 <property name="dataSource" ref="dataSource" />
255 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +0100256</beans>