blob: c401ed489f224e8e24abc734cdd16c30c07bccb7 [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"
margaretha543f2002017-07-14 00:27:15 +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:context="http://www.springframework.org/schema/context"
6 xmlns:cache="http://www.springframework.org/schema/cache"
7 xsi:schemaLocation="http://www.springframework.org/schema/beans
8 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">
17
18 <context:component-scan base-package="de.ids_mannheim.korap" />
19 <context:annotation-config />
20
margarethaade7d4a2017-07-20 19:53:35 +020021 <!-- <bean id="test" class="de.ids_mannheim.korap.web.Test">
22 <property name="config" ref="kustvakt_config" />
23 </bean> -->
24
margaretha543f2002017-07-14 00:27:15 +020025 <bean id="props"
26 class="org.springframework.beans.factory.config.PropertiesFactoryBean">
27 <property name="ignoreResourceNotFound" value="true" />
28 <property name="locations">
29 <array>
30 <value>classpath:kustvakt.conf</value>
31 <value>file:./kustvakt.conf</value>
32 </array>
33 </property>
34 </bean>
35
36 <bean id="placeholders"
37 class="org.springframework.context.support.PropertySourcesPlaceholderConfigurer">
38 <property name="ignoreResourceNotFound" value="true" />
39 <property name="locations">
40 <array>
41 <value>classpath:jdbc.properties</value>
42 <value>classpath:hibernate.properties</value>
43 <!-- <value>file:./jdbc.properties</value> -->
margarethaade7d4a2017-07-20 19:53:35 +020044 <value>file:./kustvakt.conf</value>
45 <value>classpath:kustvakt.conf</value>
margaretha543f2002017-07-14 00:27:15 +020046 </array>
47 </property>
48 </bean>
49
50 <bean id='cacheManager' class='org.springframework.cache.ehcache.EhCacheCacheManager'
51 p:cacheManager-ref='ehcache' />
52
53 <bean id='ehcache'
54 class='org.springframework.cache.ehcache.EhCacheManagerFactoryBean'
55 p:configLocation='classpath:ehcache.xml' p:shared='true' />
56
57 <!-- props are injected from default-config.xml -->
58 <bean id="kustvakt_config" class="de.ids_mannheim.korap.config.KustvaktConfiguration">
59 <property name="properties" ref="props" />
60 </bean>
61
62 <!--class="org.apache.commons.dbcp2.BasicDataSource" -->
63 <!-- org.springframework.jdbc.datasource.SingleConnectionDataSource -->
64 <bean id="dataSource" class="org.apache.commons.dbcp2.BasicDataSource"
65 lazy-init="true">
66 <property name="driverClassName" value="${jdbc.driverClassName}" />
67 <property name="url" value="${jdbc.url}" />
68 <property name="username" value="${jdbc.username}" />
69 <property name="password" value="${jdbc.password}" />
70 <!-- relevant for single connection datasource and sqlite -->
71 <!-- <property name="suppressClose"> <value>true</value> </property> -->
72 <!--<property name="initialSize" value="2"/> -->
73 <property name="maxTotal" value="4" />
74 <property name="maxIdle" value="2" />
75 <property name="minIdle" value="1" />
76 <property name="maxWaitMillis" value="15000" />
77 <!--<property name="poolPreparedStatements" value="true"/> -->
78 </bean>
79
80 <bean id="sqliteDataSource"
81 class="org.springframework.jdbc.datasource.SingleConnectionDataSource"
82 lazy-init="true">
83 <property name="driverClassName" value="${jdbc.driverClassName}" />
84 <property name="url" value="${jdbc.url}" />
85 <property name="username" value="${jdbc.username}" />
86 <property name="password" value="${jdbc.password}" />
87 <!-- relevant for single connection datasource and sqlite -->
88 <property name="suppressClose">
89 <value>true</value>
90 </property>
91 <!--<property name="initialSize" value="2"/> -->
92 <!--<property name="poolPreparedStatements" value="true"/> -->
93 </bean>
94
95 <!-- to configure database for sqlite, mysql, etc. migrations -->
96 <bean id="flyway" class="org.flywaydb.core.Flyway" init-method="migrate">
97 <property name="baselineOnMigrate" value="false" />
98 <property name="validateOnMigrate" value="false" />
99 <property name="locations" value="${jdbc.schemaPath}" />
100 <property name="dataSource" ref="dataSource" />
101 </bean>
102
103 <bean id="kustvakt_db" class="de.ids_mannheim.korap.handlers.JDBCClient">
104 <constructor-arg index="0" ref="dataSource" />
105 <!-- deprecated property -->
106 <property name="database" value="${jdbc.database}" />
107 </bean>
108
109 <bean id="entityManagerFactory"
110 class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
111 <property name="dataSource" ref="dataSource" />
112 <property name="packagesToScan" value="de.ids_mannheim.korap.entity" />
113 <property name="jpaVendorAdapter">
114 <bean id="jpaVendorAdapter"
115 class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
116 <property name="databasePlatform" value="${hibernate.dialect}" />
117 </bean>
118 </property>
119 <property name="jpaProperties">
120 <props>
121 <prop key="hibernate.dialect">${hibernate.dialect}</prop>
122 <prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop>
123 <prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
124 <prop key="hibernate.cache.use_query_cache">${hibernate.cache.use_query_cache}</prop>
125 <prop key="hibernate.cache.use_second_level_cache">${hibernate.cache.use_second_level_cache}
126 </prop>
127 <prop key="hibernate.cache.provider_class">${hibernate.cache.provider}</prop>
128 <prop key="hibernate.cache.region.factory_class">${hibernate.cache.region.factory}</prop>
129 <!-- <prop key="net.sf.ehcache.configurationResourceName">classpath:ehcache.xml</prop> -->
130 </props>
131 </property>
132 </bean>
133
134 <tx:annotation-driven proxy-target-class="true"
135 transaction-manager="transactionManager" />
136 <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
137 <property name="entityManagerFactory" ref="entityManagerFactory" />
138 </bean>
139
140 <bean id="transactionTemplate"
141 class="org.springframework.transaction.support.TransactionTemplate">
142 <constructor-arg ref="transactionManager" />
143 </bean>
144
margarethaade7d4a2017-07-20 19:53:35 +0200145 <!-- Data access objects -->
146 <bean id="resourceDao" class="de.ids_mannheim.korap.dao.ResourceDao"/>
147 <!-- <bean id="annotationDao" class="de.ids_mannheim.korap.dao.AnnotationDao"/> -->
148
149 <!-- Krill -->
150 <bean id="search_krill" class="de.ids_mannheim.korap.web.SearchKrill">
151 <constructor-arg value="${krill.indexDir}"/>
margaretha543f2002017-07-14 00:27:15 +0200152 </bean>
153
154 <bean id="kustvakt_auditing" class="de.ids_mannheim.korap.handlers.JDBCAuditing">
155 <constructor-arg ref="kustvakt_db" />
156 </bean>
157
158 <bean id="kustvakt_userdb" class="de.ids_mannheim.korap.handlers.EntityDao">
159 <constructor-arg ref="kustvakt_db" />
160 </bean>
161
162 <bean id="kustvakt_admindb" class="de.ids_mannheim.korap.handlers.AdminDao">
163 <constructor-arg ref="kustvakt_db" />
164 </bean>
165
166 <bean id="resource_provider" class="de.ids_mannheim.korap.handlers.ResourceDao">
167 <constructor-arg ref="kustvakt_db" />
168 </bean>
169
170 <bean id="document_provider" class="de.ids_mannheim.korap.handlers.DocumentDao">
171 <constructor-arg ref="kustvakt_db" />
172 </bean>
173
174 <bean id="kustvakt_policies" class="de.ids_mannheim.korap.security.ac.PolicyDao">
175 <constructor-arg ref="kustvakt_db" />
176 </bean>
177
178 <bean name="kustvakt_encryption"
179 class="de.ids_mannheim.korap.interfaces.defaults.KustvaktEncryption">
180 <constructor-arg ref="kustvakt_config" />
181 </bean>
182
183 <!-- authentication providers to use -->
184 <bean id="api_auth" class="de.ids_mannheim.korap.security.auth.APIAuthentication">
185 <constructor-arg type="de.ids_mannheim.korap.config.KustvaktConfiguration"
186 ref="kustvakt_config" />
187 </bean>
188
189 <bean id="openid_auth"
190 class="de.ids_mannheim.korap.security.auth.OpenIDconnectAuthentication">
191 <constructor-arg type="de.ids_mannheim.korap.config.KustvaktConfiguration"
192 ref="kustvakt_config" />
193 <constructor-arg
194 type="de.ids_mannheim.korap.interfaces.db.PersistenceClient" ref="kustvakt_db" />
195 </bean>
196
197 <bean id="basic_auth" class="de.ids_mannheim.korap.security.auth.BasicHttpAuth" />
Michael Hanle4fc7752016-02-17 11:41:18 +0100198
199
margaretha543f2002017-07-14 00:27:15 +0200200 <bean id="session_auth"
201 class="de.ids_mannheim.korap.security.auth.SessionAuthentication">
202 <constructor-arg type="de.ids_mannheim.korap.config.KustvaktConfiguration"
203 ref="kustvakt_config" />
204 <constructor-arg type="de.ids_mannheim.korap.interfaces.EncryptionIface"
205 ref="kustvakt_encryption" />
206 </bean>
Michael Hanlca740d72015-06-16 10:04:58 +0200207
margaretha543f2002017-07-14 00:27:15 +0200208 <util:list id="kustvakt_authproviders"
209 value-type="de.ids_mannheim.korap.interfaces.AuthenticationIface">
210 <ref bean="basic_auth" />
211 <ref bean="session_auth" />
212 <ref bean="api_auth" />
213 <ref bean="openid_auth" />
214 </util:list>
Michael Hanl72c7b832015-09-03 08:42:15 +0200215
216
margaretha543f2002017-07-14 00:27:15 +0200217 <bean id="userdata_details" class="de.ids_mannheim.korap.handlers.UserDetailsDao">
218 <constructor-arg ref="kustvakt_db" />
219 </bean>
Michael Hanl72c7b832015-09-03 08:42:15 +0200220
margaretha543f2002017-07-14 00:27:15 +0200221 <bean id="userdata_settings" class="de.ids_mannheim.korap.handlers.UserSettingsDao">
222 <constructor-arg ref="kustvakt_db" />
223 </bean>
224
225 <util:list id="kustvakt_userdata"
226 value-type="de.ids_mannheim.korap.interfaces.db.UserdataDbIface">
227 <ref bean="userdata_details" />
228 <ref bean="userdata_settings" />
229 </util:list>
Michael Hanl72c7b832015-09-03 08:42:15 +0200230
Michael Hanldaf86602016-05-12 14:31:52 +0200231
margaretha543f2002017-07-14 00:27:15 +0200232 <util:list id="kustvakt_resources"
233 value-type="de.ids_mannheim.korap.interfaces.db.ResourceOperationIface">
234 <ref bean="document_provider" />
235 <ref bean="resource_provider" />
236 </util:list>
Michael Hanlf8fcc7a2016-06-03 17:41:07 +0200237
margaretha543f2002017-07-14 00:27:15 +0200238 <!-- specify type for constructor argument -->
239 <bean id="kustvakt_authenticationmanager"
240 class="de.ids_mannheim.korap.security.auth.KustvaktAuthenticationManager">
241 <constructor-arg
242 type="de.ids_mannheim.korap.interfaces.db.EntityHandlerIface" ref="kustvakt_userdb" />
243 <constructor-arg
244 type="de.ids_mannheim.korap.interfaces.db.AdminHandlerIface" ref="kustvakt_admindb" />
245 <constructor-arg type="de.ids_mannheim.korap.interfaces.EncryptionIface"
246 ref="kustvakt_encryption" />
247 <constructor-arg ref="kustvakt_config" />
248 <constructor-arg type="de.ids_mannheim.korap.interfaces.db.AuditingIface"
249 ref="kustvakt_auditing" />
250 <constructor-arg ref="kustvakt_userdata" />
251 <!-- inject authentication providers to use -->
252 <property name="providers" ref="kustvakt_authproviders" />
253 </bean>
Michael Hanldaf86602016-05-12 14:31:52 +0200254
margaretha543f2002017-07-14 00:27:15 +0200255 <!-- todo: if db interfaces not loaded via spring, does transaction even
256 work then? -->
257 <!-- the transactional advice (i.e. what 'happens'; see the <aop:advisor/>
258 bean below) -->
259 <tx:advice id="txAdvice" transaction-manager="txManager">
260 <!-- the transactional semantics... -->
261 <tx:attributes>
262 <!-- all methods starting with 'get' are read-only -->
263 <tx:method name="get*" read-only="true" rollback-for="KorAPException" />
264 <!-- other methods use the default transaction settings (see below) -->
265 <tx:method name="*" rollback-for="KorAPException" />
266 </tx:attributes>
267 </tx:advice>
Michael Hanldaf86602016-05-12 14:31:52 +0200268
margaretha543f2002017-07-14 00:27:15 +0200269 <!-- ensure that the above transactional advice runs for any execution of
270 an operation defined by the service interface -->
271 <aop:config>
272 <aop:pointcut id="service"
273 expression="execution(* de.ids_mannheim.korap.interfaces.db.*.*(..))" />
274 <aop:advisor advice-ref="txAdvice" pointcut-ref="service" />
275 </aop:config>
Michael Hanlf8fcc7a2016-06-03 17:41:07 +0200276
margaretha543f2002017-07-14 00:27:15 +0200277 <!-- similarly, don't forget the PlatformTransactionManager -->
278 <bean id="txManager"
279 class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
280 <property name="dataSource" ref="dataSource" />
281 </bean>
Michael Hanlca740d72015-06-16 10:04:58 +0200282</beans>