blob: abd03afe0df6f9b8f08f02cdd52e956f4cfbb8fe [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>
margarethaade7d4a2017-07-20 19:53:35 +020038 <value>classpath:hibernate.properties</value>
39 <!-- <value>file:./jdbc.properties</value> -->
margarethaf18298b2017-09-14 22:14:32 +020040 <!-- <value>file:./kustvakt-test.conf</value> -->
41 <value>classpath:kustvakt-test.conf</value>
margaretha62055f72017-04-11 19:17:43 +020042 </array>
43 </property>
44 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +010045
margaretha62055f72017-04-11 19:17:43 +020046 <bean id='cacheManager' class='org.springframework.cache.ehcache.EhCacheCacheManager'
47 p:cacheManager-ref='ehcache' />
Michael Hanlbd852b82015-11-18 22:17:00 +010048
margaretha62055f72017-04-11 19:17:43 +020049 <bean id='ehcache'
50 class='org.springframework.cache.ehcache.EhCacheManagerFactoryBean'
51 p:configLocation='classpath:ehcache.xml' p:shared='true' />
Michael Hanlbd852b82015-11-18 22:17:00 +010052
margaretha62055f72017-04-11 19:17:43 +020053 <!-- props are injected from default-config.xml -->
54 <bean id="kustvakt_config" class="de.ids_mannheim.korap.config.KustvaktConfiguration">
55 <property name="properties" ref="props" />
56 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +010057
margaretha62055f72017-04-11 19:17:43 +020058 <!--class="org.apache.commons.dbcp2.BasicDataSource" -->
59 <!-- org.springframework.jdbc.datasource.SingleConnectionDataSource -->
margaretha6c2a20f2017-07-24 15:33:01 +020060 <bean id="dataSource" class="org.apache.commons.dbcp2.BasicDataSource"
61 lazy-init="true">
62 <property name="driverClassName" value="${jdbc.driverClassName}" />
63 <property name="url" value="${jdbc.url}" />
64 <property name="username" value="${jdbc.username}" />
65 <property name="password" value="${jdbc.password}" />
66 <!-- relevant for single connection datasource and sqlite -->
67 <!-- <property name="suppressClose"> <value>true</value> </property> -->
68 <!--<property name="initialSize" value="2"/> -->
69 <property name="maxTotal" value="4" />
70 <property name="maxIdle" value="2" />
71 <property name="minIdle" value="1" />
72 <property name="maxWaitMillis" value="15000" />
73 <!--<property name="poolPreparedStatements" value="true"/> -->
74 </bean>
75
76 <bean id="sqliteDataSource"
margaretha62055f72017-04-11 19:17:43 +020077 class="org.springframework.jdbc.datasource.SingleConnectionDataSource"
margaretha6c2a20f2017-07-24 15:33:01 +020078 lazy-init="true">
79 <property name="driverClassName" value="${jdbc.driverClassName}" />
80 <property name="url" value="${jdbc.url}" />
81 <property name="username" value="${jdbc.username}" />
82 <property name="password" value="${jdbc.password}" />
margaretha62055f72017-04-11 19:17:43 +020083 <!-- relevant for single connection datasource and sqlite -->
84 <property name="suppressClose">
85 <value>true</value>
86 </property>
87 <!--<property name="initialSize" value="2"/> -->
margaretha62055f72017-04-11 19:17:43 +020088 <!--<property name="poolPreparedStatements" value="true"/> -->
89 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +010090
margaretha62055f72017-04-11 19:17:43 +020091 <!-- to configure database for sqlite, mysql, etc. migrations -->
92 <bean id="flyway" class="org.flywaydb.core.Flyway" init-method="migrate">
margaretha6c2a20f2017-07-24 15:33:01 +020093 <property name="baselineOnMigrate" value="true" />
margaretha62055f72017-04-11 19:17:43 +020094 <property name="locations" value="classpath:db.sqlite" />
margaretha6c2a20f2017-07-24 15:33:01 +020095 <property name="dataSource" ref="sqliteDataSource" />
margaretha62055f72017-04-11 19:17:43 +020096 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +010097
margaretha62055f72017-04-11 19:17:43 +020098 <bean id="kustvakt_db" class="de.ids_mannheim.korap.handlers.JDBCClient">
99 <constructor-arg index="0" ref="dataSource" />
100 <property name="database" value="jdbc:sqlite::memory:" />
101 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +0100102
margarethaade7d4a2017-07-20 19:53:35 +0200103 <bean id="entityManagerFactory"
104 class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
105 <property name="dataSource" ref="dataSource" />
106 <property name="packagesToScan" value="de.ids_mannheim.korap.entity" />
107 <property name="jpaVendorAdapter">
108 <bean id="jpaVendorAdapter"
109 class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
110 <property name="databasePlatform" value="${hibernate.dialect}" />
111 </bean>
112 </property>
113 <property name="jpaProperties">
114 <props>
115 <prop key="hibernate.dialect">${hibernate.dialect}</prop>
116 <prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop>
117 <prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
118 <prop key="hibernate.cache.use_query_cache">${hibernate.cache.use_query_cache}</prop>
119 <prop key="hibernate.cache.use_second_level_cache">${hibernate.cache.use_second_level_cache}
120 </prop>
121 <prop key="hibernate.cache.provider_class">${hibernate.cache.provider}</prop>
122 <prop key="hibernate.cache.region.factory_class">${hibernate.cache.region.factory}</prop>
123 <!-- <prop key="net.sf.ehcache.configurationResourceName">classpath:ehcache.xml</prop> -->
124 </props>
125 </property>
margaretha62055f72017-04-11 19:17:43 +0200126 </bean>
Michael Hanle4fc7752016-02-17 11:41:18 +0100127
margarethaade7d4a2017-07-20 19:53:35 +0200128 <tx:annotation-driven proxy-target-class="true"
129 transaction-manager="transactionManager" />
130 <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
131 <property name="entityManagerFactory" ref="entityManagerFactory" />
margaretha62055f72017-04-11 19:17:43 +0200132 </bean>
Michael Hanle4fc7752016-02-17 11:41:18 +0100133
margarethaade7d4a2017-07-20 19:53:35 +0200134 <bean id="transactionTemplate"
135 class="org.springframework.transaction.support.TransactionTemplate">
136 <constructor-arg ref="transactionManager" />
137 </bean>
138
139 <!-- Data access objects -->
140 <bean id="resourceDao" class="de.ids_mannheim.korap.dao.ResourceDao"/>
141 <!-- <bean id="annotationDao" class="de.ids_mannheim.korap.dao.AnnotationDao"/> -->
142
margaretha6c2a20f2017-07-24 15:33:01 +0200143 <!-- Krill -->
144 <bean id="search_krill" class="de.ids_mannheim.korap.web.SearchKrill">
145 <constructor-arg value="${krill.indexDir}"/>
146 </bean>
147
margaretha62055f72017-04-11 19:17:43 +0200148 <bean id="kustvakt_auditing" class="de.ids_mannheim.korap.handlers.JDBCAuditing">
149 <constructor-arg ref="kustvakt_db" />
150 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +0100151
margaretha62055f72017-04-11 19:17:43 +0200152 <bean id="kustvakt_userdb" class="de.ids_mannheim.korap.handlers.EntityDao">
153 <constructor-arg ref="kustvakt_db" />
154 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +0100155
margaretha62055f72017-04-11 19:17:43 +0200156 <bean id="kustvakt_admindb" class="de.ids_mannheim.korap.handlers.AdminDao">
157 <constructor-arg ref="kustvakt_db" />
158 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +0100159
margaretha62055f72017-04-11 19:17:43 +0200160 <bean id="resource_provider" class="de.ids_mannheim.korap.handlers.ResourceDao">
161 <constructor-arg ref="kustvakt_db" />
162 </bean>
Michael Hanlf8fcc7a2016-06-03 17:41:07 +0200163
margaretha62055f72017-04-11 19:17:43 +0200164 <bean id="document_provider" class="de.ids_mannheim.korap.handlers.DocumentDao">
165 <constructor-arg ref="kustvakt_db" />
166 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +0100167
margaretha62055f72017-04-11 19:17:43 +0200168 <bean id="kustvakt_policies" class="de.ids_mannheim.korap.security.ac.PolicyDao">
169 <constructor-arg ref="kustvakt_db" />
170 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +0100171
margaretha62055f72017-04-11 19:17:43 +0200172 <bean name="kustvakt_encryption"
173 class="de.ids_mannheim.korap.interfaces.defaults.KustvaktEncryption">
174 <constructor-arg ref="kustvakt_config" />
175 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +0100176
margaretha62055f72017-04-11 19:17:43 +0200177 <!-- authentication providers to use -->
178 <bean id="api_auth" class="de.ids_mannheim.korap.security.auth.APIAuthentication">
179 <constructor-arg type="de.ids_mannheim.korap.config.KustvaktConfiguration"
180 ref="kustvakt_config" />
181 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +0100182
margaretha62055f72017-04-11 19:17:43 +0200183 <bean id="openid_auth"
184 class="de.ids_mannheim.korap.security.auth.OpenIDconnectAuthentication">
185 <constructor-arg type="de.ids_mannheim.korap.config.KustvaktConfiguration"
186 ref="kustvakt_config" />
187 <constructor-arg
188 type="de.ids_mannheim.korap.interfaces.db.PersistenceClient" ref="kustvakt_db" />
189 </bean>
190
191 <bean id="basic_auth" class="de.ids_mannheim.korap.security.auth.BasicHttpAuth" />
Michael Hanlbd852b82015-11-18 22:17:00 +0100192
193
margaretha62055f72017-04-11 19:17:43 +0200194 <bean id="session_auth"
195 class="de.ids_mannheim.korap.security.auth.SessionAuthentication">
196 <constructor-arg type="de.ids_mannheim.korap.config.KustvaktConfiguration"
197 ref="kustvakt_config" />
198 <constructor-arg type="de.ids_mannheim.korap.interfaces.EncryptionIface"
199 ref="kustvakt_encryption" />
200 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +0100201
margaretha62055f72017-04-11 19:17:43 +0200202 <util:list id="kustvakt_authproviders"
203 value-type="de.ids_mannheim.korap.interfaces.AuthenticationIface">
204 <ref bean="basic_auth" />
205 <ref bean="session_auth" />
206 <ref bean="api_auth" />
207 <ref bean="openid_auth" />
208 </util:list>
Michael Hanlbd852b82015-11-18 22:17:00 +0100209
margarethaade7d4a2017-07-20 19:53:35 +0200210
margaretha62055f72017-04-11 19:17:43 +0200211 <bean id="userdata_details" class="de.ids_mannheim.korap.handlers.UserDetailsDao">
margarethaade7d4a2017-07-20 19:53:35 +0200212 <constructor-arg ref="kustvakt_db" />
margaretha62055f72017-04-11 19:17:43 +0200213 </bean>
margarethaade7d4a2017-07-20 19:53:35 +0200214
margaretha62055f72017-04-11 19:17:43 +0200215 <bean id="userdata_settings" class="de.ids_mannheim.korap.handlers.UserSettingsDao">
margarethaade7d4a2017-07-20 19:53:35 +0200216 <constructor-arg ref="kustvakt_db" />
margaretha62055f72017-04-11 19:17:43 +0200217 </bean>
Michael Hanldaf86602016-05-12 14:31:52 +0200218
margaretha62055f72017-04-11 19:17:43 +0200219 <util:list id="kustvakt_userdata"
220 value-type="de.ids_mannheim.korap.interfaces.db.UserdataDbIface">
221 <ref bean="userdata_details" />
222 <ref bean="userdata_settings" />
223 </util:list>
Michael Hanldaf86602016-05-12 14:31:52 +0200224
margaretha62055f72017-04-11 19:17:43 +0200225 <util:list id="kustvakt_resources"
226 value-type="de.ids_mannheim.korap.interfaces.db.ResourceOperationIface">
227 <ref bean="document_provider" />
228 <ref bean="resource_provider" />
229 </util:list>
Michael Hanlf8fcc7a2016-06-03 17:41:07 +0200230
margaretha62055f72017-04-11 19:17:43 +0200231 <!-- specify type for constructor argument -->
232 <bean id="kustvakt_authenticationmanager"
233 class="de.ids_mannheim.korap.security.auth.KustvaktAuthenticationManager">
234 <constructor-arg
235 type="de.ids_mannheim.korap.interfaces.db.EntityHandlerIface" ref="kustvakt_userdb" />
236 <constructor-arg
237 type="de.ids_mannheim.korap.interfaces.db.AdminHandlerIface" ref="kustvakt_admindb" />
238 <constructor-arg type="de.ids_mannheim.korap.interfaces.EncryptionIface"
239 ref="kustvakt_encryption" />
240 <constructor-arg ref="kustvakt_config" />
241 <constructor-arg type="de.ids_mannheim.korap.interfaces.db.AuditingIface"
242 ref="kustvakt_auditing" />
243 <constructor-arg ref="kustvakt_userdata" />
244 <!-- inject authentication providers to use -->
245 <property name="providers" ref="kustvakt_authproviders" />
246 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +0100247
margaretha62055f72017-04-11 19:17:43 +0200248 <!-- todo: if db interfaces not loaded via spring, does transaction even
249 work then? -->
250 <!-- the transactional advice (i.e. what 'happens'; see the <aop:advisor/>
251 bean below) -->
252 <tx:advice id="txAdvice" transaction-manager="txManager">
253 <!-- the transactional semantics... -->
254 <tx:attributes>
255 <!-- all methods starting with 'get' are read-only -->
256 <tx:method name="get*" read-only="true" rollback-for="KorAPException" />
257 <!-- other methods use the default transaction settings (see below) -->
258 <tx:method name="*" rollback-for="KorAPException" />
259 </tx:attributes>
260 </tx:advice>
Michael Hanlbd852b82015-11-18 22:17:00 +0100261
margaretha62055f72017-04-11 19:17:43 +0200262 <!-- ensure that the above transactional advice runs for any execution of
263 an operation defined by the service interface -->
264 <aop:config>
265 <aop:pointcut id="service"
266 expression="execution(* de.ids_mannheim.korap.interfaces.db.*.*(..))" />
267 <aop:advisor advice-ref="txAdvice" pointcut-ref="service" />
268 </aop:config>
Michael Hanlbd852b82015-11-18 22:17:00 +0100269
margaretha62055f72017-04-11 19:17:43 +0200270 <!-- similarly, don't forget the PlatformTransactionManager -->
271 <bean id="txManager"
272 class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
273 <property name="dataSource" ref="dataSource" />
274 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +0100275</beans>