blob: 57210771b35a5a723502979cf077c686daf85107 [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"
margaretha35e1ca22023-11-16 22:00:01 +01003 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:context="http://www.springframework.org/schema/context"
margarethaade7d4a2017-07-20 19:53:35 +02009 xmlns:cache="http://www.springframework.org/schema/cache"
margaretha62055f72017-04-11 19:17:43 +020010 xsi:schemaLocation="http://www.springframework.org/schema/beans
margaretha3da7cd32018-10-22 17:42:52 +020011 http://www.springframework.org/schema/beans/spring-beans.xsd
margarethaade7d4a2017-07-20 19:53:35 +020012 http://www.springframework.org/schema/tx
margaretha3da7cd32018-10-22 17:42:52 +020013 http://www.springframework.org/schema/tx/spring-tx.xsd
margarethaade7d4a2017-07-20 19:53:35 +020014 http://www.springframework.org/schema/aop
margaretha3da7cd32018-10-22 17:42:52 +020015 http://www.springframework.org/schema/aop/spring-aop.xsd
margarethaade7d4a2017-07-20 19:53:35 +020016 http://www.springframework.org/schema/context
margaretha3da7cd32018-10-22 17:42:52 +020017 http://www.springframework.org/schema/context/spring-context.xsd
margarethaade7d4a2017-07-20 19:53:35 +020018 http://www.springframework.org/schema/util
margaretha3da7cd32018-10-22 17:42:52 +020019 http://www.springframework.org/schema/util/spring-util.xsd">
Michael Hanlbd852b82015-11-18 22:17:00 +010020
margaretha35e1ca22023-11-16 22:00:01 +010021 <context:component-scan
22 base-package="de.ids_mannheim.korap" />
margarethaade7d4a2017-07-20 19:53:35 +020023 <context:annotation-config />
Michael Hanlbd852b82015-11-18 22:17:00 +010024
margaretha62055f72017-04-11 19:17:43 +020025 <bean id="props"
26 class="org.springframework.beans.factory.config.PropertiesFactoryBean">
27 <property name="ignoreResourceNotFound" value="true" />
28 <property name="locations">
29 <array>
margaretha0c47c652017-04-19 18:44:40 +020030 <value>classpath:kustvakt-test.conf</value>
31 <value>file:./kustvakt-test.conf</value>
margaretha62055f72017-04-11 19:17:43 +020032 </array>
33 </property>
34 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +010035
margarethaade7d4a2017-07-20 19:53:35 +020036 <bean id="placeholders"
37 class="org.springframework.context.support.PropertySourcesPlaceholderConfigurer">
margaretha62055f72017-04-11 19:17:43 +020038 <property name="ignoreResourceNotFound" value="true" />
39 <property name="locations">
40 <array>
margaretha6c2a20f2017-07-24 15:33:01 +020041 <value>classpath:test-jdbc.properties</value>
margaretha1f106f62017-10-18 22:27:30 +020042 <value>file:./test-jdbc.properties</value>
margarethaf6d5a822017-10-19 19:51:20 +020043 <value>classpath:test-hibernate.properties</value>
margaretha1960ea52023-02-28 11:20:15 +010044 <value>file:./kustvakt-test.conf</value>
margarethaf18298b2017-09-14 22:14:32 +020045 <value>classpath:kustvakt-test.conf</value>
margaretha62055f72017-04-11 19:17:43 +020046 </array>
47 </property>
48 </bean>
margarethaf6f6c3c2024-06-11 10:51:06 +020049
margarethaf6f6c3c2024-06-11 10:51:06 +020050 <bean id="kustvakt_config"
51 class="de.ids_mannheim.korap.config.FullConfiguration">
52 <constructor-arg name="properties" ref="props" />
53 </bean>
54
Michael Hanlbd852b82015-11-18 22:17:00 +010055
margaretha35e1ca22023-11-16 22:00:01 +010056 <bean id="dataSource"
57 class="org.apache.commons.dbcp2.BasicDataSource" lazy-init="true">
margaretha4edc70e2018-03-14 22:34:29 +010058 <!-- <property name="driverClassName" value="${jdbc.driverClassName}" /> -->
margaretha6c2a20f2017-07-24 15:33:01 +020059 <property name="url" value="${jdbc.url}" />
60 <property name="username" value="${jdbc.username}" />
61 <property name="password" value="${jdbc.password}" />
margaretha318fec32017-10-24 12:11:58 +020062 <property name="maxTotal" value="4" />
margaretha514e1412017-10-10 15:54:20 +020063 <property name="maxIdle" value="1" />
margaretha6c2a20f2017-07-24 15:33:01 +020064 <property name="minIdle" value="1" />
65 <property name="maxWaitMillis" value="15000" />
66 <!--<property name="poolPreparedStatements" value="true"/> -->
67 </bean>
68
margaretha35e1ca22023-11-16 22:00:01 +010069 <bean id="c3p0DataSource"
70 class="com.mchange.v2.c3p0.ComboPooledDataSource"
margaretha58e18632018-02-15 13:04:42 +010071 destroy-method="close">
72 <property name="driverClass" value="${jdbc.driverClassName}" />
margaretha514e1412017-10-10 15:54:20 +020073 <property name="jdbcUrl" value="${jdbc.url}" />
74 <property name="user" value="${jdbc.username}" />
75 <property name="password" value="${jdbc.password}" />
margaretha58e18632018-02-15 13:04:42 +010076 <property name="maxPoolSize" value="4" />
77 <property name="minPoolSize" value="1" />
78 <property name="maxStatements" value="1" />
79 <property name="testConnectionOnCheckout" value="true" />
margaretha62055f72017-04-11 19:17:43 +020080 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +010081
margaretha62055f72017-04-11 19:17:43 +020082 <!-- to configure database for sqlite, mysql, etc. migrations -->
margaretha35e1ca22023-11-16 22:00:01 +010083 <bean id="flywayConfig"
84 class="org.flywaydb.core.api.configuration.ClassicConfiguration">
margarethaf6d5a822017-10-19 19:51:20 +020085 <!-- drop existing tables and create new tables -->
86 <property name="validateOnMigrate" value="true" />
87 <property name="cleanOnValidationError" value="true" />
margaretha514e1412017-10-10 15:54:20 +020088 <property name="baselineOnMigrate" value="false" />
margaretha35e1ca22023-11-16 22:00:01 +010089 <property name="locations"
90 value="#{'${jdbc.schemaPath}'.split(',')}" />
margaretha8fe51e92023-09-20 11:22:20 +020091 <property name="dataSource" ref="dataSource" />
margarethad66a6832022-03-03 08:47:13 +010092 <property name="outOfOrder" value="true" />
margaretha62055f72017-04-11 19:17:43 +020093 </bean>
margaretha35e1ca22023-11-16 22:00:01 +010094
95 <bean id="flyway" class="org.flywaydb.core.Flyway"
96 init-method="migrate">
97 <constructor-arg ref="flywayConfig" />
margarethafcf8bd92021-01-14 10:55:53 +010098 </bean>
margaretha35e1ca22023-11-16 22:00:01 +010099
margarethaade7d4a2017-07-20 19:53:35 +0200100 <bean id="entityManagerFactory"
101 class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
margaretha8fe51e92023-09-20 11:22:20 +0200102 <property name="dataSource" ref="dataSource" />
margaretha3a966022024-06-13 13:51:50 +0200103
margarethaa452c5e2018-04-25 22:48:09 +0200104 <property name="packagesToScan">
105 <array>
margaretha5b708792023-05-12 16:55:29 +0200106 <value>de.ids_mannheim.korap.core.entity</value>
margarethaa452c5e2018-04-25 22:48:09 +0200107 <value>de.ids_mannheim.korap.entity</value>
108 <value>de.ids_mannheim.korap.oauth2.entity</value>
109 </array>
110 </property>
margarethaade7d4a2017-07-20 19:53:35 +0200111 <property name="jpaVendorAdapter">
112 <bean id="jpaVendorAdapter"
113 class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
margaretha35e1ca22023-11-16 22:00:01 +0100114 <property name="databasePlatform"
115 value="${hibernate.dialect}" />
margarethaade7d4a2017-07-20 19:53:35 +0200116 </bean>
117 </property>
118 <property name="jpaProperties">
119 <props>
120 <prop key="hibernate.dialect">${hibernate.dialect}</prop>
121 <prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop>
122 <prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
123 <prop key="hibernate.cache.use_query_cache">${hibernate.cache.use_query_cache}</prop>
124 <prop key="hibernate.cache.use_second_level_cache">${hibernate.cache.use_second_level_cache}
125 </prop>
126 <prop key="hibernate.cache.provider_class">${hibernate.cache.provider}</prop>
127 <prop key="hibernate.cache.region.factory_class">${hibernate.cache.region.factory}</prop>
margaretha6ad08b42018-08-22 18:33:54 +0200128 <prop key="hibernate.jdbc.time_zone">${hibernate.jdbc.time_zone}</prop>
margarethaade7d4a2017-07-20 19:53:35 +0200129 <!-- <prop key="net.sf.ehcache.configurationResourceName">classpath:ehcache.xml</prop> -->
130 </props>
131 </property>
margaretha62055f72017-04-11 19:17:43 +0200132 </bean>
Michael Hanle4fc7752016-02-17 11:41:18 +0100133
margarethaade7d4a2017-07-20 19:53:35 +0200134 <tx:annotation-driven proxy-target-class="true"
135 transaction-manager="transactionManager" />
margaretha35e1ca22023-11-16 22:00:01 +0100136 <bean id="transactionManager"
137 class="org.springframework.orm.jpa.JpaTransactionManager">
138 <property name="entityManagerFactory"
139 ref="entityManagerFactory" />
margaretha62055f72017-04-11 19:17:43 +0200140 </bean>
Michael Hanle4fc7752016-02-17 11:41:18 +0100141
margarethaade7d4a2017-07-20 19:53:35 +0200142 <bean id="transactionTemplate"
143 class="org.springframework.transaction.support.TransactionTemplate">
144 <constructor-arg ref="transactionManager" />
145 </bean>
146
147 <!-- Data access objects -->
margaretha34954472018-10-24 20:05:17 +0200148 <bean id="adminDao" class="de.ids_mannheim.korap.dao.AdminDaoImpl" />
margaretha35e1ca22023-11-16 22:00:01 +0100149 <bean id="resourceDao"
150 class="de.ids_mannheim.korap.dao.ResourceDao" />
151 <bean id="accessScopeDao"
152 class="de.ids_mannheim.korap.oauth2.dao.AccessScopeDao" />
153 <bean id="authorizationDao"
154 class="de.ids_mannheim.korap.oauth2.dao.CachedAuthorizationDaoImpl" />
155
margaretha34954472018-10-24 20:05:17 +0200156 <!-- Services -->
margaretha35e1ca22023-11-16 22:00:01 +0100157 <bean id="scopeService"
158 class="de.ids_mannheim.korap.oauth2.service.OAuth2ScopeServiceImpl" />
159
margaretha35e1ca22023-11-16 22:00:01 +0100160 <bean id="initializator"
161 class="de.ids_mannheim.korap.init.Initializator"
margaretha1b320452018-08-02 16:56:25 +0200162 init-method="initTest">
margarethab4ce6602018-04-26 20:23:57 +0200163 </bean>
164
margaretha6c2a20f2017-07-24 15:33:01 +0200165 <!-- Krill -->
margaretha35e1ca22023-11-16 22:00:01 +0100166 <bean id="search_krill"
167 class="de.ids_mannheim.korap.web.SearchKrill">
margaretha58e18632018-02-15 13:04:42 +0100168 <constructor-arg value="${krill.indexDir}" />
margaretha6c2a20f2017-07-24 15:33:01 +0200169 </bean>
170
margaretha6cd27f32019-01-24 14:47:47 +0100171 <!-- Validator -->
margaretha35e1ca22023-11-16 22:00:01 +0100172 <bean id="validator"
173 class="de.ids_mannheim.korap.validator.ApacheValidator" />
174
margaretha31a9f522018-04-03 20:40:45 +0200175 <!-- URLValidator -->
margaretha35e1ca22023-11-16 22:00:01 +0100176 <bean id="redirectURIValidator"
177 class="org.apache.commons.validator.routines.UrlValidator">
margarethae4034a82018-07-02 14:46:59 +0200178 <constructor-arg value="http,https" index="0" />
margaretha35e1ca22023-11-16 22:00:01 +0100179 <constructor-arg index="1" type="long"
180 value="#{T(org.apache.commons.validator.routines.UrlValidator).ALLOW_LOCAL_URLS +
181 T(org.apache.commons.validator.routines.UrlValidator).NO_FRAGMENTS}" />
margaretha31a9f522018-04-03 20:40:45 +0200182 </bean>
margaretha35e1ca22023-11-16 22:00:01 +0100183 <bean id="urlValidator"
184 class="org.apache.commons.validator.routines.UrlValidator">
margarethad7cab212018-07-02 19:01:43 +0200185 <constructor-arg value="http,https" />
186 </bean>
margaretha56e8e552017-12-05 16:31:21 +0100187
margaretha4fa4b062019-01-28 19:43:30 +0100188 <!-- Rewrite -->
margaretha35e1ca22023-11-16 22:00:01 +0100189 <bean id="foundryRewrite"
190 class="de.ids_mannheim.korap.rewrite.FoundryRewrite" />
191 <bean id="collectionRewrite"
192 class="de.ids_mannheim.korap.rewrite.CollectionRewrite" />
margaretha35e1ca22023-11-16 22:00:01 +0100193 <bean id="virtualCorpusRewrite"
194 class="de.ids_mannheim.korap.rewrite.VirtualCorpusRewrite" />
margaretha35e1ca22023-11-16 22:00:01 +0100195 <bean id="queryReferenceRewrite"
196 class="de.ids_mannheim.korap.rewrite.QueryReferenceRewrite" />
197
margaretha4fa4b062019-01-28 19:43:30 +0100198 <util:list id="rewriteTasks"
199 value-type="de.ids_mannheim.korap.rewrite.RewriteTask">
margaretha4fa4b062019-01-28 19:43:30 +0100200 <ref bean="foundryRewrite" />
201 <ref bean="collectionRewrite" />
202 <ref bean="virtualCorpusRewrite" />
Akronbee031a2020-10-29 16:58:14 +0100203 <ref bean="queryReferenceRewrite" />
margaretha4fa4b062019-01-28 19:43:30 +0100204 </util:list>
margaretha35e1ca22023-11-16 22:00:01 +0100205
206 <bean id="rewriteHandler"
207 class="de.ids_mannheim.korap.rewrite.RewriteHandler">
208 <constructor-arg ref="rewriteTasks" />
margaretha56e8e552017-12-05 16:31:21 +0100209 </bean>
210
margaretha35e1ca22023-11-16 22:00:01 +0100211 <bean id="kustvaktResponseHandler"
212 class="de.ids_mannheim.korap.web.KustvaktResponseHandler">
margaretha05122312018-04-16 15:01:34 +0200213 </bean>
margarethafb027f92018-04-23 20:00:13 +0200214
215 <!-- OAuth -->
margaretha35e1ca22023-11-16 22:00:01 +0100216 <bean id="oauth2ResponseHandler"
217 class="de.ids_mannheim.korap.web.OAuth2ResponseHandler">
margaretha58e18632018-02-15 13:04:42 +0100218 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +0100219
margaretha35e1ca22023-11-16 22:00:01 +0100220 <bean name="kustvakt_encryption"
221 class="de.ids_mannheim.korap.encryption.KustvaktEncryption">
margaretha62055f72017-04-11 19:17:43 +0200222 <constructor-arg ref="kustvakt_config" />
223 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +0100224
margaretha62055f72017-04-11 19:17:43 +0200225 <!-- authentication providers to use -->
margaretha58e18632018-02-15 13:04:42 +0100226 <bean id="basic_auth"
227 class="de.ids_mannheim.korap.authentication.BasicAuthentication" />
Michael Hanlbd852b82015-11-18 22:17:00 +0100228
229
margaretha62055f72017-04-11 19:17:43 +0200230 <bean id="session_auth"
margaretha139d0f72017-11-14 18:56:22 +0100231 class="de.ids_mannheim.korap.authentication.SessionAuthentication">
margaretha35e1ca22023-11-16 22:00:01 +0100232 <constructor-arg
233 type="de.ids_mannheim.korap.config.KustvaktConfiguration"
margaretha62055f72017-04-11 19:17:43 +0200234 ref="kustvakt_config" />
margaretha35e1ca22023-11-16 22:00:01 +0100235 <constructor-arg
236 type="de.ids_mannheim.korap.interfaces.EncryptionIface"
margaretha62055f72017-04-11 19:17:43 +0200237 ref="kustvakt_encryption" />
238 </bean>
margarethae4034a82018-07-02 14:46:59 +0200239
margarethacf306d32018-05-30 19:45:35 +0200240 <bean id="oauth2_auth"
241 class="de.ids_mannheim.korap.authentication.OAuth2Authentication" />
margarethae4034a82018-07-02 14:46:59 +0200242
Michael Hanlbd852b82015-11-18 22:17:00 +0100243
margaretha62055f72017-04-11 19:17:43 +0200244 <util:list id="kustvakt_authproviders"
245 value-type="de.ids_mannheim.korap.interfaces.AuthenticationIface">
246 <ref bean="basic_auth" />
247 <ref bean="session_auth" />
margarethacf306d32018-05-30 19:45:35 +0200248 <ref bean="oauth2_auth" />
margaretha62055f72017-04-11 19:17:43 +0200249 </util:list>
Michael Hanlbd852b82015-11-18 22:17:00 +0100250
margaretha62055f72017-04-11 19:17:43 +0200251 <!-- specify type for constructor argument -->
margaretha34954472018-10-24 20:05:17 +0200252 <bean id="authenticationManager"
margaretha139d0f72017-11-14 18:56:22 +0100253 class="de.ids_mannheim.korap.authentication.KustvaktAuthenticationManager">
margaretha35e1ca22023-11-16 22:00:01 +0100254 <constructor-arg
255 type="de.ids_mannheim.korap.interfaces.EncryptionIface"
margaretha62055f72017-04-11 19:17:43 +0200256 ref="kustvakt_encryption" />
257 <constructor-arg ref="kustvakt_config" />
margaretha62055f72017-04-11 19:17:43 +0200258 <!-- inject authentication providers to use -->
259 <property name="providers" ref="kustvakt_authproviders" />
260 </bean>
Michael Hanlbd852b82015-11-18 22:17:00 +0100261
margaretha62055f72017-04-11 19:17:43 +0200262 <!-- todo: if db interfaces not loaded via spring, does transaction even
263 work then? -->
264 <!-- the transactional advice (i.e. what 'happens'; see the <aop:advisor/>
265 bean below) -->
266 <tx:advice id="txAdvice" transaction-manager="txManager">
267 <!-- the transactional semantics... -->
268 <tx:attributes>
269 <!-- all methods starting with 'get' are read-only -->
margaretha35e1ca22023-11-16 22:00:01 +0100270 <tx:method name="get*" read-only="true"
271 rollback-for="KorAPException" />
margaretha62055f72017-04-11 19:17:43 +0200272 <!-- other methods use the default transaction settings (see below) -->
273 <tx:method name="*" rollback-for="KorAPException" />
274 </tx:attributes>
275 </tx:advice>
Michael Hanlbd852b82015-11-18 22:17:00 +0100276
margaretha62055f72017-04-11 19:17:43 +0200277 <!-- ensure that the above transactional advice runs for any execution of
278 an operation defined by the service interface -->
279 <aop:config>
280 <aop:pointcut id="service"
281 expression="execution(* de.ids_mannheim.korap.interfaces.db.*.*(..))" />
282 <aop:advisor advice-ref="txAdvice" pointcut-ref="service" />
283 </aop:config>
Michael Hanlbd852b82015-11-18 22:17:00 +0100284
margaretha62055f72017-04-11 19:17:43 +0200285 <!-- similarly, don't forget the PlatformTransactionManager -->
286 <bean id="txManager"
287 class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
288 <property name="dataSource" ref="dataSource" />
289 </bean>
Akronbee031a2020-10-29 16:58:14 +0100290</beans>