margaretha | 1960ea5 | 2023-02-28 11:20:15 +0100 | [diff] [blame] | 1 | <?xml version="1.0" encoding="UTF-8"?> |
| 2 | <beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
margaretha | 35e1ca2 | 2023-11-16 22:00:01 +0100 | [diff] [blame] | 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" |
margaretha | 1960ea5 | 2023-02-28 11:20:15 +0100 | [diff] [blame] | 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 | |
margaretha | 35e1ca2 | 2023-11-16 22:00:01 +0100 | [diff] [blame] | 21 | <context:component-scan |
| 22 | base-package="de.ids_mannheim.korap" /> |
margaretha | 1960ea5 | 2023-02-28 11:20:15 +0100 | [diff] [blame] | 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>file:./kustvakt-icc.conf</value> |
| 31 | <value>classpath:kustvakt-icc.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> |
| 42 | <value>file:./jdbc.properties</value> |
| 43 | <value>classpath:properties/mail.properties</value> |
| 44 | <value>file:./mail.properties</value> |
margaretha | 4e1d476 | 2023-05-09 13:38:32 +0200 | [diff] [blame] | 45 | <value>classpath:properties/hibernate.properties</value> |
margaretha | 1960ea5 | 2023-02-28 11:20:15 +0100 | [diff] [blame] | 46 | <value>file:./kustvakt-icc.conf</value> |
| 47 | <value>classpath:kustvakt-icc.conf</value> |
| 48 | </array> |
| 49 | </property> |
| 50 | </bean> |
margaretha | 1960ea5 | 2023-02-28 11:20:15 +0100 | [diff] [blame] | 51 | |
margaretha | 35e1ca2 | 2023-11-16 22:00:01 +0100 | [diff] [blame] | 52 | <!-- <bean id='cacheManager' class='org.springframework.cache.ehcache.EhCacheCacheManager' |
| 53 | p:cacheManager-ref='ehcache' /> <bean id='ehcache' class='org.springframework.cache.ehcache.EhCacheManagerFactoryBean' |
| 54 | p:configLocation='classpath:ehcache.xml' p:shared='true' /> --> |
| 55 | <bean id="dataSource" |
| 56 | class="org.apache.commons.dbcp2.BasicDataSource" lazy-init="true"> |
margaretha | 1960ea5 | 2023-02-28 11:20:15 +0100 | [diff] [blame] | 57 | <!-- <property name="driverClassName" value="${jdbc.driverClassName}" /> --> |
| 58 | <property name="url" value="${jdbc.url}" /> |
| 59 | <property name="username" value="${jdbc.username}" /> |
| 60 | <property name="password" value="${jdbc.password}" /> |
| 61 | <property name="maxTotal" value="4" /> |
| 62 | <property name="maxIdle" value="1" /> |
| 63 | <property name="minIdle" value="1" /> |
| 64 | <property name="maxWaitMillis" value="15000" /> |
| 65 | <!--<property name="poolPreparedStatements" value="true"/> --> |
| 66 | </bean> |
| 67 | |
| 68 | <!-- use SingleConnection only for testing! --> |
| 69 | <bean id="sqliteDataSource" |
| 70 | class="org.springframework.jdbc.datasource.SingleConnectionDataSource" |
| 71 | lazy-init="true"> |
| 72 | <!-- <property name="driverClassName" value="${jdbc.driverClassName}" /> --> |
| 73 | <property name="url" value="${jdbc.url}" /> |
| 74 | <property name="username" value="${jdbc.username}" /> |
| 75 | <property name="password" value="${jdbc.password}" /> |
| 76 | <property name="connectionProperties"> |
| 77 | <props> |
| 78 | <prop key="date_string_format">yyyy-MM-dd HH:mm:ss</prop> |
| 79 | </props> |
| 80 | </property> |
| 81 | |
| 82 | <!-- Sqlite can only have a single connection --> |
| 83 | <property name="suppressClose"> |
| 84 | <value>true</value> |
| 85 | </property> |
| 86 | </bean> |
| 87 | |
margaretha | 35e1ca2 | 2023-11-16 22:00:01 +0100 | [diff] [blame] | 88 | <bean id="c3p0DataSource" |
| 89 | class="com.mchange.v2.c3p0.ComboPooledDataSource" |
margaretha | 1960ea5 | 2023-02-28 11:20:15 +0100 | [diff] [blame] | 90 | destroy-method="close"> |
| 91 | <property name="driverClass" value="${jdbc.driverClassName}" /> |
| 92 | <property name="jdbcUrl" value="${jdbc.url}" /> |
| 93 | <property name="user" value="${jdbc.username}" /> |
| 94 | <property name="password" value="${jdbc.password}" /> |
| 95 | <property name="maxPoolSize" value="4" /> |
| 96 | <property name="minPoolSize" value="1" /> |
| 97 | <property name="maxStatements" value="1" /> |
| 98 | <property name="testConnectionOnCheckout" value="true" /> |
| 99 | </bean> |
| 100 | |
| 101 | <!-- to configure database for sqlite, mysql, etc. migrations --> |
margaretha | 35e1ca2 | 2023-11-16 22:00:01 +0100 | [diff] [blame] | 102 | <bean id="flywayConfig" |
| 103 | class="org.flywaydb.core.api.configuration.ClassicConfiguration"> |
margaretha | 1960ea5 | 2023-02-28 11:20:15 +0100 | [diff] [blame] | 104 | <!-- drop existing tables and create new tables --> |
| 105 | <property name="validateOnMigrate" value="true" /> |
| 106 | <property name="cleanOnValidationError" value="true" /> |
| 107 | <property name="baselineOnMigrate" value="false" /> |
margaretha | 35e1ca2 | 2023-11-16 22:00:01 +0100 | [diff] [blame] | 108 | <property name="locations" |
| 109 | value="#{'${jdbc.schemaPath}'.split(',')}" /> |
margaretha | 1960ea5 | 2023-02-28 11:20:15 +0100 | [diff] [blame] | 110 | <property name="dataSource" ref="sqliteDataSource" /> |
| 111 | <!-- <property name="dataSource" ref="dataSource" /> --> |
| 112 | <property name="outOfOrder" value="true" /> |
| 113 | </bean> |
margaretha | 35e1ca2 | 2023-11-16 22:00:01 +0100 | [diff] [blame] | 114 | |
| 115 | <bean id="flyway" class="org.flywaydb.core.Flyway" |
| 116 | init-method="migrate"> |
| 117 | <constructor-arg ref="flywayConfig" /> |
margaretha | 1960ea5 | 2023-02-28 11:20:15 +0100 | [diff] [blame] | 118 | </bean> |
margaretha | 35e1ca2 | 2023-11-16 22:00:01 +0100 | [diff] [blame] | 119 | |
margaretha | 1960ea5 | 2023-02-28 11:20:15 +0100 | [diff] [blame] | 120 | |
margaretha | 1960ea5 | 2023-02-28 11:20:15 +0100 | [diff] [blame] | 121 | <bean id="entityManagerFactory" |
| 122 | class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"> |
| 123 | <!-- <property name="dataSource" ref="dataSource" /> --> |
| 124 | <property name="dataSource" ref="sqliteDataSource" /> |
| 125 | <property name="packagesToScan"> |
| 126 | <array> |
margaretha | 5b70879 | 2023-05-12 16:55:29 +0200 | [diff] [blame] | 127 | <value>de.ids_mannheim.korap.core.entity</value> |
margaretha | 1960ea5 | 2023-02-28 11:20:15 +0100 | [diff] [blame] | 128 | <value>de.ids_mannheim.korap.entity</value> |
| 129 | <value>de.ids_mannheim.korap.oauth2.entity</value> |
| 130 | </array> |
| 131 | </property> |
| 132 | <property name="jpaVendorAdapter"> |
| 133 | <bean id="jpaVendorAdapter" |
| 134 | class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"> |
margaretha | 35e1ca2 | 2023-11-16 22:00:01 +0100 | [diff] [blame] | 135 | <property name="databasePlatform" |
| 136 | value="${hibernate.dialect}" /> |
margaretha | 1960ea5 | 2023-02-28 11:20:15 +0100 | [diff] [blame] | 137 | </bean> |
| 138 | </property> |
| 139 | <property name="jpaProperties"> |
| 140 | <props> |
| 141 | <prop key="hibernate.dialect">${hibernate.dialect}</prop> |
| 142 | <prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop> |
| 143 | <prop key="hibernate.show_sql">${hibernate.show_sql}</prop> |
| 144 | <prop key="hibernate.cache.use_query_cache">${hibernate.cache.use_query_cache}</prop> |
| 145 | <prop key="hibernate.cache.use_second_level_cache">${hibernate.cache.use_second_level_cache} |
| 146 | </prop> |
| 147 | <prop key="hibernate.cache.provider_class">${hibernate.cache.provider}</prop> |
| 148 | <prop key="hibernate.cache.region.factory_class">${hibernate.cache.region.factory}</prop> |
| 149 | <prop key="hibernate.jdbc.time_zone">${hibernate.jdbc.time_zone}</prop> |
| 150 | <!-- <prop key="net.sf.ehcache.configurationResourceName">classpath:ehcache.xml</prop> --> |
| 151 | </props> |
| 152 | </property> |
| 153 | </bean> |
| 154 | |
| 155 | <tx:annotation-driven proxy-target-class="true" |
| 156 | transaction-manager="transactionManager" /> |
margaretha | 35e1ca2 | 2023-11-16 22:00:01 +0100 | [diff] [blame] | 157 | <bean id="transactionManager" |
| 158 | class="org.springframework.orm.jpa.JpaTransactionManager"> |
| 159 | <property name="entityManagerFactory" |
| 160 | ref="entityManagerFactory" /> |
margaretha | 1960ea5 | 2023-02-28 11:20:15 +0100 | [diff] [blame] | 161 | </bean> |
| 162 | |
| 163 | <bean id="transactionTemplate" |
| 164 | class="org.springframework.transaction.support.TransactionTemplate"> |
| 165 | <constructor-arg ref="transactionManager" /> |
| 166 | </bean> |
| 167 | |
| 168 | <!-- Data access objects --> |
| 169 | <bean id="adminDao" class="de.ids_mannheim.korap.dao.AdminDaoImpl" /> |
margaretha | 35e1ca2 | 2023-11-16 22:00:01 +0100 | [diff] [blame] | 170 | <bean id="resourceDao" |
| 171 | class="de.ids_mannheim.korap.dao.ResourceDao" /> |
| 172 | <bean id="accessScopeDao" |
| 173 | class="de.ids_mannheim.korap.oauth2.dao.AccessScopeDao" /> |
| 174 | <bean id="authorizationDao" |
| 175 | class="de.ids_mannheim.korap.oauth2.dao.CachedAuthorizationDaoImpl" /> |
| 176 | |
margaretha | 1960ea5 | 2023-02-28 11:20:15 +0100 | [diff] [blame] | 177 | <!-- Services --> |
margaretha | 35e1ca2 | 2023-11-16 22:00:01 +0100 | [diff] [blame] | 178 | <bean id="scopeService" |
| 179 | class="de.ids_mannheim.korap.oauth2.service.OAuth2ScopeServiceImpl" /> |
| 180 | |
| 181 | |
margaretha | 1960ea5 | 2023-02-28 11:20:15 +0100 | [diff] [blame] | 182 | <!-- Controller --> |
margaretha | 35e1ca2 | 2023-11-16 22:00:01 +0100 | [diff] [blame] | 183 | |
| 184 | |
margaretha | 1960ea5 | 2023-02-28 11:20:15 +0100 | [diff] [blame] | 185 | <!-- props are injected from default-config.xml --> |
margaretha | 35e1ca2 | 2023-11-16 22:00:01 +0100 | [diff] [blame] | 186 | <bean id="kustvakt_config" |
| 187 | class="de.ids_mannheim.korap.config.FullConfiguration"> |
margaretha | 1960ea5 | 2023-02-28 11:20:15 +0100 | [diff] [blame] | 188 | <constructor-arg name="properties" ref="props" /> |
| 189 | </bean> |
| 190 | |
margaretha | 35e1ca2 | 2023-11-16 22:00:01 +0100 | [diff] [blame] | 191 | <bean id="initializator" |
| 192 | class="de.ids_mannheim.korap.init.Initializator" |
margaretha | 1960ea5 | 2023-02-28 11:20:15 +0100 | [diff] [blame] | 193 | init-method="initTest"> |
| 194 | </bean> |
| 195 | |
| 196 | <!-- Krill --> |
margaretha | 35e1ca2 | 2023-11-16 22:00:01 +0100 | [diff] [blame] | 197 | <bean id="search_krill" |
| 198 | class="de.ids_mannheim.korap.web.SearchKrill"> |
margaretha | 1960ea5 | 2023-02-28 11:20:15 +0100 | [diff] [blame] | 199 | <constructor-arg value="${krill.indexDir}" /> |
| 200 | </bean> |
| 201 | |
| 202 | <!-- Validator --> |
margaretha | 35e1ca2 | 2023-11-16 22:00:01 +0100 | [diff] [blame] | 203 | <bean id="validator" |
| 204 | class="de.ids_mannheim.korap.validator.ApacheValidator" /> |
| 205 | |
margaretha | 1960ea5 | 2023-02-28 11:20:15 +0100 | [diff] [blame] | 206 | <!-- URLValidator --> |
margaretha | 35e1ca2 | 2023-11-16 22:00:01 +0100 | [diff] [blame] | 207 | <bean id="redirectURIValidator" |
| 208 | class="org.apache.commons.validator.routines.UrlValidator"> |
margaretha | 1960ea5 | 2023-02-28 11:20:15 +0100 | [diff] [blame] | 209 | <constructor-arg value="http,https" index="0" /> |
margaretha | 35e1ca2 | 2023-11-16 22:00:01 +0100 | [diff] [blame] | 210 | <constructor-arg index="1" type="long" |
| 211 | value="#{T(org.apache.commons.validator.routines.UrlValidator).ALLOW_LOCAL_URLS + |
| 212 | T(org.apache.commons.validator.routines.UrlValidator).NO_FRAGMENTS}" /> |
margaretha | 1960ea5 | 2023-02-28 11:20:15 +0100 | [diff] [blame] | 213 | </bean> |
margaretha | 35e1ca2 | 2023-11-16 22:00:01 +0100 | [diff] [blame] | 214 | <bean id="urlValidator" |
| 215 | class="org.apache.commons.validator.routines.UrlValidator"> |
margaretha | 1960ea5 | 2023-02-28 11:20:15 +0100 | [diff] [blame] | 216 | <constructor-arg value="http,https" /> |
| 217 | </bean> |
| 218 | |
| 219 | <!-- Rewrite --> |
margaretha | 35e1ca2 | 2023-11-16 22:00:01 +0100 | [diff] [blame] | 220 | <bean id="foundryRewrite" |
| 221 | class="de.ids_mannheim.korap.rewrite.FoundryRewrite" /> |
| 222 | <bean id="collectionRewrite" |
| 223 | class="de.ids_mannheim.korap.rewrite.CollectionRewrite" /> |
| 224 | <bean id="collectionCleanRewrite" |
| 225 | class="de.ids_mannheim.korap.rewrite.CollectionCleanRewrite" /> |
| 226 | <bean id="virtualCorpusRewrite" |
| 227 | class="de.ids_mannheim.korap.rewrite.VirtualCorpusRewrite" /> |
| 228 | <bean id="collectionConstraint" |
| 229 | class="de.ids_mannheim.korap.rewrite.CollectionConstraint" /> |
| 230 | <bean id="queryReferenceRewrite" |
| 231 | class="de.ids_mannheim.korap.rewrite.QueryReferenceRewrite" /> |
| 232 | |
margaretha | 1960ea5 | 2023-02-28 11:20:15 +0100 | [diff] [blame] | 233 | <util:list id="rewriteTasks" |
| 234 | value-type="de.ids_mannheim.korap.rewrite.RewriteTask"> |
margaretha | 35e1ca2 | 2023-11-16 22:00:01 +0100 | [diff] [blame] | 235 | <!-- <ref bean="collectionConstraint" /> <ref bean="collectionCleanRewrite" |
| 236 | /> --> |
margaretha | 1960ea5 | 2023-02-28 11:20:15 +0100 | [diff] [blame] | 237 | <ref bean="foundryRewrite" /> |
| 238 | <!-- <ref bean="collectionRewrite" /> --> |
| 239 | <ref bean="virtualCorpusRewrite" /> |
| 240 | <ref bean="queryReferenceRewrite" /> |
| 241 | </util:list> |
margaretha | 35e1ca2 | 2023-11-16 22:00:01 +0100 | [diff] [blame] | 242 | |
| 243 | <bean id="rewriteHandler" |
| 244 | class="de.ids_mannheim.korap.rewrite.RewriteHandler"> |
| 245 | <constructor-arg ref="rewriteTasks" /> |
margaretha | 1960ea5 | 2023-02-28 11:20:15 +0100 | [diff] [blame] | 246 | </bean> |
| 247 | |
margaretha | 35e1ca2 | 2023-11-16 22:00:01 +0100 | [diff] [blame] | 248 | <bean id="kustvaktResponseHandler" |
| 249 | class="de.ids_mannheim.korap.web.KustvaktResponseHandler"> |
margaretha | 1960ea5 | 2023-02-28 11:20:15 +0100 | [diff] [blame] | 250 | </bean> |
| 251 | |
| 252 | <!-- OAuth --> |
margaretha | 35e1ca2 | 2023-11-16 22:00:01 +0100 | [diff] [blame] | 253 | <bean id="oauth2ResponseHandler" |
| 254 | class="de.ids_mannheim.korap.web.OAuth2ResponseHandler"> |
margaretha | 1960ea5 | 2023-02-28 11:20:15 +0100 | [diff] [blame] | 255 | </bean> |
| 256 | |
margaretha | 35e1ca2 | 2023-11-16 22:00:01 +0100 | [diff] [blame] | 257 | <bean name="kustvakt_encryption" |
| 258 | class="de.ids_mannheim.korap.encryption.KustvaktEncryption"> |
margaretha | 1960ea5 | 2023-02-28 11:20:15 +0100 | [diff] [blame] | 259 | <constructor-arg ref="kustvakt_config" /> |
| 260 | </bean> |
| 261 | |
| 262 | <!-- authentication providers to use --> |
| 263 | <bean id="basic_auth" |
| 264 | class="de.ids_mannheim.korap.authentication.BasicAuthentication" /> |
| 265 | |
| 266 | <bean id="oauth2_auth" |
| 267 | class="de.ids_mannheim.korap.authentication.OAuth2Authentication" /> |
| 268 | |
| 269 | |
| 270 | <util:list id="kustvakt_authproviders" |
| 271 | value-type="de.ids_mannheim.korap.interfaces.AuthenticationIface"> |
| 272 | <ref bean="basic_auth" /> |
| 273 | <ref bean="oauth2_auth" /> |
| 274 | </util:list> |
| 275 | |
| 276 | |
margaretha | 1960ea5 | 2023-02-28 11:20:15 +0100 | [diff] [blame] | 277 | <!-- specify type for constructor argument --> |
| 278 | <bean id="authenticationManager" |
| 279 | class="de.ids_mannheim.korap.authentication.KustvaktAuthenticationManager"> |
margaretha | 35e1ca2 | 2023-11-16 22:00:01 +0100 | [diff] [blame] | 280 | <constructor-arg |
| 281 | type="de.ids_mannheim.korap.interfaces.EncryptionIface" |
margaretha | 1960ea5 | 2023-02-28 11:20:15 +0100 | [diff] [blame] | 282 | ref="kustvakt_encryption" /> |
| 283 | <constructor-arg ref="kustvakt_config" /> |
margaretha | 1960ea5 | 2023-02-28 11:20:15 +0100 | [diff] [blame] | 284 | <!-- inject authentication providers to use --> |
| 285 | <property name="providers" ref="kustvakt_authproviders" /> |
| 286 | </bean> |
| 287 | |
| 288 | <!-- todo: if db interfaces not loaded via spring, does transaction even |
| 289 | work then? --> |
| 290 | <!-- the transactional advice (i.e. what 'happens'; see the <aop:advisor/> |
| 291 | bean below) --> |
| 292 | <tx:advice id="txAdvice" transaction-manager="txManager"> |
| 293 | <!-- the transactional semantics... --> |
| 294 | <tx:attributes> |
| 295 | <!-- all methods starting with 'get' are read-only --> |
margaretha | 35e1ca2 | 2023-11-16 22:00:01 +0100 | [diff] [blame] | 296 | <tx:method name="get*" read-only="true" |
| 297 | rollback-for="KorAPException" /> |
margaretha | 1960ea5 | 2023-02-28 11:20:15 +0100 | [diff] [blame] | 298 | <!-- other methods use the default transaction settings (see below) --> |
| 299 | <tx:method name="*" rollback-for="KorAPException" /> |
| 300 | </tx:attributes> |
| 301 | </tx:advice> |
| 302 | |
| 303 | <!-- ensure that the above transactional advice runs for any execution of |
| 304 | an operation defined by the service interface --> |
| 305 | <aop:config> |
| 306 | <aop:pointcut id="service" |
| 307 | expression="execution(* de.ids_mannheim.korap.interfaces.db.*.*(..))" /> |
| 308 | <aop:advisor advice-ref="txAdvice" pointcut-ref="service" /> |
| 309 | </aop:config> |
| 310 | |
| 311 | <!-- similarly, don't forget the PlatformTransactionManager --> |
| 312 | <bean id="txManager" |
| 313 | class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> |
| 314 | <property name="dataSource" ref="dataSource" /> |
| 315 | </bean> |
| 316 | |
margaretha | 1960ea5 | 2023-02-28 11:20:15 +0100 | [diff] [blame] | 317 | </beans> |