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