blob: cb6291055768b5de10e66603310f200d85f7e10b [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 Hanl72c7b832015-09-03 08:42:15 +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 Hanl72c7b832015-09-03 08:42:15 +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
Michael Hanld6eadd52015-11-11 18:30:33 +010013
14
Michael Hanl72c7b832015-09-03 08:42:15 +020015 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
Michael Hanlca740d72015-06-16 10:04:58 +020021 http://www.springframework.org/schema/util
22 http://www.springframework.org/schema/util/spring-util-4.0.xsd">
23
Michael Hanl72c7b832015-09-03 08:42:15 +020024 <cache:annotation-driven/>
Michael Hanld6eadd52015-11-11 18:30:33 +010025
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>
Michael Hanl38399df2015-11-13 16:32:19 +010032 <value>file:./kustvakt.conf</value>
Michael Hanld6eadd52015-11-11 18:30:33 +010033 </array>
34 </property>
35 </bean>
Michael Hanlca740d72015-06-16 10:04:58 +020036
Michael Hanl72c7b832015-09-03 08:42:15 +020037 <bean id="jdbc_props"
38 class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
Michael Hanld6eadd52015-11-11 18:30:33 +010039 <property name="ignoreResourceNotFound" value="true"/>
40 <property name="locations">
41 <array>
42 <value>classpath:jdbc.properties</value>
Michael Hanl38399df2015-11-13 16:32:19 +010043 <value>file:./jdbc.properties</value>
Michael Hanld6eadd52015-11-11 18:30:33 +010044 </array>
45 </property>
Michael Hanlca740d72015-06-16 10:04:58 +020046 </bean>
47
Michael Hanl72c7b832015-09-03 08:42:15 +020048 <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 -->
Michael Hanl1e18cb42015-08-06 20:57:35 +020058 <bean id="kustvakt_config"
Michael Hanlf21773f2015-10-16 23:02:31 +020059 class="de.ids_mannheim.korap.config.KustvaktConfiguration">
Michael Hanlca740d72015-06-16 10:04:58 +020060 <property name="properties" ref="props"/>
61 </bean>
62
Michael Hanlf0785322015-11-13 16:14:45 +010063 <!--class="org.apache.commons.dbcp2.BasicDataSource"-->
Michael Hanl2760cc42015-11-16 19:30:01 +010064 <!-- org.springframework.jdbc.datasource.SingleConnectionDataSource -->
Michael Hanl72c7b832015-09-03 08:42:15 +020065 <bean id="dataSource"
Michael Hanl19390652016-01-16 11:01:24 +010066 class="org.springframework.jdbc.datasource.SingleConnectionDataSource"
Michael Hanl72c7b832015-09-03 08:42:15 +020067 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}"/>
72 <!-- relevant for single connection datasource and sqlite -->
Michael Hanl19390652016-01-16 11:01:24 +010073 <property name="suppressClose">
74 <value>true</value>
75 </property>
76 <!--<property name="initialSize" value="2"/>-->
77 <!--<property name="maxIdle" value="2"/>-->
78 <!--<property name="poolPreparedStatements" value="true"/>-->
Michael Hanl72c7b832015-09-03 08:42:15 +020079 </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"
Michael Hanl482f30d2015-09-25 12:39:46 +020090 class="de.ids_mannheim.korap.handlers.JDBCClient">
Michael Hanl72c7b832015-09-03 08:42:15 +020091 <constructor-arg index="0" ref="dataSource"/>
92 <!-- deprecated property -->
93 <property name="database" value="${jdbc.database}"/>
94 </bean>
95
96 <bean id="kustvakt_auditing"
Michael Hanl482f30d2015-09-25 12:39:46 +020097 class="de.ids_mannheim.korap.handlers.JDBCAuditing">
Michael Hanl72c7b832015-09-03 08:42:15 +020098 <constructor-arg ref="kustvakt_db"/>
99 </bean>
100
101 <bean id="kustvakt_userdb"
Michael Hanl482f30d2015-09-25 12:39:46 +0200102 class="de.ids_mannheim.korap.handlers.EntityDao">
Michael Hanl72c7b832015-09-03 08:42:15 +0200103 <constructor-arg ref="kustvakt_db"/>
104 </bean>
105
Michael Hanl482f30d2015-09-25 12:39:46 +0200106 <!--fixme: change name according to convention -->
Michael Hanl9b84eff2016-01-27 17:11:11 +0100107 <!--<bean id="collectionProvider"-->
108 <!--class="de.ids_mannheim.korap.handlers.CollectionDao">-->
109 <!--<constructor-arg ref="kustvakt_db"/>-->
110 <!--</bean>-->
Michael Hanl72c7b832015-09-03 08:42:15 +0200111
Michael Hanl482f30d2015-09-25 12:39:46 +0200112 <!--fixme: change name according to convention -->
Michael Hanl72c7b832015-09-03 08:42:15 +0200113 <bean id="resourceProvider"
Michael Hanl482f30d2015-09-25 12:39:46 +0200114 class="de.ids_mannheim.korap.handlers.ResourceDao">
Michael Hanl72c7b832015-09-03 08:42:15 +0200115 <constructor-arg ref="kustvakt_db"/>
116 </bean>
117
118 <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
160 <util:list id="auth_providers"
161 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
168 <!-- specify type for constructor argument -->
169 <bean id="kustvakt_authenticationmanager"
Michael Hanlf21773f2015-10-16 23:02:31 +0200170 class="de.ids_mannheim.korap.security.auth.KustvaktAuthenticationManager">
Michael Hanl72c7b832015-09-03 08:42:15 +0200171 <constructor-arg
Michael Hanlf21773f2015-10-16 23:02:31 +0200172 type="de.ids_mannheim.korap.interfaces.db.EntityHandlerIface"
Michael Hanl72c7b832015-09-03 08:42:15 +0200173 ref="kustvakt_userdb"/>
174 <constructor-arg type="de.ids_mannheim.korap.interfaces.EncryptionIface"
175 ref="kustvakt_encryption"/>
176 <constructor-arg ref="kustvakt_config"/>
Michael Hanlf21773f2015-10-16 23:02:31 +0200177 <constructor-arg
178 type="de.ids_mannheim.korap.interfaces.db.AuditingIface"
179 ref="kustvakt_auditing"/>
Michael Hanl72c7b832015-09-03 08:42:15 +0200180 <!-- inject authentication providers to use -->
181 <property name="providers" ref="auth_providers"/>
182 </bean>
183
Michael Hanl72c7b832015-09-03 08:42:15 +0200184 <!-- todo: if db interfaces not loaded via spring, does transaction even work then? -->
185 <!-- the transactional advice (i.e. what 'happens'; see the <aop:advisor/> bean below) -->
186 <tx:advice id="txAdvice" transaction-manager="txManager">
187 <!-- the transactional semantics... -->
188 <tx:attributes>
189 <!-- all methods starting with 'get' are read-only -->
190 <tx:method name="get*" read-only="true"
191 rollback-for="KorAPException"/>
192 <!-- other methods use the default transaction settings (see below) -->
193 <tx:method name="*" rollback-for="KorAPException"/>
194 </tx:attributes>
195 </tx:advice>
196
197 <!-- ensure that the above transactional advice runs for any execution
198 of an operation defined by the service interface -->
199 <aop:config>
200 <aop:pointcut id="service"
Michael Hanlf21773f2015-10-16 23:02:31 +0200201 expression="execution(* de.ids_mannheim.korap.interfaces.db.*.*(..))"/>
Michael Hanl72c7b832015-09-03 08:42:15 +0200202 <aop:advisor advice-ref="txAdvice" pointcut-ref="service"/>
203 </aop:config>
204
205 <!-- similarly, don't forget the PlatformTransactionManager -->
206 <bean id="txManager"
207 class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
208 <property name="dataSource" ref="dataSource"/>
Michael Hanlca740d72015-06-16 10:04:58 +0200209 </bean>
210</beans>