blob: 4117b76618871042e9e46d359613fbb435bf7e79 [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 Hanl72c7b832015-09-03 08:42:15 +020064 <bean id="dataSource"
Michael Hanlf0785322015-11-13 16:14:45 +010065 class="org.springframework.jdbc.datasource.SingleConnectionDataSource"
Michael Hanl72c7b832015-09-03 08:42:15 +020066 lazy-init="true">
67 <property name="driverClassName" value="${jdbc.driverClassName}"/>
68 <property name="url" value="${jdbc.url}"/>
69 <property name="username" value="${jdbc.username}"/>
70 <property name="password" value="${jdbc.password}"/>
71 <!-- relevant for single connection datasource and sqlite -->
Michael Hanlf0785322015-11-13 16:14:45 +010072 <property name="suppressClose">
73 <value>true</value>
74 </property>
75 <!--<property name="initialSize" value="1"/>-->
76 <!--<property name="maxIdle" value="1"/>-->
77 <!--<property name="poolPreparedStatements" value="true"/>-->
Michael Hanl72c7b832015-09-03 08:42:15 +020078 </bean>
79
80 <!-- to configure database for sqlite, mysql, etc. migrations -->
81 <bean id="flyway" class="org.flywaydb.core.Flyway" init-method="migrate">
82 <property name="baselineOnMigrate" value="false"/>
83 <property name="locations"
84 value="classpath:${jdbc.schemaPath}"/>
85 <property name="dataSource" ref="dataSource"/>
86 </bean>
87
88 <bean id="kustvakt_db"
Michael Hanl482f30d2015-09-25 12:39:46 +020089 class="de.ids_mannheim.korap.handlers.JDBCClient">
Michael Hanl72c7b832015-09-03 08:42:15 +020090 <constructor-arg index="0" ref="dataSource"/>
91 <!-- deprecated property -->
92 <property name="database" value="${jdbc.database}"/>
93 </bean>
94
95 <bean id="kustvakt_auditing"
Michael Hanl482f30d2015-09-25 12:39:46 +020096 class="de.ids_mannheim.korap.handlers.JDBCAuditing">
Michael Hanl72c7b832015-09-03 08:42:15 +020097 <constructor-arg ref="kustvakt_db"/>
98 </bean>
99
100 <bean id="kustvakt_userdb"
Michael Hanl482f30d2015-09-25 12:39:46 +0200101 class="de.ids_mannheim.korap.handlers.EntityDao">
Michael Hanl72c7b832015-09-03 08:42:15 +0200102 <constructor-arg ref="kustvakt_db"/>
103 </bean>
104
Michael Hanl482f30d2015-09-25 12:39:46 +0200105 <!--fixme: change name according to convention -->
Michael Hanl72c7b832015-09-03 08:42:15 +0200106 <bean id="collectionProvider"
Michael Hanl482f30d2015-09-25 12:39:46 +0200107 class="de.ids_mannheim.korap.handlers.CollectionDao">
Michael Hanl72c7b832015-09-03 08:42:15 +0200108 <constructor-arg ref="kustvakt_db"/>
109 </bean>
110
Michael Hanl482f30d2015-09-25 12:39:46 +0200111 <!--fixme: change name according to convention -->
Michael Hanl72c7b832015-09-03 08:42:15 +0200112 <bean id="resourceProvider"
Michael Hanl482f30d2015-09-25 12:39:46 +0200113 class="de.ids_mannheim.korap.handlers.ResourceDao">
Michael Hanl72c7b832015-09-03 08:42:15 +0200114 <constructor-arg ref="kustvakt_db"/>
115 </bean>
116
117 <bean id="kustvakt_policies"
Michael Hanlf21773f2015-10-16 23:02:31 +0200118 class="de.ids_mannheim.korap.security.ac.PolicyDao">
Michael Hanl72c7b832015-09-03 08:42:15 +0200119 <constructor-arg ref="kustvakt_db"/>
120 </bean>
121
Michael Hanl1e18cb42015-08-06 20:57:35 +0200122 <bean name="kustvakt_encryption"
Michael Hanlf21773f2015-10-16 23:02:31 +0200123 class="de.ids_mannheim.korap.interfaces.defaults.KustvaktEncryption">
Michael Hanl72c7b832015-09-03 08:42:15 +0200124 <constructor-arg ref="kustvakt_config"/>
125 </bean>
126
Michael Hanl72c7b832015-09-03 08:42:15 +0200127 <!-- authentication providers to use -->
Michael Hanl72c7b832015-09-03 08:42:15 +0200128 <bean id="api_auth"
Michael Hanlf21773f2015-10-16 23:02:31 +0200129 class="de.ids_mannheim.korap.security.auth.APIAuthentication">
Michael Hanl72c7b832015-09-03 08:42:15 +0200130 <constructor-arg
131 type="de.ids_mannheim.korap.config.KustvaktConfiguration"
132 ref="kustvakt_config"/>
133 </bean>
134
135 <bean id="openid_auth"
Michael Hanlf21773f2015-10-16 23:02:31 +0200136 class="de.ids_mannheim.korap.security.auth.OpenIDconnectAuthentication">
Michael Hanl72c7b832015-09-03 08:42:15 +0200137 <constructor-arg
138 type="de.ids_mannheim.korap.config.KustvaktConfiguration"
139 ref="kustvakt_config"/>
140 <constructor-arg
Michael Hanlf21773f2015-10-16 23:02:31 +0200141 type="de.ids_mannheim.korap.interfaces.db.PersistenceClient"
Michael Hanl72c7b832015-09-03 08:42:15 +0200142 ref="kustvakt_db"/>
143 </bean>
144
145 <bean id="basic_auth"
Michael Hanlf21773f2015-10-16 23:02:31 +0200146 class="de.ids_mannheim.korap.security.auth.BasicHttpAuth"/>
Michael Hanl72c7b832015-09-03 08:42:15 +0200147
148
149 <bean id="session_auth"
Michael Hanlf21773f2015-10-16 23:02:31 +0200150 class="de.ids_mannheim.korap.security.auth.SessionAuthentication">
Michael Hanl72c7b832015-09-03 08:42:15 +0200151 <constructor-arg
152 type="de.ids_mannheim.korap.config.KustvaktConfiguration"
153 ref="kustvakt_config"/>
154 <constructor-arg
155 type="de.ids_mannheim.korap.interfaces.EncryptionIface"
156 ref="kustvakt_encryption"/>
157 </bean>
158
159 <util:list id="auth_providers"
160 value-type="de.ids_mannheim.korap.interfaces.AuthenticationIface">
161 <ref bean="basic_auth"/>
162 <ref bean="session_auth"/>
163 <ref bean="api_auth"/>
164 <ref bean="openid_auth"/>
165 </util:list>
166
167 <!-- specify type for constructor argument -->
168 <bean id="kustvakt_authenticationmanager"
Michael Hanlf21773f2015-10-16 23:02:31 +0200169 class="de.ids_mannheim.korap.security.auth.KustvaktAuthenticationManager">
Michael Hanl72c7b832015-09-03 08:42:15 +0200170 <constructor-arg
Michael Hanlf21773f2015-10-16 23:02:31 +0200171 type="de.ids_mannheim.korap.interfaces.db.EntityHandlerIface"
Michael Hanl72c7b832015-09-03 08:42:15 +0200172 ref="kustvakt_userdb"/>
173 <constructor-arg type="de.ids_mannheim.korap.interfaces.EncryptionIface"
174 ref="kustvakt_encryption"/>
175 <constructor-arg ref="kustvakt_config"/>
Michael Hanlf21773f2015-10-16 23:02:31 +0200176 <constructor-arg
177 type="de.ids_mannheim.korap.interfaces.db.AuditingIface"
178 ref="kustvakt_auditing"/>
Michael Hanl72c7b832015-09-03 08:42:15 +0200179 <!-- inject authentication providers to use -->
180 <property name="providers" ref="auth_providers"/>
181 </bean>
182
Michael Hanl72c7b832015-09-03 08:42:15 +0200183 <!-- todo: if db interfaces not loaded via spring, does transaction even work then? -->
184 <!-- the transactional advice (i.e. what 'happens'; see the <aop:advisor/> bean below) -->
185 <tx:advice id="txAdvice" transaction-manager="txManager">
186 <!-- the transactional semantics... -->
187 <tx:attributes>
188 <!-- all methods starting with 'get' are read-only -->
189 <tx:method name="get*" read-only="true"
190 rollback-for="KorAPException"/>
191 <!-- other methods use the default transaction settings (see below) -->
192 <tx:method name="*" rollback-for="KorAPException"/>
193 </tx:attributes>
194 </tx:advice>
195
196 <!-- ensure that the above transactional advice runs for any execution
197 of an operation defined by the service interface -->
198 <aop:config>
199 <aop:pointcut id="service"
Michael Hanlf21773f2015-10-16 23:02:31 +0200200 expression="execution(* de.ids_mannheim.korap.interfaces.db.*.*(..))"/>
Michael Hanl72c7b832015-09-03 08:42:15 +0200201 <aop:advisor advice-ref="txAdvice" pointcut-ref="service"/>
202 </aop:config>
203
204 <!-- similarly, don't forget the PlatformTransactionManager -->
205 <bean id="txManager"
206 class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
207 <property name="dataSource" ref="dataSource"/>
Michael Hanlca740d72015-06-16 10:04:58 +0200208 </bean>
209</beans>