blob: 86a5cba8e49a23e7afbc7bb2329ab4b58b2cfa9d [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"
3 xmlns:util="http://www.springframework.org/schema/util"
Michael Hanl72c7b832015-09-03 08:42:15 +02004 xmlns:aop="http://www.springframework.org/schema/aop"
5 xmlns:tx="http://www.springframework.org/schema/tx"
Michael Hanlca740d72015-06-16 10:04:58 +02006 xmlns="http://www.springframework.org/schema/beans"
7 xsi:schemaLocation="http://www.springframework.org/schema/beans
8 http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
Michael Hanl72c7b832015-09-03 08:42:15 +02009 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
Michael Hanle4fc7752016-02-17 11:41:18 +010013
14
Michael Hanlca740d72015-06-16 10:04:58 +020015 http://www.springframework.org/schema/util
16 http://www.springframework.org/schema/util/spring-util-4.0.xsd">
17
Michael Hanl7368aa42016-02-05 18:15:47 +010018 <!--<cache:annotation-driven/>-->
Michael Hanld6eadd52015-11-11 18:30:33 +010019
20 <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 Hanl7368aa42016-02-05 18:15:47 +010042 <!--<bean id='cacheManager'-->
Michael Hanle4fc7752016-02-17 11:41:18 +010043 <!--class='org.springframework.cache.ehcache.EhCacheCacheManager'-->
44 <!--p:cacheManager-ref='ehcache'/>-->
Michael Hanl72c7b832015-09-03 08:42:15 +020045
Michael Hanl7368aa42016-02-05 18:15:47 +010046 <!--<bean id='ehcache'-->
Michael Hanle4fc7752016-02-17 11:41:18 +010047 <!--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 -->
Michael Hanl72c7b832015-09-03 08:42:15 +020059 <bean id="dataSource"
Michael Hanl19390652016-01-16 11:01:24 +010060 class="org.springframework.jdbc.datasource.SingleConnectionDataSource"
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 -->
Michael Hanl19390652016-01-16 11:01:24 +010067 <property name="suppressClose">
68 <value>true</value>
69 </property>
70 <!--<property name="initialSize" value="2"/>-->
71 <!--<property name="maxIdle" value="2"/>-->
72 <!--<property name="poolPreparedStatements" value="true"/>-->
Michael Hanl72c7b832015-09-03 08:42:15 +020073 </bean>
74
75 <!-- to configure database for sqlite, mysql, etc. migrations -->
76 <bean id="flyway" class="org.flywaydb.core.Flyway" init-method="migrate">
77 <property name="baselineOnMigrate" value="false"/>
78 <property name="locations"
79 value="classpath:${jdbc.schemaPath}"/>
80 <property name="dataSource" ref="dataSource"/>
81 </bean>
82
83 <bean id="kustvakt_db"
Michael Hanl482f30d2015-09-25 12:39:46 +020084 class="de.ids_mannheim.korap.handlers.JDBCClient">
Michael Hanl72c7b832015-09-03 08:42:15 +020085 <constructor-arg index="0" ref="dataSource"/>
86 <!-- deprecated property -->
87 <property name="database" value="${jdbc.database}"/>
88 </bean>
89
Michael Hanle4fc7752016-02-17 11:41:18 +010090 <bean id="kustvakt_userdetails"
91 class="de.ids_mannheim.korap.handlers.UserDetailsDao">
92 <constructor-arg ref="kustvakt_db"/>
93 </bean>
94
95 <bean id="kustvakt_usersettings"
96 class="de.ids_mannheim.korap.handlers.UserSettingsDao">
97 <constructor-arg ref="kustvakt_db"/>
98 </bean>
99
Michael Hanl72c7b832015-09-03 08:42:15 +0200100 <bean id="kustvakt_auditing"
Michael Hanl482f30d2015-09-25 12:39:46 +0200101 class="de.ids_mannheim.korap.handlers.JDBCAuditing">
Michael Hanl72c7b832015-09-03 08:42:15 +0200102 <constructor-arg ref="kustvakt_db"/>
103 </bean>
104
105 <bean id="kustvakt_userdb"
Michael Hanl482f30d2015-09-25 12:39:46 +0200106 class="de.ids_mannheim.korap.handlers.EntityDao">
Michael Hanl72c7b832015-09-03 08:42:15 +0200107 <constructor-arg ref="kustvakt_db"/>
108 </bean>
109
Michael Hanl482f30d2015-09-25 12:39:46 +0200110 <!--fixme: change name according to convention -->
Michael Hanl9b84eff2016-01-27 17:11:11 +0100111 <!--<bean id="collectionProvider"-->
Michael Hanle4fc7752016-02-17 11:41:18 +0100112 <!--class="de.ids_mannheim.korap.handlers.CollectionDao">-->
113 <!--<constructor-arg ref="kustvakt_db"/>-->
Michael Hanl9b84eff2016-01-27 17:11:11 +0100114 <!--</bean>-->
Michael Hanl72c7b832015-09-03 08:42:15 +0200115
Michael Hanl482f30d2015-09-25 12:39:46 +0200116 <!--fixme: change name according to convention -->
Michael Hanl72c7b832015-09-03 08:42:15 +0200117 <bean id="resourceProvider"
Michael Hanl482f30d2015-09-25 12:39:46 +0200118 class="de.ids_mannheim.korap.handlers.ResourceDao">
Michael Hanl72c7b832015-09-03 08:42:15 +0200119 <constructor-arg ref="kustvakt_db"/>
120 </bean>
121
122 <bean id="kustvakt_policies"
Michael Hanlf21773f2015-10-16 23:02:31 +0200123 class="de.ids_mannheim.korap.security.ac.PolicyDao">
Michael Hanl72c7b832015-09-03 08:42:15 +0200124 <constructor-arg ref="kustvakt_db"/>
125 </bean>
126
Michael Hanl1e18cb42015-08-06 20:57:35 +0200127 <bean name="kustvakt_encryption"
Michael Hanlf21773f2015-10-16 23:02:31 +0200128 class="de.ids_mannheim.korap.interfaces.defaults.KustvaktEncryption">
Michael Hanl72c7b832015-09-03 08:42:15 +0200129 <constructor-arg ref="kustvakt_config"/>
130 </bean>
131
Michael Hanl72c7b832015-09-03 08:42:15 +0200132 <!-- authentication providers to use -->
Michael Hanl72c7b832015-09-03 08:42:15 +0200133 <bean id="api_auth"
Michael Hanlf21773f2015-10-16 23:02:31 +0200134 class="de.ids_mannheim.korap.security.auth.APIAuthentication">
Michael Hanl72c7b832015-09-03 08:42:15 +0200135 <constructor-arg
136 type="de.ids_mannheim.korap.config.KustvaktConfiguration"
137 ref="kustvakt_config"/>
138 </bean>
139
140 <bean id="openid_auth"
Michael Hanlf21773f2015-10-16 23:02:31 +0200141 class="de.ids_mannheim.korap.security.auth.OpenIDconnectAuthentication">
Michael Hanl72c7b832015-09-03 08:42:15 +0200142 <constructor-arg
143 type="de.ids_mannheim.korap.config.KustvaktConfiguration"
144 ref="kustvakt_config"/>
145 <constructor-arg
Michael Hanlf21773f2015-10-16 23:02:31 +0200146 type="de.ids_mannheim.korap.interfaces.db.PersistenceClient"
Michael Hanl72c7b832015-09-03 08:42:15 +0200147 ref="kustvakt_db"/>
148 </bean>
149
150 <bean id="basic_auth"
Michael Hanlf21773f2015-10-16 23:02:31 +0200151 class="de.ids_mannheim.korap.security.auth.BasicHttpAuth"/>
Michael Hanl72c7b832015-09-03 08:42:15 +0200152
153
154 <bean id="session_auth"
Michael Hanlf21773f2015-10-16 23:02:31 +0200155 class="de.ids_mannheim.korap.security.auth.SessionAuthentication">
Michael Hanl72c7b832015-09-03 08:42:15 +0200156 <constructor-arg
157 type="de.ids_mannheim.korap.config.KustvaktConfiguration"
158 ref="kustvakt_config"/>
159 <constructor-arg
160 type="de.ids_mannheim.korap.interfaces.EncryptionIface"
161 ref="kustvakt_encryption"/>
162 </bean>
163
164 <util:list id="auth_providers"
165 value-type="de.ids_mannheim.korap.interfaces.AuthenticationIface">
166 <ref bean="basic_auth"/>
167 <ref bean="session_auth"/>
168 <ref bean="api_auth"/>
169 <ref bean="openid_auth"/>
170 </util:list>
171
172 <!-- specify type for constructor argument -->
173 <bean id="kustvakt_authenticationmanager"
Michael Hanlf21773f2015-10-16 23:02:31 +0200174 class="de.ids_mannheim.korap.security.auth.KustvaktAuthenticationManager">
Michael Hanl72c7b832015-09-03 08:42:15 +0200175 <constructor-arg
Michael Hanlf21773f2015-10-16 23:02:31 +0200176 type="de.ids_mannheim.korap.interfaces.db.EntityHandlerIface"
Michael Hanl72c7b832015-09-03 08:42:15 +0200177 ref="kustvakt_userdb"/>
178 <constructor-arg type="de.ids_mannheim.korap.interfaces.EncryptionIface"
179 ref="kustvakt_encryption"/>
180 <constructor-arg ref="kustvakt_config"/>
Michael Hanlf21773f2015-10-16 23:02:31 +0200181 <constructor-arg
182 type="de.ids_mannheim.korap.interfaces.db.AuditingIface"
183 ref="kustvakt_auditing"/>
Michael Hanl72c7b832015-09-03 08:42:15 +0200184 <!-- inject authentication providers to use -->
185 <property name="providers" ref="auth_providers"/>
186 </bean>
187
Michael Hanl72c7b832015-09-03 08:42:15 +0200188 <!-- todo: if db interfaces not loaded via spring, does transaction even work then? -->
189 <!-- the transactional advice (i.e. what 'happens'; see the <aop:advisor/> bean below) -->
190 <tx:advice id="txAdvice" transaction-manager="txManager">
191 <!-- the transactional semantics... -->
192 <tx:attributes>
193 <!-- all methods starting with 'get' are read-only -->
194 <tx:method name="get*" read-only="true"
195 rollback-for="KorAPException"/>
196 <!-- other methods use the default transaction settings (see below) -->
197 <tx:method name="*" rollback-for="KorAPException"/>
198 </tx:attributes>
199 </tx:advice>
200
201 <!-- ensure that the above transactional advice runs for any execution
202 of an operation defined by the service interface -->
203 <aop:config>
204 <aop:pointcut id="service"
Michael Hanlf21773f2015-10-16 23:02:31 +0200205 expression="execution(* de.ids_mannheim.korap.interfaces.db.*.*(..))"/>
Michael Hanl72c7b832015-09-03 08:42:15 +0200206 <aop:advisor advice-ref="txAdvice" pointcut-ref="service"/>
207 </aop:config>
208
209 <!-- similarly, don't forget the PlatformTransactionManager -->
210 <bean id="txManager"
211 class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
212 <property name="dataSource" ref="dataSource"/>
Michael Hanlca740d72015-06-16 10:04:58 +0200213 </bean>
214</beans>