blob: 0a954167bc41ebbe85bbe069ccb64bbd1878b837 [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"
Michael Hanlf8fcc7a2016-06-03 17:41:07 +02003 xmlns:p="http://www.springframework.org/schema/p"
Michael Hanlca740d72015-06-16 10:04:58 +02004 xmlns:util="http://www.springframework.org/schema/util"
Michael Hanl72c7b832015-09-03 08:42:15 +02005 xmlns:aop="http://www.springframework.org/schema/aop"
6 xmlns:tx="http://www.springframework.org/schema/tx"
Michael Hanlca740d72015-06-16 10:04:58 +02007 xmlns="http://www.springframework.org/schema/beans"
Michael Hanlf8fcc7a2016-06-03 17:41:07 +02008 xmlns:cache="http://www.springframework.org/schema/cache"
Michael Hanlca740d72015-06-16 10:04:58 +02009 xsi:schemaLocation="http://www.springframework.org/schema/beans
10 http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
Michael Hanl72c7b832015-09-03 08:42:15 +020011 http://www.springframework.org/schema/tx
12 http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
13 http://www.springframework.org/schema/aop
14 http://www.springframework.org/schema/aop/spring-aop-4.0.xsd
Michael Hanle4fc7752016-02-17 11:41:18 +010015
16
Michael Hanlca740d72015-06-16 10:04:58 +020017 http://www.springframework.org/schema/util
18 http://www.springframework.org/schema/util/spring-util-4.0.xsd">
19
Michael Hanld6eadd52015-11-11 18:30:33 +010020 <bean id="props"
21 class="org.springframework.beans.factory.config.PropertiesFactoryBean">
22 <property name="ignoreResourceNotFound" value="true"/>
23 <property name="locations">
24 <array>
25 <value>classpath:kustvakt.conf</value>
Michael Hanl38399df2015-11-13 16:32:19 +010026 <value>file:./kustvakt.conf</value>
Michael Hanld6eadd52015-11-11 18:30:33 +010027 </array>
28 </property>
29 </bean>
Michael Hanlca740d72015-06-16 10:04:58 +020030
Michael Hanl72c7b832015-09-03 08:42:15 +020031 <bean id="jdbc_props"
32 class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
Michael Hanld6eadd52015-11-11 18:30:33 +010033 <property name="ignoreResourceNotFound" value="true"/>
34 <property name="locations">
35 <array>
36 <value>classpath:jdbc.properties</value>
Michael Hanl38399df2015-11-13 16:32:19 +010037 <value>file:./jdbc.properties</value>
Michael Hanld6eadd52015-11-11 18:30:33 +010038 </array>
39 </property>
Michael Hanlca740d72015-06-16 10:04:58 +020040 </bean>
41
Michael Hanlf8fcc7a2016-06-03 17:41:07 +020042 <bean id='cacheManager'
43 class='org.springframework.cache.ehcache.EhCacheCacheManager'
44 p:cacheManager-ref='ehcache'/>
Michael Hanl72c7b832015-09-03 08:42:15 +020045
Michael Hanlf8fcc7a2016-06-03 17:41:07 +020046 <bean id='ehcache'
47 class='org.springframework.cache.ehcache.EhCacheManagerFactoryBean'
48 p:configLocation='classpath:ehcache.xml'
49 p:shared='true'/>
Michael Hanl72c7b832015-09-03 08:42:15 +020050
51 <!-- props are injected from default-config.xml -->
Michael Hanl1e18cb42015-08-06 20:57:35 +020052 <bean id="kustvakt_config"
Michael Hanlf21773f2015-10-16 23:02:31 +020053 class="de.ids_mannheim.korap.config.KustvaktConfiguration">
Michael Hanlca740d72015-06-16 10:04:58 +020054 <property name="properties" ref="props"/>
55 </bean>
56
Michael Hanlf0785322015-11-13 16:14:45 +010057 <!--class="org.apache.commons.dbcp2.BasicDataSource"-->
Michael Hanl2760cc42015-11-16 19:30:01 +010058 <!-- org.springframework.jdbc.datasource.SingleConnectionDataSource -->
margaretha0f5a0e62017-03-21 15:33:11 +010059 <bean id="dataSource"
60 class="org.apache.commons.dbcp2.BasicDataSource"
Michael Hanl72c7b832015-09-03 08:42:15 +020061 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 -->
margaretha0f5a0e62017-03-21 15:33:11 +010067 <!-- <property name="suppressClose">
Michael Hanl19390652016-01-16 11:01:24 +010068 <value>true</value>
margaretha0f5a0e62017-03-21 15:33:11 +010069 </property> -->
Michael Hanl19390652016-01-16 11:01:24 +010070 <!--<property name="initialSize" value="2"/>-->
margaretha0f5a0e62017-03-21 15:33:11 +010071 <property name="maxTotal" value="4"/>
72 <property name="maxIdle" value="2"/>
73 <property name="minIdle" value="1"/>
74 <property name="maxWaitMillis" value="15000"/>
Michael Hanl19390652016-01-16 11:01:24 +010075 <!--<property name="poolPreparedStatements" value="true"/>-->
Michael Hanl72c7b832015-09-03 08:42:15 +020076 </bean>
77
78 <!-- to configure database for sqlite, mysql, etc. migrations -->
79 <bean id="flyway" class="org.flywaydb.core.Flyway" init-method="migrate">
80 <property name="baselineOnMigrate" value="false"/>
81 <property name="locations"
Michael Hanldaf86602016-05-12 14:31:52 +020082 value="${jdbc.schemaPath}"/>
Michael Hanl72c7b832015-09-03 08:42:15 +020083 <property name="dataSource" ref="dataSource"/>
84 </bean>
85
86 <bean id="kustvakt_db"
Michael Hanl482f30d2015-09-25 12:39:46 +020087 class="de.ids_mannheim.korap.handlers.JDBCClient">
Michael Hanl72c7b832015-09-03 08:42:15 +020088 <constructor-arg index="0" ref="dataSource"/>
89 <!-- deprecated property -->
90 <property name="database" value="${jdbc.database}"/>
91 </bean>
92
93 <bean id="kustvakt_auditing"
Michael Hanl482f30d2015-09-25 12:39:46 +020094 class="de.ids_mannheim.korap.handlers.JDBCAuditing">
Michael Hanl72c7b832015-09-03 08:42:15 +020095 <constructor-arg ref="kustvakt_db"/>
96 </bean>
97
98 <bean id="kustvakt_userdb"
Michael Hanl482f30d2015-09-25 12:39:46 +020099 class="de.ids_mannheim.korap.handlers.EntityDao">
Michael Hanl72c7b832015-09-03 08:42:15 +0200100 <constructor-arg ref="kustvakt_db"/>
101 </bean>
margaretha62055f72017-04-11 19:17:43 +0200102
103 <bean id="kustvakt_admindb"
104 class="de.ids_mannheim.korap.handlers.AdminDao">
105 <constructor-arg ref="kustvakt_db"/>
106 </bean>
107
Michael Hanlf8fcc7a2016-06-03 17:41:07 +0200108 <bean id="resource_provider"
Michael Hanl482f30d2015-09-25 12:39:46 +0200109 class="de.ids_mannheim.korap.handlers.ResourceDao">
Michael Hanl72c7b832015-09-03 08:42:15 +0200110 <constructor-arg ref="kustvakt_db"/>
111 </bean>
112
Michael Hanlf8fcc7a2016-06-03 17:41:07 +0200113 <bean id="document_provider"
114 class="de.ids_mannheim.korap.handlers.DocumentDao">
115 <constructor-arg ref="kustvakt_db"/>
116 </bean>
117
Michael Hanl72c7b832015-09-03 08:42:15 +0200118 <bean id="kustvakt_policies"
Michael Hanlf21773f2015-10-16 23:02:31 +0200119 class="de.ids_mannheim.korap.security.ac.PolicyDao">
Michael Hanl72c7b832015-09-03 08:42:15 +0200120 <constructor-arg ref="kustvakt_db"/>
121 </bean>
122
Michael Hanl1e18cb42015-08-06 20:57:35 +0200123 <bean name="kustvakt_encryption"
Michael Hanlf21773f2015-10-16 23:02:31 +0200124 class="de.ids_mannheim.korap.interfaces.defaults.KustvaktEncryption">
Michael Hanl72c7b832015-09-03 08:42:15 +0200125 <constructor-arg ref="kustvakt_config"/>
126 </bean>
127
Michael Hanl72c7b832015-09-03 08:42:15 +0200128 <!-- authentication providers to use -->
Michael Hanl72c7b832015-09-03 08:42:15 +0200129 <bean id="api_auth"
Michael Hanlf21773f2015-10-16 23:02:31 +0200130 class="de.ids_mannheim.korap.security.auth.APIAuthentication">
Michael Hanl72c7b832015-09-03 08:42:15 +0200131 <constructor-arg
132 type="de.ids_mannheim.korap.config.KustvaktConfiguration"
133 ref="kustvakt_config"/>
134 </bean>
135
136 <bean id="openid_auth"
Michael Hanlf21773f2015-10-16 23:02:31 +0200137 class="de.ids_mannheim.korap.security.auth.OpenIDconnectAuthentication">
Michael Hanl72c7b832015-09-03 08:42:15 +0200138 <constructor-arg
139 type="de.ids_mannheim.korap.config.KustvaktConfiguration"
140 ref="kustvakt_config"/>
141 <constructor-arg
Michael Hanlf21773f2015-10-16 23:02:31 +0200142 type="de.ids_mannheim.korap.interfaces.db.PersistenceClient"
Michael Hanl72c7b832015-09-03 08:42:15 +0200143 ref="kustvakt_db"/>
144 </bean>
145
146 <bean id="basic_auth"
Michael Hanlf21773f2015-10-16 23:02:31 +0200147 class="de.ids_mannheim.korap.security.auth.BasicHttpAuth"/>
Michael Hanl72c7b832015-09-03 08:42:15 +0200148
149
150 <bean id="session_auth"
Michael Hanlf21773f2015-10-16 23:02:31 +0200151 class="de.ids_mannheim.korap.security.auth.SessionAuthentication">
Michael Hanl72c7b832015-09-03 08:42:15 +0200152 <constructor-arg
153 type="de.ids_mannheim.korap.config.KustvaktConfiguration"
154 ref="kustvakt_config"/>
155 <constructor-arg
156 type="de.ids_mannheim.korap.interfaces.EncryptionIface"
157 ref="kustvakt_encryption"/>
158 </bean>
159
Michael Hanldaf86602016-05-12 14:31:52 +0200160 <util:list id="kustvakt_authproviders"
Michael Hanl72c7b832015-09-03 08:42:15 +0200161 value-type="de.ids_mannheim.korap.interfaces.AuthenticationIface">
162 <ref bean="basic_auth"/>
163 <ref bean="session_auth"/>
164 <ref bean="api_auth"/>
165 <ref bean="openid_auth"/>
166 </util:list>
167
Michael Hanldaf86602016-05-12 14:31:52 +0200168
169 <bean id="userdata_details"
170 class="de.ids_mannheim.korap.handlers.UserDetailsDao">
171 <constructor-arg
Michael Hanldaf86602016-05-12 14:31:52 +0200172 ref="kustvakt_db"/>
173 </bean>
Michael Hanlf8fcc7a2016-06-03 17:41:07 +0200174
Michael Hanldaf86602016-05-12 14:31:52 +0200175 <bean id="userdata_settings"
Michael Hanlf8fcc7a2016-06-03 17:41:07 +0200176 class="de.ids_mannheim.korap.handlers.UserSettingsDao">
Michael Hanldaf86602016-05-12 14:31:52 +0200177 <constructor-arg
Michael Hanldaf86602016-05-12 14:31:52 +0200178 ref="kustvakt_db"/>
179 </bean>
180
181 <util:list id="kustvakt_userdata"
182 value-type="de.ids_mannheim.korap.interfaces.db.UserdataDbIface">
183 <ref bean="userdata_details"/>
184 <ref bean="userdata_settings"/>
185 </util:list>
186
Michael Hanlf8fcc7a2016-06-03 17:41:07 +0200187
188 <util:list id="kustvakt_resources"
189 value-type="de.ids_mannheim.korap.interfaces.db.ResourceOperationIface">
190 <ref bean="document_provider"/>
191 <ref bean="resource_provider"/>
192 </util:list>
193
Michael Hanl72c7b832015-09-03 08:42:15 +0200194 <!-- specify type for constructor argument -->
195 <bean id="kustvakt_authenticationmanager"
Michael Hanlf21773f2015-10-16 23:02:31 +0200196 class="de.ids_mannheim.korap.security.auth.KustvaktAuthenticationManager">
Michael Hanl72c7b832015-09-03 08:42:15 +0200197 <constructor-arg
Michael Hanlf21773f2015-10-16 23:02:31 +0200198 type="de.ids_mannheim.korap.interfaces.db.EntityHandlerIface"
Michael Hanl72c7b832015-09-03 08:42:15 +0200199 ref="kustvakt_userdb"/>
margaretha62055f72017-04-11 19:17:43 +0200200 <constructor-arg
201 type="de.ids_mannheim.korap.interfaces.db.AdminHandlerIface"
202 ref="kustvakt_admindb"/>
Michael Hanl72c7b832015-09-03 08:42:15 +0200203 <constructor-arg type="de.ids_mannheim.korap.interfaces.EncryptionIface"
204 ref="kustvakt_encryption"/>
205 <constructor-arg ref="kustvakt_config"/>
Michael Hanlf21773f2015-10-16 23:02:31 +0200206 <constructor-arg
207 type="de.ids_mannheim.korap.interfaces.db.AuditingIface"
208 ref="kustvakt_auditing"/>
Michael Hanldaf86602016-05-12 14:31:52 +0200209 <constructor-arg ref="kustvakt_userdata"/>
Michael Hanl72c7b832015-09-03 08:42:15 +0200210 <!-- inject authentication providers to use -->
Michael Hanldaf86602016-05-12 14:31:52 +0200211 <property name="providers" ref="kustvakt_authproviders"/>
Michael Hanl72c7b832015-09-03 08:42:15 +0200212 </bean>
213
Michael Hanl72c7b832015-09-03 08:42:15 +0200214 <!-- todo: if db interfaces not loaded via spring, does transaction even work then? -->
215 <!-- the transactional advice (i.e. what 'happens'; see the <aop:advisor/> bean below) -->
216 <tx:advice id="txAdvice" transaction-manager="txManager">
217 <!-- the transactional semantics... -->
218 <tx:attributes>
219 <!-- all methods starting with 'get' are read-only -->
220 <tx:method name="get*" read-only="true"
221 rollback-for="KorAPException"/>
222 <!-- other methods use the default transaction settings (see below) -->
223 <tx:method name="*" rollback-for="KorAPException"/>
224 </tx:attributes>
225 </tx:advice>
226
227 <!-- ensure that the above transactional advice runs for any execution
228 of an operation defined by the service interface -->
229 <aop:config>
230 <aop:pointcut id="service"
Michael Hanlf21773f2015-10-16 23:02:31 +0200231 expression="execution(* de.ids_mannheim.korap.interfaces.db.*.*(..))"/>
Michael Hanl72c7b832015-09-03 08:42:15 +0200232 <aop:advisor advice-ref="txAdvice" pointcut-ref="service"/>
233 </aop:config>
234
235 <!-- similarly, don't forget the PlatformTransactionManager -->
236 <bean id="txManager"
237 class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
238 <property name="dataSource" ref="dataSource"/>
Michael Hanlca740d72015-06-16 10:04:58 +0200239 </bean>
240</beans>