blob: 48e97a8e03bfcecd9ca36fb7111a4832566390a3 [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"
5 xmlns="http://www.springframework.org/schema/beans" xmlns:cache="http://www.springframework.org/schema/cache"
6 xsi:schemaLocation="http://www.springframework.org/schema/beans
Michael Hanlbd852b82015-11-18 22:17:00 +01007 http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
8 http://www.springframework.org/schema/tx
9 http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
10
11
12 http://www.springframework.org/schema/aop
13 http://www.springframework.org/schema/aop/spring-aop-4.0.xsd
14 http://www.springframework.org/schema/cache
15 http://www.springframework.org/schema/cache/spring-cache-4.0.xsd
16
17
18 http://www.springframework.org/schema/util
19 http://www.springframework.org/schema/util/spring-util-4.0.xsd">
20
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>
26 <value>classpath:kustvakt.conf</value>
27 <value>file:./kustvakt.conf</value>
28 </array>
29 </property>
30 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +010031
margaretha62055f72017-04-11 19:17:43 +020032 <bean id="jdbc_props"
33 class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
34 <property name="ignoreResourceNotFound" value="true" />
35 <property name="locations">
36 <array>
37 <value>classpath:jdbc.properties</value>
38 <value>file:./jdbc_tests.properties</value>
39 </array>
40 </property>
41 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +010042
margaretha62055f72017-04-11 19:17:43 +020043 <bean id='cacheManager' class='org.springframework.cache.ehcache.EhCacheCacheManager'
44 p:cacheManager-ref='ehcache' />
Michael Hanlbd852b82015-11-18 22:17:00 +010045
margaretha62055f72017-04-11 19:17:43 +020046 <bean id='ehcache'
47 class='org.springframework.cache.ehcache.EhCacheManagerFactoryBean'
48 p:configLocation='classpath:ehcache.xml' p:shared='true' />
Michael Hanlbd852b82015-11-18 22:17:00 +010049
margaretha62055f72017-04-11 19:17:43 +020050 <!-- props are injected from default-config.xml -->
51 <bean id="kustvakt_config" class="de.ids_mannheim.korap.config.KustvaktConfiguration">
52 <property name="properties" ref="props" />
53 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +010054
margaretha62055f72017-04-11 19:17:43 +020055 <!--class="org.apache.commons.dbcp2.BasicDataSource" -->
56 <!-- org.springframework.jdbc.datasource.SingleConnectionDataSource -->
57 <!-- org.springframework.jdbc.datasource.DriverManagerDataSource -->
58 <bean id="dataSource"
59 class="org.springframework.jdbc.datasource.SingleConnectionDataSource"
60 lazy-init="false">
61 <property name="driverClassName" value="org.sqlite.JDBC" />
62 <property name="url" value="jdbc:sqlite::memory:" />
63 <!--<property name="initialSize" value="1" /> -->
64 <!--<property name="maxTotal" value="1" /> -->
65 <!--<property name="maxIdle" value="1" /> -->
66 <!--<property name="username" value="${jdbc.username}"/> -->
67 <!--<property name="password" value="${jdbc.password}"/> -->
68 <!-- relevant for single connection datasource and sqlite -->
69 <property name="suppressClose">
70 <value>true</value>
71 </property>
72 <!--<property name="initialSize" value="2"/> -->
73 <!--<property name="maxIdle" value="2"/> -->
74 <!--<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
margaretha62055f72017-04-11 19:17:43 +020089 <bean id="kustvakt_userdetails" class="de.ids_mannheim.korap.handlers.UserDetailsDao">
90 <constructor-arg ref="kustvakt_db" />
91 </bean>
Michael Hanle4fc7752016-02-17 11:41:18 +010092
margaretha62055f72017-04-11 19:17:43 +020093 <bean id="kustvakt_usersettings" class="de.ids_mannheim.korap.handlers.UserSettingsDao">
94 <constructor-arg ref="kustvakt_db" />
95 </bean>
Michael Hanle4fc7752016-02-17 11:41:18 +010096
margaretha62055f72017-04-11 19:17:43 +020097 <bean id="kustvakt_auditing" class="de.ids_mannheim.korap.handlers.JDBCAuditing">
98 <constructor-arg ref="kustvakt_db" />
99 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +0100100
margaretha62055f72017-04-11 19:17:43 +0200101 <bean id="kustvakt_userdb" class="de.ids_mannheim.korap.handlers.EntityDao">
102 <constructor-arg ref="kustvakt_db" />
103 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +0100104
margaretha62055f72017-04-11 19:17:43 +0200105 <bean id="kustvakt_admindb" class="de.ids_mannheim.korap.handlers.AdminDao">
106 <constructor-arg ref="kustvakt_db" />
107 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +0100108
margaretha62055f72017-04-11 19:17:43 +0200109 <bean id="resource_provider" class="de.ids_mannheim.korap.handlers.ResourceDao">
110 <constructor-arg ref="kustvakt_db" />
111 </bean>
Michael Hanlf8fcc7a2016-06-03 17:41:07 +0200112
margaretha62055f72017-04-11 19:17:43 +0200113 <bean id="document_provider" class="de.ids_mannheim.korap.handlers.DocumentDao">
114 <constructor-arg ref="kustvakt_db" />
115 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +0100116
margaretha62055f72017-04-11 19:17:43 +0200117 <bean id="kustvakt_policies" class="de.ids_mannheim.korap.security.ac.PolicyDao">
118 <constructor-arg ref="kustvakt_db" />
119 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +0100120
margaretha62055f72017-04-11 19:17:43 +0200121 <bean name="kustvakt_encryption"
122 class="de.ids_mannheim.korap.interfaces.defaults.KustvaktEncryption">
123 <constructor-arg ref="kustvakt_config" />
124 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +0100125
margaretha62055f72017-04-11 19:17:43 +0200126 <!-- authentication providers to use -->
127 <bean id="api_auth" class="de.ids_mannheim.korap.security.auth.APIAuthentication">
128 <constructor-arg type="de.ids_mannheim.korap.config.KustvaktConfiguration"
129 ref="kustvakt_config" />
130 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +0100131
margaretha62055f72017-04-11 19:17:43 +0200132 <bean id="openid_auth"
133 class="de.ids_mannheim.korap.security.auth.OpenIDconnectAuthentication">
134 <constructor-arg type="de.ids_mannheim.korap.config.KustvaktConfiguration"
135 ref="kustvakt_config" />
136 <constructor-arg
137 type="de.ids_mannheim.korap.interfaces.db.PersistenceClient" ref="kustvakt_db" />
138 </bean>
139
140 <bean id="basic_auth" class="de.ids_mannheim.korap.security.auth.BasicHttpAuth" />
Michael Hanlbd852b82015-11-18 22:17:00 +0100141
142
margaretha62055f72017-04-11 19:17:43 +0200143 <bean id="session_auth"
144 class="de.ids_mannheim.korap.security.auth.SessionAuthentication">
145 <constructor-arg type="de.ids_mannheim.korap.config.KustvaktConfiguration"
146 ref="kustvakt_config" />
147 <constructor-arg type="de.ids_mannheim.korap.interfaces.EncryptionIface"
148 ref="kustvakt_encryption" />
149 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +0100150
margaretha62055f72017-04-11 19:17:43 +0200151 <util:list id="kustvakt_authproviders"
152 value-type="de.ids_mannheim.korap.interfaces.AuthenticationIface">
153 <ref bean="basic_auth" />
154 <ref bean="session_auth" />
155 <ref bean="api_auth" />
156 <ref bean="openid_auth" />
157 </util:list>
Michael Hanlbd852b82015-11-18 22:17:00 +0100158
margaretha62055f72017-04-11 19:17:43 +0200159 <bean id="userdata_details" class="de.ids_mannheim.korap.handlers.UserDetailsDao">
160 <constructor-arg
161 type="de.ids_mannheim.korap.interfaces.db.PersistenceClient" ref="kustvakt_db" />
162 </bean>
163 <bean id="userdata_settings" class="de.ids_mannheim.korap.handlers.UserSettingsDao">
164 <constructor-arg
165 type="de.ids_mannheim.korap.interfaces.db.PersistenceClient" ref="kustvakt_db" />
166 </bean>
Michael Hanldaf86602016-05-12 14:31:52 +0200167
margaretha62055f72017-04-11 19:17:43 +0200168 <util:list id="kustvakt_userdata"
169 value-type="de.ids_mannheim.korap.interfaces.db.UserdataDbIface">
170 <ref bean="userdata_details" />
171 <ref bean="userdata_settings" />
172 </util:list>
Michael Hanldaf86602016-05-12 14:31:52 +0200173
margaretha62055f72017-04-11 19:17:43 +0200174 <util:list id="kustvakt_resources"
175 value-type="de.ids_mannheim.korap.interfaces.db.ResourceOperationIface">
176 <ref bean="document_provider" />
177 <ref bean="resource_provider" />
178 </util:list>
Michael Hanlf8fcc7a2016-06-03 17:41:07 +0200179
Michael Hanldaf86602016-05-12 14:31:52 +0200180
margaretha62055f72017-04-11 19:17:43 +0200181 <!-- specify type for constructor argument -->
182 <bean id="kustvakt_authenticationmanager"
183 class="de.ids_mannheim.korap.security.auth.KustvaktAuthenticationManager">
184 <constructor-arg
185 type="de.ids_mannheim.korap.interfaces.db.EntityHandlerIface" ref="kustvakt_userdb" />
186 <constructor-arg
187 type="de.ids_mannheim.korap.interfaces.db.AdminHandlerIface" ref="kustvakt_admindb" />
188 <constructor-arg type="de.ids_mannheim.korap.interfaces.EncryptionIface"
189 ref="kustvakt_encryption" />
190 <constructor-arg ref="kustvakt_config" />
191 <constructor-arg type="de.ids_mannheim.korap.interfaces.db.AuditingIface"
192 ref="kustvakt_auditing" />
193 <constructor-arg ref="kustvakt_userdata" />
194 <!-- inject authentication providers to use -->
195 <property name="providers" ref="kustvakt_authproviders" />
196 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +0100197
margaretha62055f72017-04-11 19:17:43 +0200198 <!-- todo: if db interfaces not loaded via spring, does transaction even
199 work then? -->
200 <!-- the transactional advice (i.e. what 'happens'; see the <aop:advisor/>
201 bean below) -->
202 <tx:advice id="txAdvice" transaction-manager="txManager">
203 <!-- the transactional semantics... -->
204 <tx:attributes>
205 <!-- all methods starting with 'get' are read-only -->
206 <tx:method name="get*" read-only="true" rollback-for="KorAPException" />
207 <!-- other methods use the default transaction settings (see below) -->
208 <tx:method name="*" rollback-for="KorAPException" />
209 </tx:attributes>
210 </tx:advice>
Michael Hanlbd852b82015-11-18 22:17:00 +0100211
margaretha62055f72017-04-11 19:17:43 +0200212 <!-- ensure that the above transactional advice runs for any execution of
213 an operation defined by the service interface -->
214 <aop:config>
215 <aop:pointcut id="service"
216 expression="execution(* de.ids_mannheim.korap.interfaces.db.*.*(..))" />
217 <aop:advisor advice-ref="txAdvice" pointcut-ref="service" />
218 </aop:config>
Michael Hanlbd852b82015-11-18 22:17:00 +0100219
margaretha62055f72017-04-11 19:17:43 +0200220 <!-- similarly, don't forget the PlatformTransactionManager -->
221 <bean id="txManager"
222 class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
223 <property name="dataSource" ref="dataSource" />
224 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +0100225</beans>