blob: a6888828571ada1965491a23242b40b5acbd5a44 [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>
45 <value>classpath:hibernate.properties</value>
46 <!-- <value>file:./jdbc.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 -->
61 <bean id="kustvakt_config" class="de.ids_mannheim.korap.config.KustvaktConfiguration">
62 <property name="properties" ref="props" />
63 </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">
100 <property name="baselineOnMigrate" value="false" />
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}" />
104 <property name="dataSource" ref="dataSource" />
105 </bean>
106
107 <bean id="kustvakt_db" class="de.ids_mannheim.korap.handlers.JDBCClient">
108 <constructor-arg index="0" ref="dataSource" />
109 <!-- deprecated property -->
110 <property name="database" value="${jdbc.database}" />
111 </bean>
112
113 <bean id="entityManagerFactory"
114 class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
115 <property name="dataSource" ref="dataSource" />
116 <property name="packagesToScan" value="de.ids_mannheim.korap.entity" />
117 <property name="jpaVendorAdapter">
118 <bean id="jpaVendorAdapter"
119 class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
120 <property name="databasePlatform" value="${hibernate.dialect}" />
121 </bean>
122 </property>
123 <property name="jpaProperties">
124 <props>
125 <prop key="hibernate.dialect">${hibernate.dialect}</prop>
126 <prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop>
127 <prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
128 <prop key="hibernate.cache.use_query_cache">${hibernate.cache.use_query_cache}</prop>
129 <prop key="hibernate.cache.use_second_level_cache">${hibernate.cache.use_second_level_cache}
130 </prop>
131 <prop key="hibernate.cache.provider_class">${hibernate.cache.provider}</prop>
132 <prop key="hibernate.cache.region.factory_class">${hibernate.cache.region.factory}</prop>
133 <!-- <prop key="net.sf.ehcache.configurationResourceName">classpath:ehcache.xml</prop> -->
134 </props>
135 </property>
136 </bean>
137
138 <tx:annotation-driven proxy-target-class="true"
139 transaction-manager="transactionManager" />
140 <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
141 <property name="entityManagerFactory" ref="entityManagerFactory" />
142 </bean>
143
144 <bean id="transactionTemplate"
145 class="org.springframework.transaction.support.TransactionTemplate">
146 <constructor-arg ref="transactionManager" />
147 </bean>
148
margarethaade7d4a2017-07-20 19:53:35 +0200149 <!-- Data access objects -->
150 <bean id="resourceDao" class="de.ids_mannheim.korap.dao.ResourceDao"/>
151 <!-- <bean id="annotationDao" class="de.ids_mannheim.korap.dao.AnnotationDao"/> -->
152
153 <!-- Krill -->
154 <bean id="search_krill" class="de.ids_mannheim.korap.web.SearchKrill">
155 <constructor-arg value="${krill.indexDir}"/>
margaretha543f2002017-07-14 00:27:15 +0200156 </bean>
157
158 <bean id="kustvakt_auditing" class="de.ids_mannheim.korap.handlers.JDBCAuditing">
159 <constructor-arg ref="kustvakt_db" />
160 </bean>
161
162 <bean id="kustvakt_userdb" class="de.ids_mannheim.korap.handlers.EntityDao">
163 <constructor-arg ref="kustvakt_db" />
164 </bean>
165
166 <bean id="kustvakt_admindb" class="de.ids_mannheim.korap.handlers.AdminDao">
167 <constructor-arg ref="kustvakt_db" />
168 </bean>
169
170 <bean id="resource_provider" class="de.ids_mannheim.korap.handlers.ResourceDao">
171 <constructor-arg ref="kustvakt_db" />
172 </bean>
173
174 <bean id="document_provider" class="de.ids_mannheim.korap.handlers.DocumentDao">
175 <constructor-arg ref="kustvakt_db" />
176 </bean>
177
178 <bean id="kustvakt_policies" class="de.ids_mannheim.korap.security.ac.PolicyDao">
179 <constructor-arg ref="kustvakt_db" />
180 </bean>
181
182 <bean name="kustvakt_encryption"
183 class="de.ids_mannheim.korap.interfaces.defaults.KustvaktEncryption">
184 <constructor-arg ref="kustvakt_config" />
185 </bean>
186
187 <!-- authentication providers to use -->
188 <bean id="api_auth" class="de.ids_mannheim.korap.security.auth.APIAuthentication">
189 <constructor-arg type="de.ids_mannheim.korap.config.KustvaktConfiguration"
190 ref="kustvakt_config" />
191 </bean>
192
193 <bean id="openid_auth"
194 class="de.ids_mannheim.korap.security.auth.OpenIDconnectAuthentication">
195 <constructor-arg type="de.ids_mannheim.korap.config.KustvaktConfiguration"
196 ref="kustvakt_config" />
197 <constructor-arg
198 type="de.ids_mannheim.korap.interfaces.db.PersistenceClient" ref="kustvakt_db" />
199 </bean>
200
201 <bean id="basic_auth" class="de.ids_mannheim.korap.security.auth.BasicHttpAuth" />
Michael Hanle4fc7752016-02-17 11:41:18 +0100202
203
margaretha543f2002017-07-14 00:27:15 +0200204 <bean id="session_auth"
205 class="de.ids_mannheim.korap.security.auth.SessionAuthentication">
206 <constructor-arg type="de.ids_mannheim.korap.config.KustvaktConfiguration"
207 ref="kustvakt_config" />
208 <constructor-arg type="de.ids_mannheim.korap.interfaces.EncryptionIface"
209 ref="kustvakt_encryption" />
210 </bean>
Michael Hanlca740d72015-06-16 10:04:58 +0200211
margaretha543f2002017-07-14 00:27:15 +0200212 <util:list id="kustvakt_authproviders"
213 value-type="de.ids_mannheim.korap.interfaces.AuthenticationIface">
214 <ref bean="basic_auth" />
215 <ref bean="session_auth" />
216 <ref bean="api_auth" />
217 <ref bean="openid_auth" />
218 </util:list>
Michael Hanl72c7b832015-09-03 08:42:15 +0200219
220
margaretha543f2002017-07-14 00:27:15 +0200221 <bean id="userdata_details" class="de.ids_mannheim.korap.handlers.UserDetailsDao">
222 <constructor-arg ref="kustvakt_db" />
223 </bean>
Michael Hanl72c7b832015-09-03 08:42:15 +0200224
margaretha543f2002017-07-14 00:27:15 +0200225 <bean id="userdata_settings" class="de.ids_mannheim.korap.handlers.UserSettingsDao">
226 <constructor-arg ref="kustvakt_db" />
227 </bean>
228
229 <util:list id="kustvakt_userdata"
230 value-type="de.ids_mannheim.korap.interfaces.db.UserdataDbIface">
231 <ref bean="userdata_details" />
232 <ref bean="userdata_settings" />
233 </util:list>
Michael Hanl72c7b832015-09-03 08:42:15 +0200234
Michael Hanldaf86602016-05-12 14:31:52 +0200235
margaretha543f2002017-07-14 00:27:15 +0200236 <util:list id="kustvakt_resources"
237 value-type="de.ids_mannheim.korap.interfaces.db.ResourceOperationIface">
238 <ref bean="document_provider" />
239 <ref bean="resource_provider" />
240 </util:list>
Michael Hanlf8fcc7a2016-06-03 17:41:07 +0200241
margaretha543f2002017-07-14 00:27:15 +0200242 <!-- specify type for constructor argument -->
243 <bean id="kustvakt_authenticationmanager"
244 class="de.ids_mannheim.korap.security.auth.KustvaktAuthenticationManager">
245 <constructor-arg
246 type="de.ids_mannheim.korap.interfaces.db.EntityHandlerIface" ref="kustvakt_userdb" />
247 <constructor-arg
248 type="de.ids_mannheim.korap.interfaces.db.AdminHandlerIface" ref="kustvakt_admindb" />
249 <constructor-arg type="de.ids_mannheim.korap.interfaces.EncryptionIface"
250 ref="kustvakt_encryption" />
251 <constructor-arg ref="kustvakt_config" />
252 <constructor-arg type="de.ids_mannheim.korap.interfaces.db.AuditingIface"
253 ref="kustvakt_auditing" />
254 <constructor-arg ref="kustvakt_userdata" />
255 <!-- inject authentication providers to use -->
256 <property name="providers" ref="kustvakt_authproviders" />
257 </bean>
Michael Hanldaf86602016-05-12 14:31:52 +0200258
margaretha543f2002017-07-14 00:27:15 +0200259 <!-- todo: if db interfaces not loaded via spring, does transaction even
260 work then? -->
261 <!-- the transactional advice (i.e. what 'happens'; see the <aop:advisor/>
262 bean below) -->
263 <tx:advice id="txAdvice" transaction-manager="txManager">
264 <!-- the transactional semantics... -->
265 <tx:attributes>
266 <!-- all methods starting with 'get' are read-only -->
267 <tx:method name="get*" read-only="true" rollback-for="KorAPException" />
268 <!-- other methods use the default transaction settings (see below) -->
269 <tx:method name="*" rollback-for="KorAPException" />
270 </tx:attributes>
271 </tx:advice>
Michael Hanldaf86602016-05-12 14:31:52 +0200272
margaretha543f2002017-07-14 00:27:15 +0200273 <!-- ensure that the above transactional advice runs for any execution of
274 an operation defined by the service interface -->
275 <aop:config>
276 <aop:pointcut id="service"
277 expression="execution(* de.ids_mannheim.korap.interfaces.db.*.*(..))" />
278 <aop:advisor advice-ref="txAdvice" pointcut-ref="service" />
279 </aop:config>
Michael Hanlf8fcc7a2016-06-03 17:41:07 +0200280
margaretha543f2002017-07-14 00:27:15 +0200281 <!-- similarly, don't forget the PlatformTransactionManager -->
282 <bean id="txManager"
283 class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
284 <property name="dataSource" ref="dataSource" />
285 </bean>
Michael Hanlca740d72015-06-16 10:04:58 +0200286</beans>