blob: 7d21bdde7fcac6248e407560b78755f5d7efe10d [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>
32 <value>file:./config/kustvakt.conf</value>
33 </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>
43 <value>file:./config/jdbc.properties</value>
44 </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 Hanl72c7b832015-09-03 08:42:15 +020063 <bean id="dataSource"
Michael Hanlf21773f2015-10-16 23:02:31 +020064 class="org.apache.commons.dbcp2.BasicDataSource"
Michael Hanl72c7b832015-09-03 08:42:15 +020065 lazy-init="true">
66 <property name="driverClassName" value="${jdbc.driverClassName}"/>
67 <property name="url" value="${jdbc.url}"/>
68 <property name="username" value="${jdbc.username}"/>
69 <property name="password" value="${jdbc.password}"/>
70 <!-- relevant for single connection datasource and sqlite -->
Michael Hanlf21773f2015-10-16 23:02:31 +020071 <!--<property name="suppressClose">-->
Michael Hanld6eadd52015-11-11 18:30:33 +010072 <!--<value>true</value>-->
Michael Hanlf21773f2015-10-16 23:02:31 +020073 <!--</property>-->
74 <property name="initialSize" value="1"/>
75 <property name="maxIdle" value="1"/>
76 <property name="poolPreparedStatements" value="true"/>
Michael Hanl72c7b832015-09-03 08:42:15 +020077 </bean>
78
79 <!-- to configure database for sqlite, mysql, etc. migrations -->
80 <bean id="flyway" class="org.flywaydb.core.Flyway" init-method="migrate">
81 <property name="baselineOnMigrate" value="false"/>
82 <property name="locations"
83 value="classpath:${jdbc.schemaPath}"/>
84 <property name="dataSource" ref="dataSource"/>
85 </bean>
86
87 <bean id="kustvakt_db"
Michael Hanl482f30d2015-09-25 12:39:46 +020088 class="de.ids_mannheim.korap.handlers.JDBCClient">
Michael Hanl72c7b832015-09-03 08:42:15 +020089 <constructor-arg index="0" ref="dataSource"/>
90 <!-- deprecated property -->
91 <property name="database" value="${jdbc.database}"/>
92 </bean>
93
94 <bean id="kustvakt_auditing"
Michael Hanl482f30d2015-09-25 12:39:46 +020095 class="de.ids_mannheim.korap.handlers.JDBCAuditing">
Michael Hanl72c7b832015-09-03 08:42:15 +020096 <constructor-arg ref="kustvakt_db"/>
97 </bean>
98
99 <bean id="kustvakt_userdb"
Michael Hanl482f30d2015-09-25 12:39:46 +0200100 class="de.ids_mannheim.korap.handlers.EntityDao">
Michael Hanl72c7b832015-09-03 08:42:15 +0200101 <constructor-arg ref="kustvakt_db"/>
102 </bean>
103
Michael Hanl482f30d2015-09-25 12:39:46 +0200104 <!--fixme: change name according to convention -->
Michael Hanl72c7b832015-09-03 08:42:15 +0200105 <bean id="collectionProvider"
Michael Hanl482f30d2015-09-25 12:39:46 +0200106 class="de.ids_mannheim.korap.handlers.CollectionDao">
Michael Hanl72c7b832015-09-03 08:42:15 +0200107 <constructor-arg ref="kustvakt_db"/>
108 </bean>
109
Michael Hanl482f30d2015-09-25 12:39:46 +0200110 <!--fixme: change name according to convention -->
Michael Hanl72c7b832015-09-03 08:42:15 +0200111 <bean id="resourceProvider"
Michael Hanl482f30d2015-09-25 12:39:46 +0200112 class="de.ids_mannheim.korap.handlers.ResourceDao">
Michael Hanl72c7b832015-09-03 08:42:15 +0200113 <constructor-arg ref="kustvakt_db"/>
114 </bean>
115
116 <bean id="kustvakt_policies"
Michael Hanlf21773f2015-10-16 23:02:31 +0200117 class="de.ids_mannheim.korap.security.ac.PolicyDao">
Michael Hanl72c7b832015-09-03 08:42:15 +0200118 <constructor-arg ref="kustvakt_db"/>
119 </bean>
120
Michael Hanl1e18cb42015-08-06 20:57:35 +0200121 <bean name="kustvakt_encryption"
Michael Hanlf21773f2015-10-16 23:02:31 +0200122 class="de.ids_mannheim.korap.interfaces.defaults.KustvaktEncryption">
Michael Hanl72c7b832015-09-03 08:42:15 +0200123 <constructor-arg ref="kustvakt_config"/>
124 </bean>
125
Michael Hanl72c7b832015-09-03 08:42:15 +0200126 <!-- authentication providers to use -->
Michael Hanl72c7b832015-09-03 08:42:15 +0200127 <bean id="api_auth"
Michael Hanlf21773f2015-10-16 23:02:31 +0200128 class="de.ids_mannheim.korap.security.auth.APIAuthentication">
Michael Hanl72c7b832015-09-03 08:42:15 +0200129 <constructor-arg
130 type="de.ids_mannheim.korap.config.KustvaktConfiguration"
131 ref="kustvakt_config"/>
132 </bean>
133
134 <bean id="openid_auth"
Michael Hanlf21773f2015-10-16 23:02:31 +0200135 class="de.ids_mannheim.korap.security.auth.OpenIDconnectAuthentication">
Michael Hanl72c7b832015-09-03 08:42:15 +0200136 <constructor-arg
137 type="de.ids_mannheim.korap.config.KustvaktConfiguration"
138 ref="kustvakt_config"/>
139 <constructor-arg
Michael Hanlf21773f2015-10-16 23:02:31 +0200140 type="de.ids_mannheim.korap.interfaces.db.PersistenceClient"
Michael Hanl72c7b832015-09-03 08:42:15 +0200141 ref="kustvakt_db"/>
142 </bean>
143
144 <bean id="basic_auth"
Michael Hanlf21773f2015-10-16 23:02:31 +0200145 class="de.ids_mannheim.korap.security.auth.BasicHttpAuth"/>
Michael Hanl72c7b832015-09-03 08:42:15 +0200146
147
148 <bean id="session_auth"
Michael Hanlf21773f2015-10-16 23:02:31 +0200149 class="de.ids_mannheim.korap.security.auth.SessionAuthentication">
Michael Hanl72c7b832015-09-03 08:42:15 +0200150 <constructor-arg
151 type="de.ids_mannheim.korap.config.KustvaktConfiguration"
152 ref="kustvakt_config"/>
153 <constructor-arg
154 type="de.ids_mannheim.korap.interfaces.EncryptionIface"
155 ref="kustvakt_encryption"/>
156 </bean>
157
158 <util:list id="auth_providers"
159 value-type="de.ids_mannheim.korap.interfaces.AuthenticationIface">
160 <ref bean="basic_auth"/>
161 <ref bean="session_auth"/>
162 <ref bean="api_auth"/>
163 <ref bean="openid_auth"/>
164 </util:list>
165
166 <!-- specify type for constructor argument -->
167 <bean id="kustvakt_authenticationmanager"
Michael Hanlf21773f2015-10-16 23:02:31 +0200168 class="de.ids_mannheim.korap.security.auth.KustvaktAuthenticationManager">
Michael Hanl72c7b832015-09-03 08:42:15 +0200169 <constructor-arg
Michael Hanlf21773f2015-10-16 23:02:31 +0200170 type="de.ids_mannheim.korap.interfaces.db.EntityHandlerIface"
Michael Hanl72c7b832015-09-03 08:42:15 +0200171 ref="kustvakt_userdb"/>
172 <constructor-arg type="de.ids_mannheim.korap.interfaces.EncryptionIface"
173 ref="kustvakt_encryption"/>
174 <constructor-arg ref="kustvakt_config"/>
Michael Hanlf21773f2015-10-16 23:02:31 +0200175 <constructor-arg
176 type="de.ids_mannheim.korap.interfaces.db.AuditingIface"
177 ref="kustvakt_auditing"/>
Michael Hanl72c7b832015-09-03 08:42:15 +0200178 <!-- inject authentication providers to use -->
179 <property name="providers" ref="auth_providers"/>
180 </bean>
181
Michael Hanl72c7b832015-09-03 08:42:15 +0200182 <!-- todo: if db interfaces not loaded via spring, does transaction even work then? -->
183 <!-- the transactional advice (i.e. what 'happens'; see the <aop:advisor/> bean below) -->
184 <tx:advice id="txAdvice" transaction-manager="txManager">
185 <!-- the transactional semantics... -->
186 <tx:attributes>
187 <!-- all methods starting with 'get' are read-only -->
188 <tx:method name="get*" read-only="true"
189 rollback-for="KorAPException"/>
190 <!-- other methods use the default transaction settings (see below) -->
191 <tx:method name="*" rollback-for="KorAPException"/>
192 </tx:attributes>
193 </tx:advice>
194
195 <!-- ensure that the above transactional advice runs for any execution
196 of an operation defined by the service interface -->
197 <aop:config>
198 <aop:pointcut id="service"
Michael Hanlf21773f2015-10-16 23:02:31 +0200199 expression="execution(* de.ids_mannheim.korap.interfaces.db.*.*(..))"/>
Michael Hanl72c7b832015-09-03 08:42:15 +0200200 <aop:advisor advice-ref="txAdvice" pointcut-ref="service"/>
201 </aop:config>
202
203 <!-- similarly, don't forget the PlatformTransactionManager -->
204 <bean id="txManager"
205 class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
206 <property name="dataSource" ref="dataSource"/>
Michael Hanlca740d72015-06-16 10:04:58 +0200207 </bean>
208</beans>