blob: f76785f4afc4a014f357976632c9578b1b952612 [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"
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"
margaretha543f2002017-07-14 00:27:15 +02009 xmlns:cache="http://www.springframework.org/schema/cache"
10 xsi:schemaLocation="http://www.springframework.org/schema/beans
margaretha3da7cd32018-10-22 17:42:52 +020011 http://www.springframework.org/schema/beans/spring-beans.xsd
margaretha543f2002017-07-14 00:27:15 +020012 http://www.springframework.org/schema/tx
margaretha3da7cd32018-10-22 17:42:52 +020013 http://www.springframework.org/schema/tx/spring-tx.xsd
margaretha543f2002017-07-14 00:27:15 +020014 http://www.springframework.org/schema/aop
margaretha3da7cd32018-10-22 17:42:52 +020015 http://www.springframework.org/schema/aop/spring-aop.xsd
margaretha543f2002017-07-14 00:27:15 +020016 http://www.springframework.org/schema/context
margaretha3da7cd32018-10-22 17:42:52 +020017 http://www.springframework.org/schema/context/spring-context.xsd
margaretha543f2002017-07-14 00:27:15 +020018 http://www.springframework.org/schema/util
margaretha3da7cd32018-10-22 17:42:52 +020019 http://www.springframework.org/schema/util/spring-util.xsd">
margaretha543f2002017-07-14 00:27:15 +020020
margaretha35e1ca22023-11-16 22:00:01 +010021 <context:component-scan
22 base-package="de.ids_mannheim.korap" />
margaretha543f2002017-07-14 00:27:15 +020023 <context:annotation-config />
24
25 <bean id="props"
26 class="org.springframework.beans.factory.config.PropertiesFactoryBean">
27 <property name="ignoreResourceNotFound" value="true" />
28 <property name="locations">
29 <array>
30 <value>classpath:kustvakt.conf</value>
31 <value>file:./kustvakt.conf</value>
margarethad77ee712024-03-22 12:35:30 +010032 <value>file:./data/kustvakt.conf</value>
margaretha543f2002017-07-14 00:27:15 +020033 </array>
34 </property>
35 </bean>
36
37 <bean id="placeholders"
38 class="org.springframework.context.support.PropertySourcesPlaceholderConfigurer">
39 <property name="ignoreResourceNotFound" value="true" />
40 <property name="locations">
41 <array>
margarethaaecee1b2018-02-20 14:44:21 +010042 <value>classpath:properties/jdbc.properties</value>
margarethaea68a0a2017-09-21 03:09:49 +020043 <value>file:./jdbc.properties</value>
margarethad77ee712024-03-22 12:35:30 +010044 <value>file:./data/jdbc.properties</value>
margarethacc7feb62023-05-09 08:57:46 +020045 <value>classpath:properties/hibernate.properties</value>
margaretha0e8f4e72018-04-05 14:11:52 +020046
margarethaade7d4a2017-07-20 19:53:35 +020047 <value>classpath:kustvakt.conf</value>
margaretha14503cd2017-09-08 15:35:24 +020048 <value>file:./kustvakt.conf</value>
margarethad77ee712024-03-22 12:35:30 +010049 <value>file:./data/kustvakt.conf</value>
margaretha543f2002017-07-14 00:27:15 +020050 </array>
51 </property>
52 </bean>
53
margaretha35e1ca22023-11-16 22:00:01 +010054 <bean id="dataSource"
55 class="org.apache.commons.dbcp2.BasicDataSource" lazy-init="true">
56 <property name="driverClassName"
57 value="${jdbc.driverClassName}" />
margaretha543f2002017-07-14 00:27:15 +020058 <property name="url" value="${jdbc.url}" />
59 <property name="username" value="${jdbc.username}" />
60 <property name="password" value="${jdbc.password}" />
margaretha543f2002017-07-14 00:27:15 +020061 <property name="maxTotal" value="4" />
62 <property name="maxIdle" value="2" />
63 <property name="minIdle" value="1" />
margaretha45211af2018-08-28 12:49:07 +020064 <property name="maxWaitMillis" value="-1" />
margaretha543f2002017-07-14 00:27:15 +020065 <!--<property name="poolPreparedStatements" value="true"/> -->
66 </bean>
margaretha35e1ca22023-11-16 22:00:01 +010067
68 <bean id="c3p0DataSource"
69 class="com.mchange.v2.c3p0.ComboPooledDataSource"
margaretha45211af2018-08-28 12:49:07 +020070 destroy-method="close" lazy-init="true">
71 <property name="driverClass" value="${jdbc.driverClassName}" />
72 <property name="jdbcUrl" value="${jdbc.url}" />
73 <property name="user" value="${jdbc.username}" />
74 <property name="password" value="${jdbc.password}" />
75 <property name="maxPoolSize" value="4" />
76 <property name="minPoolSize" value="1" />
77 <property name="maxStatements" value="100" />
78 <!-- <property name="testConnectionOnCheckOut" value="true" /> -->
79 <property name="idleConnectionTestPeriod" value="60" />
80 <property name="testConnectionOnCheckin" value="true" />
81 </bean>
margaretha543f2002017-07-14 00:27:15 +020082
margaretha543f2002017-07-14 00:27:15 +020083 <!-- to configure database for sqlite, mysql, etc. migrations -->
margaretha35e1ca22023-11-16 22:00:01 +010084 <bean id="flywayConfig"
85 class="org.flywaydb.core.api.configuration.ClassicConfiguration">
margarethaf6d5a822017-10-19 19:51:20 +020086 <property name="baselineOnMigrate" value="true" />
margarethaecbe72d2017-07-26 17:13:32 +020087 <!-- <property name="validateOnMigrate" value="false" /> -->
88 <!-- <property name="cleanOnValidationError" value="true" /> -->
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" />
margaretha8514d782018-08-28 17:36:56 +020092 <!-- <property name="dataSource" ref="c3p0DataSource" /> -->
margarethad66a6832022-03-03 08:47:13 +010093 <property name="outOfOrder" value="true" />
margaretha543f2002017-07-14 00:27:15 +020094 </bean>
margaretha35e1ca22023-11-16 22:00:01 +010095
96 <bean id="flyway" class="org.flywaydb.core.Flyway"
97 init-method="migrate">
98 <constructor-arg ref="flywayConfig" />
margarethafcf8bd92021-01-14 10:55:53 +010099 </bean>
margaretha0e8f4e72018-04-05 14:11:52 +0200100
margaretha543f2002017-07-14 00:27:15 +0200101 <bean id="entityManagerFactory"
margarethafcf8bd92021-01-14 10:55:53 +0100102 class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
103 depends-on="flyway">
margaretha8fe51e92023-09-20 11:22:20 +0200104 <property name="dataSource" ref="dataSource" />
margaretha8514d782018-08-28 17:36:56 +0200105 <!-- <property name="dataSource" ref="c3p0DataSource" /> -->
margaretha0e8f4e72018-04-05 14:11:52 +0200106
margarethaa452c5e2018-04-25 22:48:09 +0200107 <property name="packagesToScan">
108 <array>
margaretha5b708792023-05-12 16:55:29 +0200109 <value>de.ids_mannheim.korap.core.entity</value>
margarethaa452c5e2018-04-25 22:48:09 +0200110 <value>de.ids_mannheim.korap.entity</value>
111 <value>de.ids_mannheim.korap.oauth2.entity</value>
112 </array>
113 </property>
margaretha543f2002017-07-14 00:27:15 +0200114 <property name="jpaVendorAdapter">
115 <bean id="jpaVendorAdapter"
116 class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
margaretha35e1ca22023-11-16 22:00:01 +0100117 <property name="databasePlatform"
118 value="${hibernate.dialect}" />
margaretha543f2002017-07-14 00:27:15 +0200119 </bean>
120 </property>
121 <property name="jpaProperties">
122 <props>
123 <prop key="hibernate.dialect">${hibernate.dialect}</prop>
124 <prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop>
125 <prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
126 <prop key="hibernate.cache.use_query_cache">${hibernate.cache.use_query_cache}</prop>
127 <prop key="hibernate.cache.use_second_level_cache">${hibernate.cache.use_second_level_cache}
128 </prop>
129 <prop key="hibernate.cache.provider_class">${hibernate.cache.provider}</prop>
130 <prop key="hibernate.cache.region.factory_class">${hibernate.cache.region.factory}</prop>
margaretha6ad08b42018-08-22 18:33:54 +0200131 <prop key="hibernate.jdbc.time_zone">${hibernate.jdbc.time_zone}</prop>
margaretha543f2002017-07-14 00:27:15 +0200132 </props>
133 </property>
134 </bean>
135
136 <tx:annotation-driven proxy-target-class="true"
137 transaction-manager="transactionManager" />
margaretha0e8f4e72018-04-05 14:11:52 +0200138
margaretha35e1ca22023-11-16 22:00:01 +0100139 <bean id="transactionManager"
140 class="org.springframework.orm.jpa.JpaTransactionManager">
141 <property name="entityManagerFactory"
142 ref="entityManagerFactory" />
margaretha543f2002017-07-14 00:27:15 +0200143 </bean>
144
145 <bean id="transactionTemplate"
146 class="org.springframework.transaction.support.TransactionTemplate">
147 <constructor-arg ref="transactionManager" />
148 </bean>
149
margarethaade7d4a2017-07-20 19:53:35 +0200150 <!-- Data access objects -->
margaretha34954472018-10-24 20:05:17 +0200151 <bean id="adminDao" class="de.ids_mannheim.korap.dao.AdminDaoImpl" />
margaretha35e1ca22023-11-16 22:00:01 +0100152 <bean id="authorizationDao"
153 class="de.ids_mannheim.korap.oauth2.dao.CachedAuthorizationDaoImpl" />
margarethab4ce6602018-04-26 20:23:57 +0200154
margaretha34954472018-10-24 20:05:17 +0200155 <!-- Services -->
margaretha35e1ca22023-11-16 22:00:01 +0100156 <bean id="scopeService"
157 class="de.ids_mannheim.korap.oauth2.service.OAuth2ScopeServiceImpl" />
158
margarethab4ce6602018-04-26 20:23:57 +0200159 <!-- props are injected from default-config.xml -->
margaretha35e1ca22023-11-16 22:00:01 +0100160 <bean id="kustvakt_config"
161 class="de.ids_mannheim.korap.config.FullConfiguration">
margarethab4ce6602018-04-26 20:23:57 +0200162 <constructor-arg name="properties" ref="props" />
163 </bean>
164
margaretha35e1ca22023-11-16 22:00:01 +0100165 <bean id="initializator"
166 class="de.ids_mannheim.korap.init.Initializator" init-method="init">
margarethab4ce6602018-04-26 20:23:57 +0200167 </bean>
margaretha35e1ca22023-11-16 22:00:01 +0100168
margarethaade7d4a2017-07-20 19:53:35 +0200169 <!-- Krill -->
margaretha35e1ca22023-11-16 22:00:01 +0100170 <bean id="search_krill"
171 class="de.ids_mannheim.korap.web.SearchKrill">
margaretha0e8f4e72018-04-05 14:11:52 +0200172 <constructor-arg value="${krill.indexDir}" />
margaretha543f2002017-07-14 00:27:15 +0200173 </bean>
margaretha35e1ca22023-11-16 22:00:01 +0100174
margaretha6cd27f32019-01-24 14:47:47 +0100175 <!-- Validator -->
margaretha35e1ca22023-11-16 22:00:01 +0100176 <bean id="validator"
177 class="de.ids_mannheim.korap.validator.ApacheValidator" />
margaretha543f2002017-07-14 00:27:15 +0200178
margaretha31a9f522018-04-03 20:40:45 +0200179 <!-- URLValidator -->
margaretha35e1ca22023-11-16 22:00:01 +0100180 <bean id="redirectURIValidator"
181 class="org.apache.commons.validator.routines.UrlValidator">
margarethae4034a82018-07-02 14:46:59 +0200182 <constructor-arg value="http,https" index="0" />
margaretha35e1ca22023-11-16 22:00:01 +0100183 <constructor-arg index="1" type="long"
184 value="#{T(org.apache.commons.validator.routines.UrlValidator).ALLOW_LOCAL_URLS +
185 T(org.apache.commons.validator.routines.UrlValidator).NO_FRAGMENTS}" />
186
187 <!-- <constructor-arg index="1" type="long"> <util:constant static-field="org.apache.commons.validator.routines.UrlValidator.NO_FRAGMENTS"
188 /> </constructor-arg> -->
margarethaa0486272018-04-12 19:59:31 +0200189 </bean>
margaretha35e1ca22023-11-16 22:00:01 +0100190 <bean id="urlValidator"
191 class="org.apache.commons.validator.routines.UrlValidator">
margarethad7cab212018-07-02 19:01:43 +0200192 <constructor-arg value="http,https" />
193 </bean>
margaretha35e1ca22023-11-16 22:00:01 +0100194
margaretha34954472018-10-24 20:05:17 +0200195 <!-- Rewrite -->
margaretha35e1ca22023-11-16 22:00:01 +0100196 <bean id="foundryRewrite"
197 class="de.ids_mannheim.korap.rewrite.FoundryRewrite" />
198 <bean id="collectionRewrite"
199 class="de.ids_mannheim.korap.rewrite.CollectionRewrite" />
200 <bean id="virtualCorpusRewrite"
201 class="de.ids_mannheim.korap.rewrite.VirtualCorpusRewrite" />
202 <bean id="queryReferenceRewrite"
203 class="de.ids_mannheim.korap.rewrite.QueryReferenceRewrite" />
204
margaretha4fa4b062019-01-28 19:43:30 +0100205 <util:list id="rewriteTasks"
206 value-type="de.ids_mannheim.korap.rewrite.RewriteTask">
207 <ref bean="foundryRewrite" />
208 <ref bean="collectionRewrite" />
209 <ref bean="virtualCorpusRewrite" />
margaretha35e1ca22023-11-16 22:00:01 +0100210 <ref bean="queryReferenceRewrite" />
margaretha4fa4b062019-01-28 19:43:30 +0100211 </util:list>
margaretha35e1ca22023-11-16 22:00:01 +0100212
213 <bean id="rewriteHandler"
214 class="de.ids_mannheim.korap.rewrite.RewriteHandler">
215 <constructor-arg ref="rewriteTasks" />
margaretha56e8e552017-12-05 16:31:21 +0100216 </bean>
217
margaretha35e1ca22023-11-16 22:00:01 +0100218 <bean id="kustvaktResponseHandler"
219 class="de.ids_mannheim.korap.web.KustvaktResponseHandler">
margaretha0e8f4e72018-04-05 14:11:52 +0200220 </bean>
margarethaa452c5e2018-04-25 22:48:09 +0200221
margarethafb027f92018-04-23 20:00:13 +0200222 <!-- OAuth -->
margaretha35e1ca22023-11-16 22:00:01 +0100223 <bean id="oauth2ResponseHandler"
224 class="de.ids_mannheim.korap.web.OAuth2ResponseHandler">
margaretha05122312018-04-16 15:01:34 +0200225 </bean>
margarethaa452c5e2018-04-25 22:48:09 +0200226
margaretha35e1ca22023-11-16 22:00:01 +0100227 <bean name="kustvakt_encryption"
228 class="de.ids_mannheim.korap.encryption.KustvaktEncryption">
margaretha543f2002017-07-14 00:27:15 +0200229 <constructor-arg ref="kustvakt_config" />
230 </bean>
231
232 <!-- authentication providers to use -->
margaretha543f2002017-07-14 00:27:15 +0200233
margaretha35e1ca22023-11-16 22:00:01 +0100234 <!-- <bean id="session_auth" class="de.ids_mannheim.korap.authentication.SessionAuthentication">
235 <constructor-arg type="de.ids_mannheim.korap.config.KustvaktConfiguration"
236 ref="kustvakt_config" /> <constructor-arg type="de.ids_mannheim.korap.interfaces.EncryptionIface"
237 ref="kustvakt_encryption" /> </bean> -->
Michael Hanlca740d72015-06-16 10:04:58 +0200238
margarethacf306d32018-05-30 19:45:35 +0200239 <bean id="oauth2_auth"
240 class="de.ids_mannheim.korap.authentication.OAuth2Authentication" />
margaretha35e1ca22023-11-16 22:00:01 +0100241
margaretha543f2002017-07-14 00:27:15 +0200242 <util:list id="kustvakt_authproviders"
243 value-type="de.ids_mannheim.korap.interfaces.AuthenticationIface">
margarethaac49b502023-04-18 11:01:48 +0200244 <!-- <ref bean="session_auth" /> -->
margarethacf306d32018-05-30 19:45:35 +0200245 <ref bean="oauth2_auth" />
margaretha543f2002017-07-14 00:27:15 +0200246 </util:list>
Michael Hanl72c7b832015-09-03 08:42:15 +0200247
248
margaretha543f2002017-07-14 00:27:15 +0200249 <!-- specify type for constructor argument -->
margaretha34954472018-10-24 20:05:17 +0200250 <bean id="authenticationManager"
margaretha139d0f72017-11-14 18:56:22 +0100251 class="de.ids_mannheim.korap.authentication.KustvaktAuthenticationManager">
margaretha35e1ca22023-11-16 22:00:01 +0100252 <constructor-arg
253 type="de.ids_mannheim.korap.interfaces.EncryptionIface"
margaretha543f2002017-07-14 00:27:15 +0200254 ref="kustvakt_encryption" />
255 <constructor-arg ref="kustvakt_config" />
margaretha543f2002017-07-14 00:27:15 +0200256 <!-- inject authentication providers to use -->
257 <property name="providers" ref="kustvakt_authproviders" />
258 </bean>
margaretha35e1ca22023-11-16 22:00:01 +0100259
margaretha543f2002017-07-14 00:27:15 +0200260 <!-- todo: if db interfaces not loaded via spring, does transaction even
261 work then? -->
262 <!-- the transactional advice (i.e. what 'happens'; see the <aop:advisor/>
263 bean below) -->
264 <tx:advice id="txAdvice" transaction-manager="txManager">
265 <!-- the transactional semantics... -->
266 <tx:attributes>
267 <!-- all methods starting with 'get' are read-only -->
margaretha35e1ca22023-11-16 22:00:01 +0100268 <tx:method name="get*" read-only="true"
269 rollback-for="KorAPException" />
margaretha543f2002017-07-14 00:27:15 +0200270 <!-- other methods use the default transaction settings (see below) -->
271 <tx:method name="*" rollback-for="KorAPException" />
272 </tx:attributes>
273 </tx:advice>
Michael Hanldaf86602016-05-12 14:31:52 +0200274
margaretha543f2002017-07-14 00:27:15 +0200275 <!-- ensure that the above transactional advice runs for any execution of
276 an operation defined by the service interface -->
277 <aop:config>
278 <aop:pointcut id="service"
279 expression="execution(* de.ids_mannheim.korap.interfaces.db.*.*(..))" />
280 <aop:advisor advice-ref="txAdvice" pointcut-ref="service" />
281 </aop:config>
Michael Hanlf8fcc7a2016-06-03 17:41:07 +0200282
margaretha543f2002017-07-14 00:27:15 +0200283 <!-- similarly, don't forget the PlatformTransactionManager -->
284 <bean id="txManager"
285 class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
margaretha09a9a582024-01-11 21:48:20 +0100286 <property name="dataSource" ref="dataSource" />
margaretha8514d782018-08-28 17:36:56 +0200287 <!-- <property name="dataSource" ref="c3p0DataSource" /> -->
margaretha543f2002017-07-14 00:27:15 +0200288 </bean>
margaretha0e8f4e72018-04-05 14:11:52 +0200289
Akronbee031a2020-10-29 16:58:14 +0100290</beans>