blob: 20ce71cb1d8cd975ab962afce70388ef6911aa95 [file] [log] [blame]
margaretha46e2c952024-05-23 09:09:54 +02001<?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:context="http://www.springframework.org/schema/context"
9 xmlns:cache="http://www.springframework.org/schema/cache"
10 xsi:schemaLocation="http://www.springframework.org/schema/beans
11 http://www.springframework.org/schema/beans/spring-beans.xsd
12 http://www.springframework.org/schema/tx
13 http://www.springframework.org/schema/tx/spring-tx.xsd
14 http://www.springframework.org/schema/aop
15 http://www.springframework.org/schema/aop/spring-aop.xsd
16 http://www.springframework.org/schema/context
17 http://www.springframework.org/schema/context/spring-context.xsd
18 http://www.springframework.org/schema/util
19 http://www.springframework.org/schema/util/spring-util.xsd">
20
21 <context:component-scan
22 base-package="de.ids_mannheim.korap" />
23 <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-dnb.conf</value>
31 <value>file:./kustvakt-dnb.conf</value>
32 </array>
33 </property>
34 </bean>
35
36 <bean id="placeholders"
37 class="org.springframework.context.support.PropertySourcesPlaceholderConfigurer">
38 <property name="ignoreResourceNotFound" value="true" />
39 <property name="locations">
40 <array>
41 <value>classpath:test-jdbc.properties</value>
margaretha29060842025-04-07 09:09:42 +020042 <value>file:./data/test-jdbc.properties</value>
margaretha46e2c952024-05-23 09:09:54 +020043 <value>classpath:test-hibernate.properties</value>
margaretha46e2c952024-05-23 09:09:54 +020044 <value>classpath:kustvakt-dnb.conf</value>
margaretha29060842025-04-07 09:09:42 +020045 <value>file:./data/kustvakt-dnb.conf</value>
margaretha46e2c952024-05-23 09:09:54 +020046 </array>
47 </property>
48 </bean>
49
margaretha29060842025-04-07 09:09:42 +020050 <!-- props are injected from default-config.xml -->
51 <bean id="kustvakt_config"
52 class="de.ids_mannheim.korap.config.FullConfiguration">
53 <constructor-arg name="properties" ref="props" />
54 </bean>
55
margaretha46e2c952024-05-23 09:09:54 +020056
57 <bean id="dataSource"
58 class="org.apache.commons.dbcp2.BasicDataSource" lazy-init="true">
59 <!-- <property name="driverClassName" value="${jdbc.driverClassName}" /> -->
60 <property name="url" value="${jdbc.url}" />
61 <property name="username" value="${jdbc.username}" />
62 <property name="password" value="${jdbc.password}" />
63 <property name="maxTotal" value="4" />
64 <property name="maxIdle" value="1" />
65 <property name="minIdle" value="1" />
66 <property name="maxWaitMillis" value="15000" />
67 <!--<property name="poolPreparedStatements" value="true"/> -->
68 </bean>
69
margaretha46e2c952024-05-23 09:09:54 +020070 <bean id="c3p0DataSource"
71 class="com.mchange.v2.c3p0.ComboPooledDataSource"
72 destroy-method="close">
73 <property name="driverClass" value="${jdbc.driverClassName}" />
74 <property name="jdbcUrl" value="${jdbc.url}" />
75 <property name="user" value="${jdbc.username}" />
76 <property name="password" value="${jdbc.password}" />
77 <property name="maxPoolSize" value="4" />
78 <property name="minPoolSize" value="1" />
79 <property name="maxStatements" value="1" />
80 <property name="testConnectionOnCheckout" value="true" />
81 </bean>
82
83 <!-- to configure database for sqlite, mysql, etc. migrations -->
84 <bean id="flywayConfig"
85 class="org.flywaydb.core.api.configuration.ClassicConfiguration">
86 <!-- drop existing tables and create new tables -->
87 <property name="validateOnMigrate" value="true" />
88 <property name="cleanOnValidationError" value="true" />
89 <property name="baselineOnMigrate" value="false" />
90 <property name="locations"
91 value="#{'${jdbc.schemaPath}'.split(',')}" />
margaretha46e2c952024-05-23 09:09:54 +020092 <property name="dataSource" ref="dataSource" />
93 <property name="outOfOrder" value="true" />
94 </bean>
95
96 <bean id="flyway" class="org.flywaydb.core.Flyway"
97 init-method="migrate">
98 <constructor-arg ref="flywayConfig" />
99 </bean>
100
101
102 <bean id="entityManagerFactory"
103 class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
104 <property name="dataSource" ref="dataSource" />
margaretha46e2c952024-05-23 09:09:54 +0200105 <property name="packagesToScan">
106 <array>
107 <value>de.ids_mannheim.korap.core.entity</value>
108 <value>de.ids_mannheim.korap.entity</value>
109 <value>de.ids_mannheim.korap.oauth2.entity</value>
110 </array>
111 </property>
112 <property name="jpaVendorAdapter">
113 <bean id="jpaVendorAdapter"
114 class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
115 <property name="databasePlatform"
116 value="${hibernate.dialect}" />
117 </bean>
118 </property>
119 <property name="jpaProperties">
120 <props>
121 <prop key="hibernate.dialect">${hibernate.dialect}</prop>
122 <prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop>
123 <prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
124 <prop key="hibernate.cache.use_query_cache">${hibernate.cache.use_query_cache}</prop>
125 <prop key="hibernate.cache.use_second_level_cache">${hibernate.cache.use_second_level_cache}
126 </prop>
127 <prop key="hibernate.cache.provider_class">${hibernate.cache.provider}</prop>
128 <prop key="hibernate.cache.region.factory_class">${hibernate.cache.region.factory}</prop>
129 <prop key="hibernate.jdbc.time_zone">${hibernate.jdbc.time_zone}</prop>
130 <!-- <prop key="net.sf.ehcache.configurationResourceName">classpath:ehcache.xml</prop> -->
131 </props>
132 </property>
133 </bean>
134
135 <tx:annotation-driven proxy-target-class="true"
136 transaction-manager="transactionManager" />
137 <bean id="transactionManager"
138 class="org.springframework.orm.jpa.JpaTransactionManager">
139 <property name="entityManagerFactory"
140 ref="entityManagerFactory" />
141 </bean>
142
143 <bean id="transactionTemplate"
144 class="org.springframework.transaction.support.TransactionTemplate">
145 <constructor-arg ref="transactionManager" />
146 </bean>
147
148 <!-- Data access objects -->
149 <bean id="adminDao" class="de.ids_mannheim.korap.dao.AdminDaoImpl" />
150 <bean id="resourceDao"
151 class="de.ids_mannheim.korap.dao.ResourceDao" />
152 <bean id="accessScopeDao"
153 class="de.ids_mannheim.korap.oauth2.dao.AccessScopeDao" />
154 <bean id="authorizationDao"
155 class="de.ids_mannheim.korap.oauth2.dao.CachedAuthorizationDaoImpl" />
156
157 <!-- Services -->
158 <bean id="scopeService"
159 class="de.ids_mannheim.korap.oauth2.service.OAuth2ScopeServiceImpl" />
160
margaretha46e2c952024-05-23 09:09:54 +0200161 <bean id="initializator"
162 class="de.ids_mannheim.korap.init.Initializator"
163 init-method="initTest">
164 </bean>
165
166 <!-- Krill -->
167 <bean id="search_krill"
168 class="de.ids_mannheim.korap.web.SearchKrill">
169 <constructor-arg value="${krill.indexDir}" />
170 </bean>
171
172 <!-- Validator -->
173 <bean id="validator"
174 class="de.ids_mannheim.korap.validator.ApacheValidator" />
175
176 <!-- URLValidator -->
177 <bean id="redirectURIValidator"
178 class="org.apache.commons.validator.routines.UrlValidator">
179 <constructor-arg value="http,https" index="0" />
180 <constructor-arg index="1" type="long"
181 value="#{T(org.apache.commons.validator.routines.UrlValidator).ALLOW_LOCAL_URLS +
182 T(org.apache.commons.validator.routines.UrlValidator).NO_FRAGMENTS}" />
183 </bean>
184 <bean id="urlValidator"
185 class="org.apache.commons.validator.routines.UrlValidator">
186 <constructor-arg value="http,https" />
187 </bean>
188
189 <!-- Rewrite -->
190 <bean id="foundryRewrite"
191 class="de.ids_mannheim.korap.rewrite.FoundryRewrite" />
margaretha46e2c952024-05-23 09:09:54 +0200192 <bean id="virtualCorpusRewrite"
193 class="de.ids_mannheim.korap.rewrite.VirtualCorpusRewrite" />
margaretha46e2c952024-05-23 09:09:54 +0200194 <bean id="queryReferenceRewrite"
195 class="de.ids_mannheim.korap.rewrite.QueryReferenceRewrite" />
margaretha29060842025-04-07 09:09:42 +0200196 <bean id="queryContextRewrite"
197 class="de.ids_mannheim.korap.rewrite.QueryContextRewrite" />
198
margaretha46e2c952024-05-23 09:09:54 +0200199
200 <util:list id="rewriteTasks"
201 value-type="de.ids_mannheim.korap.rewrite.RewriteTask">
margaretha46e2c952024-05-23 09:09:54 +0200202 <ref bean="foundryRewrite" />
margaretha46e2c952024-05-23 09:09:54 +0200203 <ref bean="virtualCorpusRewrite" />
204 <ref bean="queryReferenceRewrite" />
margaretha29060842025-04-07 09:09:42 +0200205 <ref bean="queryContextRewrite" />
margaretha46e2c952024-05-23 09:09:54 +0200206 </util:list>
207
208 <bean id="rewriteHandler"
209 class="de.ids_mannheim.korap.rewrite.RewriteHandler">
210 <constructor-arg ref="rewriteTasks" />
211 </bean>
margaretha29060842025-04-07 09:09:42 +0200212
213 <util:list id="statisticsRewriteTasks"
214 value-type="de.ids_mannheim.korap.rewrite.RewriteTask">
215 <ref bean="foundryRewrite" />
216 <ref bean="virtualCorpusRewrite" />
217 <ref bean="queryReferenceRewrite" />
218 </util:list>
219
220 <bean id="statisticsRewriteHandler"
221 class="de.ids_mannheim.korap.rewrite.RewriteHandler">
222 <constructor-arg ref="statisticsRewriteTasks" />
223 </bean>
margaretha46e2c952024-05-23 09:09:54 +0200224
225 <bean id="kustvaktResponseHandler"
226 class="de.ids_mannheim.korap.web.KustvaktResponseHandler">
227 </bean>
228
229 <!-- OAuth -->
230 <bean id="oauth2ResponseHandler"
231 class="de.ids_mannheim.korap.web.OAuth2ResponseHandler">
232 </bean>
233
234 <bean name="kustvakt_encryption"
235 class="de.ids_mannheim.korap.encryption.KustvaktEncryption">
236 <constructor-arg ref="kustvakt_config" />
237 </bean>
238
239 <!-- authentication providers to use -->
240 <bean id="basic_auth"
241 class="de.ids_mannheim.korap.authentication.BasicAuthentication" />
242
margaretha46e2c952024-05-23 09:09:54 +0200243 <bean id="oauth2_auth"
244 class="de.ids_mannheim.korap.authentication.OAuth2Authentication" />
245
246
247 <util:list id="kustvakt_authproviders"
248 value-type="de.ids_mannheim.korap.interfaces.AuthenticationIface">
249 <ref bean="basic_auth" />
margaretha46e2c952024-05-23 09:09:54 +0200250 <ref bean="oauth2_auth" />
251 </util:list>
252
253 <!-- specify type for constructor argument -->
254 <bean id="authenticationManager"
255 class="de.ids_mannheim.korap.authentication.KustvaktAuthenticationManager">
256 <constructor-arg
257 type="de.ids_mannheim.korap.interfaces.EncryptionIface"
258 ref="kustvakt_encryption" />
259 <constructor-arg ref="kustvakt_config" />
260 <!-- inject authentication providers to use -->
261 <property name="providers" ref="kustvakt_authproviders" />
262 </bean>
263
264 <!-- todo: if db interfaces not loaded via spring, does transaction even
265 work then? -->
266 <!-- the transactional advice (i.e. what 'happens'; see the <aop:advisor/>
267 bean below) -->
268 <tx:advice id="txAdvice" transaction-manager="txManager">
269 <!-- the transactional semantics... -->
270 <tx:attributes>
271 <!-- all methods starting with 'get' are read-only -->
272 <tx:method name="get*" read-only="true"
273 rollback-for="KorAPException" />
274 <!-- other methods use the default transaction settings (see below) -->
275 <tx:method name="*" rollback-for="KorAPException" />
276 </tx:attributes>
277 </tx:advice>
278
279 <!-- ensure that the above transactional advice runs for any execution of
280 an operation defined by the service interface -->
281 <aop:config>
282 <aop:pointcut id="service"
283 expression="execution(* de.ids_mannheim.korap.interfaces.db.*.*(..))" />
284 <aop:advisor advice-ref="txAdvice" pointcut-ref="service" />
285 </aop:config>
286
287 <!-- similarly, don't forget the PlatformTransactionManager -->
288 <bean id="txManager"
289 class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
290 <property name="dataSource" ref="dataSource" />
291 </bean>
292
margaretha46e2c952024-05-23 09:09:54 +0200293</beans>