blob: 082d616835efdad0b55b13294a8c82a830aeef2e [file] [log] [blame]
Michael Hanlbd852b82015-11-18 22:17:00 +01001<?xml version="1.0" encoding="UTF-8"?>
2<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3 xmlns:p="http://www.springframework.org/schema/p"
4 xmlns:util="http://www.springframework.org/schema/util"
5 xmlns:aop="http://www.springframework.org/schema/aop"
6 xmlns:tx="http://www.springframework.org/schema/tx"
7 xmlns="http://www.springframework.org/schema/beans"
8 xmlns:cache="http://www.springframework.org/schema/cache"
9 xsi:schemaLocation="http://www.springframework.org/schema/beans
10 http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
11 http://www.springframework.org/schema/tx
12 http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
13
14
15 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
21 http://www.springframework.org/schema/util
22 http://www.springframework.org/schema/util/spring-util-4.0.xsd">
23
24 <cache:annotation-driven/>
25
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>
32 <value>file:./kustvakt.conf</value>
33 </array>
34 </property>
35 </bean>
36
37 <bean id="jdbc_props"
38 class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
39 <property name="ignoreResourceNotFound" value="true"/>
40 <property name="locations">
41 <array>
42 <value>classpath:jdbc.properties</value>
43 <value>file:./jdbc.properties</value>
44 </array>
45 </property>
46 </bean>
47
48 <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 -->
58 <bean id="kustvakt_config"
59 class="de.ids_mannheim.korap.config.KustvaktConfiguration">
60 <property name="properties" ref="props"/>
61 </bean>
62
63 <!--class="org.apache.commons.dbcp2.BasicDataSource"-->
64 <!-- org.springframework.jdbc.datasource.SingleConnectionDataSource -->
65 <bean id="dataSource"
66 class="org.springframework.jdbc.datasource.SingleConnectionDataSource"
67 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 <property name="suppressClose">
73 <value>true</value>
74 </property>
75 </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"
86 class="de.ids_mannheim.korap.handlers.JDBCClient">
87 <constructor-arg index="0" ref="dataSource"/>
88 <!-- deprecated property -->
89 <property name="database" value="${jdbc.database}"/>
90 </bean>
91
92 <bean id="kustvakt_auditing"
93 class="de.ids_mannheim.korap.handlers.JDBCAuditing">
94 <constructor-arg ref="kustvakt_db"/>
95 </bean>
96
97 <bean id="kustvakt_userdb"
98 class="de.ids_mannheim.korap.handlers.EntityDao">
99 <constructor-arg ref="kustvakt_db"/>
100 </bean>
101
Michael Hanl19390652016-01-16 11:01:24 +0100102 <!-- deprecated : load via constructor -->
Michael Hanlbd852b82015-11-18 22:17:00 +0100103 <!--fixme: change name according to convention -->
104 <bean id="collectionProvider"
105 class="de.ids_mannheim.korap.handlers.CollectionDao">
106 <constructor-arg ref="kustvakt_db"/>
107 </bean>
108
109 <!--fixme: change name according to convention -->
110 <bean id="resourceProvider"
111 class="de.ids_mannheim.korap.handlers.ResourceDao">
112 <constructor-arg ref="kustvakt_db"/>
113 </bean>
114
115 <bean id="kustvakt_policies"
116 class="de.ids_mannheim.korap.security.ac.PolicyDao">
117 <constructor-arg ref="kustvakt_db"/>
118 </bean>
119
120 <bean name="kustvakt_encryption"
121 class="de.ids_mannheim.korap.interfaces.defaults.KustvaktEncryption">
122 <constructor-arg ref="kustvakt_config"/>
123 </bean>
124
125 <!-- authentication providers to use -->
126 <bean id="api_auth"
127 class="de.ids_mannheim.korap.security.auth.APIAuthentication">
128 <constructor-arg
129 type="de.ids_mannheim.korap.config.KustvaktConfiguration"
130 ref="kustvakt_config"/>
131 </bean>
132
133 <bean id="openid_auth"
134 class="de.ids_mannheim.korap.security.auth.OpenIDconnectAuthentication">
135 <constructor-arg
136 type="de.ids_mannheim.korap.config.KustvaktConfiguration"
137 ref="kustvakt_config"/>
138 <constructor-arg
139 type="de.ids_mannheim.korap.interfaces.db.PersistenceClient"
140 ref="kustvakt_db"/>
141 </bean>
142
143 <bean id="basic_auth"
144 class="de.ids_mannheim.korap.security.auth.BasicHttpAuth"/>
145
146
147 <bean id="session_auth"
148 class="de.ids_mannheim.korap.security.auth.SessionAuthentication">
149 <constructor-arg
150 type="de.ids_mannheim.korap.config.KustvaktConfiguration"
151 ref="kustvakt_config"/>
152 <constructor-arg
153 type="de.ids_mannheim.korap.interfaces.EncryptionIface"
154 ref="kustvakt_encryption"/>
155 </bean>
156
157 <util:list id="auth_providers"
158 value-type="de.ids_mannheim.korap.interfaces.AuthenticationIface">
159 <ref bean="basic_auth"/>
160 <ref bean="session_auth"/>
161 <ref bean="api_auth"/>
162 <ref bean="openid_auth"/>
163 </util:list>
164
165 <!-- specify type for constructor argument -->
166 <bean id="kustvakt_authenticationmanager"
167 class="de.ids_mannheim.korap.security.auth.KustvaktAuthenticationManager">
168 <constructor-arg
169 type="de.ids_mannheim.korap.interfaces.db.EntityHandlerIface"
170 ref="kustvakt_userdb"/>
171 <constructor-arg type="de.ids_mannheim.korap.interfaces.EncryptionIface"
172 ref="kustvakt_encryption"/>
173 <constructor-arg ref="kustvakt_config"/>
174 <constructor-arg
175 type="de.ids_mannheim.korap.interfaces.db.AuditingIface"
176 ref="kustvakt_auditing"/>
177 <!-- inject authentication providers to use -->
178 <property name="providers" ref="auth_providers"/>
179 </bean>
180
181 <!-- todo: if db interfaces not loaded via spring, does transaction even work then? -->
182 <!-- the transactional advice (i.e. what 'happens'; see the <aop:advisor/> bean below) -->
183 <tx:advice id="txAdvice" transaction-manager="txManager">
184 <!-- the transactional semantics... -->
185 <tx:attributes>
186 <!-- all methods starting with 'get' are read-only -->
187 <tx:method name="get*" read-only="true"
188 rollback-for="KorAPException"/>
189 <!-- other methods use the default transaction settings (see below) -->
190 <tx:method name="*" rollback-for="KorAPException"/>
191 </tx:attributes>
192 </tx:advice>
193
194 <!-- ensure that the above transactional advice runs for any execution
195 of an operation defined by the service interface -->
196 <aop:config>
197 <aop:pointcut id="service"
198 expression="execution(* de.ids_mannheim.korap.interfaces.db.*.*(..))"/>
199 <aop:advisor advice-ref="txAdvice" pointcut-ref="service"/>
200 </aop:config>
201
202 <!-- similarly, don't forget the PlatformTransactionManager -->
203 <bean id="txManager"
204 class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
205 <property name="dataSource" ref="dataSource"/>
206 </bean>
207</beans>