blob: 89f4bb9257a2b5bb7cdab22cdaf941c7c673fe8d [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
13 http://www.springframework.org/schema/aop
14 http://www.springframework.org/schema/aop/spring-aop-4.0.xsd
15 http://www.springframework.org/schema/cache
16 http://www.springframework.org/schema/cache/spring-cache-4.0.xsd
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 Hanl7368aa42016-02-05 18:15:47 +010020 <!--<cache:annotation-driven/>-->
Michael Hanld6eadd52015-11-11 18:30:33 +010021
22 <bean id="props"
23 class="org.springframework.beans.factory.config.PropertiesFactoryBean">
24 <property name="ignoreResourceNotFound" value="true"/>
25 <property name="locations">
26 <array>
27 <value>classpath:kustvakt.conf</value>
Michael Hanl38399df2015-11-13 16:32:19 +010028 <value>file:./kustvakt.conf</value>
Michael Hanld6eadd52015-11-11 18:30:33 +010029 </array>
30 </property>
31 </bean>
Michael Hanlca740d72015-06-16 10:04:58 +020032
Michael Hanl72c7b832015-09-03 08:42:15 +020033 <bean id="jdbc_props"
34 class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
Michael Hanld6eadd52015-11-11 18:30:33 +010035 <property name="ignoreResourceNotFound" value="true"/>
36 <property name="locations">
37 <array>
38 <value>classpath:jdbc.properties</value>
Michael Hanl38399df2015-11-13 16:32:19 +010039 <value>file:./jdbc.properties</value>
Michael Hanld6eadd52015-11-11 18:30:33 +010040 </array>
41 </property>
Michael Hanlca740d72015-06-16 10:04:58 +020042 </bean>
43
Michael Hanl7368aa42016-02-05 18:15:47 +010044 <!--<bean id='cacheManager'-->
45 <!--class='org.springframework.cache.ehcache.EhCacheCacheManager'-->
46 <!--p:cacheManager-ref='ehcache'/>-->
Michael Hanl72c7b832015-09-03 08:42:15 +020047
Michael Hanl7368aa42016-02-05 18:15:47 +010048 <!--<bean id='ehcache'-->
49 <!--class='org.springframework.cache.ehcache.EhCacheManagerFactoryBean'-->
50 <!--p:configLocation='classpath:ehcache.xml'-->
51 <!--p:shared='true'/>-->
Michael Hanl72c7b832015-09-03 08:42:15 +020052
53 <!-- props are injected from default-config.xml -->
Michael Hanl1e18cb42015-08-06 20:57:35 +020054 <bean id="kustvakt_config"
Michael Hanlf21773f2015-10-16 23:02:31 +020055 class="de.ids_mannheim.korap.config.KustvaktConfiguration">
Michael Hanlca740d72015-06-16 10:04:58 +020056 <property name="properties" ref="props"/>
57 </bean>
58
Michael Hanlf0785322015-11-13 16:14:45 +010059 <!--class="org.apache.commons.dbcp2.BasicDataSource"-->
Michael Hanl2760cc42015-11-16 19:30:01 +010060 <!-- org.springframework.jdbc.datasource.SingleConnectionDataSource -->
Michael Hanl72c7b832015-09-03 08:42:15 +020061 <bean id="dataSource"
Michael Hanl19390652016-01-16 11:01:24 +010062 class="org.springframework.jdbc.datasource.SingleConnectionDataSource"
Michael Hanl72c7b832015-09-03 08:42:15 +020063 lazy-init="true">
64 <property name="driverClassName" value="${jdbc.driverClassName}"/>
65 <property name="url" value="${jdbc.url}"/>
66 <property name="username" value="${jdbc.username}"/>
67 <property name="password" value="${jdbc.password}"/>
68 <!-- relevant for single connection datasource and sqlite -->
Michael Hanl19390652016-01-16 11:01:24 +010069 <property name="suppressClose">
70 <value>true</value>
71 </property>
72 <!--<property name="initialSize" value="2"/>-->
73 <!--<property name="maxIdle" value="2"/>-->
74 <!--<property name="poolPreparedStatements" value="true"/>-->
Michael Hanl72c7b832015-09-03 08:42:15 +020075 </bean>
76
77 <!-- to configure database for sqlite, mysql, etc. migrations -->
78 <bean id="flyway" class="org.flywaydb.core.Flyway" init-method="migrate">
79 <property name="baselineOnMigrate" value="false"/>
80 <property name="locations"
81 value="classpath:${jdbc.schemaPath}"/>
82 <property name="dataSource" ref="dataSource"/>
83 </bean>
84
85 <bean id="kustvakt_db"
Michael Hanl482f30d2015-09-25 12:39:46 +020086 class="de.ids_mannheim.korap.handlers.JDBCClient">
Michael Hanl72c7b832015-09-03 08:42:15 +020087 <constructor-arg index="0" ref="dataSource"/>
88 <!-- deprecated property -->
89 <property name="database" value="${jdbc.database}"/>
90 </bean>
91
92 <bean id="kustvakt_auditing"
Michael Hanl482f30d2015-09-25 12:39:46 +020093 class="de.ids_mannheim.korap.handlers.JDBCAuditing">
Michael Hanl72c7b832015-09-03 08:42:15 +020094 <constructor-arg ref="kustvakt_db"/>
95 </bean>
96
97 <bean id="kustvakt_userdb"
Michael Hanl482f30d2015-09-25 12:39:46 +020098 class="de.ids_mannheim.korap.handlers.EntityDao">
Michael Hanl72c7b832015-09-03 08:42:15 +020099 <constructor-arg ref="kustvakt_db"/>
100 </bean>
101
Michael Hanl482f30d2015-09-25 12:39:46 +0200102 <!--fixme: change name according to convention -->
Michael Hanl9b84eff2016-01-27 17:11:11 +0100103 <!--<bean id="collectionProvider"-->
104 <!--class="de.ids_mannheim.korap.handlers.CollectionDao">-->
105 <!--<constructor-arg ref="kustvakt_db"/>-->
106 <!--</bean>-->
Michael Hanl72c7b832015-09-03 08:42:15 +0200107
Michael Hanl482f30d2015-09-25 12:39:46 +0200108 <!--fixme: change name according to convention -->
Michael Hanl72c7b832015-09-03 08:42:15 +0200109 <bean id="resourceProvider"
Michael Hanl482f30d2015-09-25 12:39:46 +0200110 class="de.ids_mannheim.korap.handlers.ResourceDao">
Michael Hanl72c7b832015-09-03 08:42:15 +0200111 <constructor-arg ref="kustvakt_db"/>
112 </bean>
113
114 <bean id="kustvakt_policies"
Michael Hanlf21773f2015-10-16 23:02:31 +0200115 class="de.ids_mannheim.korap.security.ac.PolicyDao">
Michael Hanl72c7b832015-09-03 08:42:15 +0200116 <constructor-arg ref="kustvakt_db"/>
117 </bean>
118
Michael Hanl1e18cb42015-08-06 20:57:35 +0200119 <bean name="kustvakt_encryption"
Michael Hanlf21773f2015-10-16 23:02:31 +0200120 class="de.ids_mannheim.korap.interfaces.defaults.KustvaktEncryption">
Michael Hanl72c7b832015-09-03 08:42:15 +0200121 <constructor-arg ref="kustvakt_config"/>
122 </bean>
123
Michael Hanl72c7b832015-09-03 08:42:15 +0200124 <!-- authentication providers to use -->
Michael Hanl72c7b832015-09-03 08:42:15 +0200125 <bean id="api_auth"
Michael Hanlf21773f2015-10-16 23:02:31 +0200126 class="de.ids_mannheim.korap.security.auth.APIAuthentication">
Michael Hanl72c7b832015-09-03 08:42:15 +0200127 <constructor-arg
128 type="de.ids_mannheim.korap.config.KustvaktConfiguration"
129 ref="kustvakt_config"/>
130 </bean>
131
132 <bean id="openid_auth"
Michael Hanlf21773f2015-10-16 23:02:31 +0200133 class="de.ids_mannheim.korap.security.auth.OpenIDconnectAuthentication">
Michael Hanl72c7b832015-09-03 08:42:15 +0200134 <constructor-arg
135 type="de.ids_mannheim.korap.config.KustvaktConfiguration"
136 ref="kustvakt_config"/>
137 <constructor-arg
Michael Hanlf21773f2015-10-16 23:02:31 +0200138 type="de.ids_mannheim.korap.interfaces.db.PersistenceClient"
Michael Hanl72c7b832015-09-03 08:42:15 +0200139 ref="kustvakt_db"/>
140 </bean>
141
142 <bean id="basic_auth"
Michael Hanlf21773f2015-10-16 23:02:31 +0200143 class="de.ids_mannheim.korap.security.auth.BasicHttpAuth"/>
Michael Hanl72c7b832015-09-03 08:42:15 +0200144
145
146 <bean id="session_auth"
Michael Hanlf21773f2015-10-16 23:02:31 +0200147 class="de.ids_mannheim.korap.security.auth.SessionAuthentication">
Michael Hanl72c7b832015-09-03 08:42:15 +0200148 <constructor-arg
149 type="de.ids_mannheim.korap.config.KustvaktConfiguration"
150 ref="kustvakt_config"/>
151 <constructor-arg
152 type="de.ids_mannheim.korap.interfaces.EncryptionIface"
153 ref="kustvakt_encryption"/>
154 </bean>
155
156 <util:list id="auth_providers"
157 value-type="de.ids_mannheim.korap.interfaces.AuthenticationIface">
158 <ref bean="basic_auth"/>
159 <ref bean="session_auth"/>
160 <ref bean="api_auth"/>
161 <ref bean="openid_auth"/>
162 </util:list>
163
164 <!-- specify type for constructor argument -->
165 <bean id="kustvakt_authenticationmanager"
Michael Hanlf21773f2015-10-16 23:02:31 +0200166 class="de.ids_mannheim.korap.security.auth.KustvaktAuthenticationManager">
Michael Hanl72c7b832015-09-03 08:42:15 +0200167 <constructor-arg
Michael Hanlf21773f2015-10-16 23:02:31 +0200168 type="de.ids_mannheim.korap.interfaces.db.EntityHandlerIface"
Michael Hanl72c7b832015-09-03 08:42:15 +0200169 ref="kustvakt_userdb"/>
170 <constructor-arg type="de.ids_mannheim.korap.interfaces.EncryptionIface"
171 ref="kustvakt_encryption"/>
172 <constructor-arg ref="kustvakt_config"/>
Michael Hanlf21773f2015-10-16 23:02:31 +0200173 <constructor-arg
174 type="de.ids_mannheim.korap.interfaces.db.AuditingIface"
175 ref="kustvakt_auditing"/>
Michael Hanl72c7b832015-09-03 08:42:15 +0200176 <!-- inject authentication providers to use -->
177 <property name="providers" ref="auth_providers"/>
178 </bean>
179
Michael Hanl72c7b832015-09-03 08:42:15 +0200180 <!-- todo: if db interfaces not loaded via spring, does transaction even work then? -->
181 <!-- the transactional advice (i.e. what 'happens'; see the <aop:advisor/> bean below) -->
182 <tx:advice id="txAdvice" transaction-manager="txManager">
183 <!-- the transactional semantics... -->
184 <tx:attributes>
185 <!-- all methods starting with 'get' are read-only -->
186 <tx:method name="get*" read-only="true"
187 rollback-for="KorAPException"/>
188 <!-- other methods use the default transaction settings (see below) -->
189 <tx:method name="*" rollback-for="KorAPException"/>
190 </tx:attributes>
191 </tx:advice>
192
193 <!-- ensure that the above transactional advice runs for any execution
194 of an operation defined by the service interface -->
195 <aop:config>
196 <aop:pointcut id="service"
Michael Hanlf21773f2015-10-16 23:02:31 +0200197 expression="execution(* de.ids_mannheim.korap.interfaces.db.*.*(..))"/>
Michael Hanl72c7b832015-09-03 08:42:15 +0200198 <aop:advisor advice-ref="txAdvice" pointcut-ref="service"/>
199 </aop:config>
200
201 <!-- similarly, don't forget the PlatformTransactionManager -->
202 <bean id="txManager"
203 class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
204 <property name="dataSource" ref="dataSource"/>
Michael Hanlca740d72015-06-16 10:04:58 +0200205 </bean>
206</beans>