blob: ce2dc356e40ff8db9e60640826ae9dfc7d638f28 [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"
3 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:cache="http://www.springframework.org/schema/cache"
9 xsi:schemaLocation="http://www.springframework.org/schema/beans
10 http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
11 http://www.springframework.org/schema/tx
12 http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
13
14
15 http://www.springframework.org/schema/aop
16 http://www.springframework.org/schema/aop/spring-aop-4.0.xsd
17 http://www.springframework.org/schema/cache
18 http://www.springframework.org/schema/cache/spring-cache-4.0.xsd
19
20
21 http://www.springframework.org/schema/util
22 http://www.springframework.org/schema/util/spring-util-4.0.xsd">
23
24 <cache:annotation-driven/>
25
26 <bean id="props"
27 class="org.springframework.beans.factory.config.PropertiesFactoryBean">
28 <property name="ignoreResourceNotFound" value="true"/>
29 <property name="locations">
30 <array>
31 <value>classpath:kustvakt.conf</value>
32 <value>file:./kustvakt.conf</value>
33 </array>
34 </property>
35 </bean>
36
37 <bean id="jdbc_props"
38 class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
39 <property name="ignoreResourceNotFound" value="true"/>
40 <property name="locations">
41 <array>
42 <value>classpath:jdbc.properties</value>
43 <value>file:./jdbc.properties</value>
44 </array>
45 </property>
46 </bean>
47
48 <bean id='cacheManager'
49 class='org.springframework.cache.ehcache.EhCacheCacheManager'
50 p:cacheManager-ref='ehcache'/>
51
52 <bean id='ehcache'
53 class='org.springframework.cache.ehcache.EhCacheManagerFactoryBean'
54 p:configLocation='classpath:ehcache.xml'
55 p:shared='true'/>
56
57 <!-- props are injected from default-config.xml -->
58 <bean id="kustvakt_config"
59 class="de.ids_mannheim.korap.config.KustvaktConfiguration">
60 <property name="properties" ref="props"/>
61 </bean>
62
63 <!--class="org.apache.commons.dbcp2.BasicDataSource"-->
64 <!-- org.springframework.jdbc.datasource.SingleConnectionDataSource -->
65 <bean id="dataSource"
66 class="org.springframework.jdbc.datasource.SingleConnectionDataSource"
67 lazy-init="true">
68 <property name="driverClassName" value="${jdbc.driverClassName}"/>
69 <property name="url" value="${jdbc.url}"/>
70 <property name="username" value="${jdbc.username}"/>
71 <property name="password" value="${jdbc.password}"/>
Michael Hanlefb54c42016-01-16 18:54:03 +010072 <!-- relevant for single connection datasource and sqlite -->
Michael Hanlbd852b82015-11-18 22:17:00 +010073 <property name="suppressClose">
74 <value>true</value>
75 </property>
Michael Hanlefb54c42016-01-16 18:54:03 +010076 <!--<property name="initialSize" value="2"/>-->
77 <!--<property name="maxIdle" value="2"/>-->
78 <!--<property name="poolPreparedStatements" value="true"/>-->
Michael Hanlbd852b82015-11-18 22:17:00 +010079 </bean>
80
81 <!-- to configure database for sqlite, mysql, etc. migrations -->
82 <bean id="flyway" class="org.flywaydb.core.Flyway" init-method="migrate">
83 <property name="baselineOnMigrate" value="false"/>
84 <property name="locations"
85 value="classpath:${jdbc.schemaPath}"/>
86 <property name="dataSource" ref="dataSource"/>
87 </bean>
88
89 <bean id="kustvakt_db"
90 class="de.ids_mannheim.korap.handlers.JDBCClient">
91 <constructor-arg index="0" ref="dataSource"/>
92 <!-- deprecated property -->
93 <property name="database" value="${jdbc.database}"/>
94 </bean>
95
Michael Hanle4fc7752016-02-17 11:41:18 +010096 <bean id="kustvakt_userdetails"
97 class="de.ids_mannheim.korap.handlers.UserDetailsDao">
98 <constructor-arg ref="kustvakt_db"/>
99 </bean>
100
101 <bean id="kustvakt_usersettings"
102 class="de.ids_mannheim.korap.handlers.UserSettingsDao">
103 <constructor-arg ref="kustvakt_db"/>
104 </bean>
105
Michael Hanlbd852b82015-11-18 22:17:00 +0100106 <bean id="kustvakt_auditing"
107 class="de.ids_mannheim.korap.handlers.JDBCAuditing">
108 <constructor-arg ref="kustvakt_db"/>
109 </bean>
110
111 <bean id="kustvakt_userdb"
112 class="de.ids_mannheim.korap.handlers.EntityDao">
113 <constructor-arg ref="kustvakt_db"/>
114 </bean>
115
Michael Hanl9b84eff2016-01-27 17:11:11 +0100116 <!--<bean id="collectionProvider"-->
117 <!--class="de.ids_mannheim.korap.handlers.CollectionDao">-->
118 <!--<constructor-arg ref="kustvakt_db"/>-->
119 <!--</bean>-->
Michael Hanlbd852b82015-11-18 22:17:00 +0100120
121 <!--fixme: change name according to convention -->
122 <bean id="resourceProvider"
123 class="de.ids_mannheim.korap.handlers.ResourceDao">
124 <constructor-arg ref="kustvakt_db"/>
125 </bean>
126
127 <bean id="kustvakt_policies"
128 class="de.ids_mannheim.korap.security.ac.PolicyDao">
129 <constructor-arg ref="kustvakt_db"/>
130 </bean>
131
132 <bean name="kustvakt_encryption"
133 class="de.ids_mannheim.korap.interfaces.defaults.KustvaktEncryption">
134 <constructor-arg ref="kustvakt_config"/>
135 </bean>
136
137 <!-- authentication providers to use -->
138 <bean id="api_auth"
139 class="de.ids_mannheim.korap.security.auth.APIAuthentication">
140 <constructor-arg
141 type="de.ids_mannheim.korap.config.KustvaktConfiguration"
142 ref="kustvakt_config"/>
143 </bean>
144
145 <bean id="openid_auth"
146 class="de.ids_mannheim.korap.security.auth.OpenIDconnectAuthentication">
147 <constructor-arg
148 type="de.ids_mannheim.korap.config.KustvaktConfiguration"
149 ref="kustvakt_config"/>
150 <constructor-arg
151 type="de.ids_mannheim.korap.interfaces.db.PersistenceClient"
152 ref="kustvakt_db"/>
153 </bean>
154
155 <bean id="basic_auth"
156 class="de.ids_mannheim.korap.security.auth.BasicHttpAuth"/>
157
158
159 <bean id="session_auth"
160 class="de.ids_mannheim.korap.security.auth.SessionAuthentication">
161 <constructor-arg
162 type="de.ids_mannheim.korap.config.KustvaktConfiguration"
163 ref="kustvakt_config"/>
164 <constructor-arg
165 type="de.ids_mannheim.korap.interfaces.EncryptionIface"
166 ref="kustvakt_encryption"/>
167 </bean>
168
169 <util:list id="auth_providers"
170 value-type="de.ids_mannheim.korap.interfaces.AuthenticationIface">
171 <ref bean="basic_auth"/>
172 <ref bean="session_auth"/>
173 <ref bean="api_auth"/>
174 <ref bean="openid_auth"/>
175 </util:list>
176
177 <!-- specify type for constructor argument -->
178 <bean id="kustvakt_authenticationmanager"
179 class="de.ids_mannheim.korap.security.auth.KustvaktAuthenticationManager">
180 <constructor-arg
181 type="de.ids_mannheim.korap.interfaces.db.EntityHandlerIface"
182 ref="kustvakt_userdb"/>
183 <constructor-arg type="de.ids_mannheim.korap.interfaces.EncryptionIface"
184 ref="kustvakt_encryption"/>
185 <constructor-arg ref="kustvakt_config"/>
186 <constructor-arg
187 type="de.ids_mannheim.korap.interfaces.db.AuditingIface"
188 ref="kustvakt_auditing"/>
189 <!-- inject authentication providers to use -->
190 <property name="providers" ref="auth_providers"/>
191 </bean>
192
193 <!-- todo: if db interfaces not loaded via spring, does transaction even work then? -->
194 <!-- the transactional advice (i.e. what 'happens'; see the <aop:advisor/> bean below) -->
195 <tx:advice id="txAdvice" transaction-manager="txManager">
196 <!-- the transactional semantics... -->
197 <tx:attributes>
198 <!-- all methods starting with 'get' are read-only -->
199 <tx:method name="get*" read-only="true"
200 rollback-for="KorAPException"/>
201 <!-- other methods use the default transaction settings (see below) -->
202 <tx:method name="*" rollback-for="KorAPException"/>
203 </tx:attributes>
204 </tx:advice>
205
206 <!-- ensure that the above transactional advice runs for any execution
207 of an operation defined by the service interface -->
208 <aop:config>
209 <aop:pointcut id="service"
210 expression="execution(* de.ids_mannheim.korap.interfaces.db.*.*(..))"/>
211 <aop:advisor advice-ref="txAdvice" pointcut-ref="service"/>
212 </aop:config>
213
214 <!-- similarly, don't forget the PlatformTransactionManager -->
215 <bean id="txManager"
216 class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
217 <property name="dataSource" ref="dataSource"/>
218 </bean>
219</beans>