blob: 2188edc979bc13fa896902f2e09ab17117e58044 [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
102 <!--fixme: change name according to convention -->
103 <bean id="collectionProvider"
104 class="de.ids_mannheim.korap.handlers.CollectionDao">
105 <constructor-arg ref="kustvakt_db"/>
106 </bean>
107
108 <!--fixme: change name according to convention -->
109 <bean id="resourceProvider"
110 class="de.ids_mannheim.korap.handlers.ResourceDao">
111 <constructor-arg ref="kustvakt_db"/>
112 </bean>
113
114 <bean id="kustvakt_policies"
115 class="de.ids_mannheim.korap.security.ac.PolicyDao">
116 <constructor-arg ref="kustvakt_db"/>
117 </bean>
118
119 <bean name="kustvakt_encryption"
120 class="de.ids_mannheim.korap.interfaces.defaults.KustvaktEncryption">
121 <constructor-arg ref="kustvakt_config"/>
122 </bean>
123
124 <!-- authentication providers to use -->
125 <bean id="api_auth"
126 class="de.ids_mannheim.korap.security.auth.APIAuthentication">
127 <constructor-arg
128 type="de.ids_mannheim.korap.config.KustvaktConfiguration"
129 ref="kustvakt_config"/>
130 </bean>
131
132 <bean id="openid_auth"
133 class="de.ids_mannheim.korap.security.auth.OpenIDconnectAuthentication">
134 <constructor-arg
135 type="de.ids_mannheim.korap.config.KustvaktConfiguration"
136 ref="kustvakt_config"/>
137 <constructor-arg
138 type="de.ids_mannheim.korap.interfaces.db.PersistenceClient"
139 ref="kustvakt_db"/>
140 </bean>
141
142 <bean id="basic_auth"
143 class="de.ids_mannheim.korap.security.auth.BasicHttpAuth"/>
144
145
146 <bean id="session_auth"
147 class="de.ids_mannheim.korap.security.auth.SessionAuthentication">
148 <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"
166 class="de.ids_mannheim.korap.security.auth.KustvaktAuthenticationManager">
167 <constructor-arg
168 type="de.ids_mannheim.korap.interfaces.db.EntityHandlerIface"
169 ref="kustvakt_userdb"/>
170 <constructor-arg type="de.ids_mannheim.korap.interfaces.EncryptionIface"
171 ref="kustvakt_encryption"/>
172 <constructor-arg ref="kustvakt_config"/>
173 <constructor-arg
174 type="de.ids_mannheim.korap.interfaces.db.AuditingIface"
175 ref="kustvakt_auditing"/>
176 <!-- inject authentication providers to use -->
177 <property name="providers" ref="auth_providers"/>
178 </bean>
179
180 <!-- 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"
197 expression="execution(* de.ids_mannheim.korap.interfaces.db.*.*(..))"/>
198 <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"/>
205 </bean>
206</beans>