margaretha | 46e2c95 | 2024-05-23 09:09:54 +0200 | [diff] [blame] | 1 | <?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> |
| 42 | <value>file:./test-jdbc.properties</value> |
margaretha | 46e2c95 | 2024-05-23 09:09:54 +0200 | [diff] [blame] | 43 | <value>classpath:test-hibernate.properties</value> |
| 44 | <value>file:./kustvakt-dnb.conf</value> |
| 45 | <value>classpath:kustvakt-dnb.conf</value> |
| 46 | </array> |
| 47 | </property> |
| 48 | </bean> |
| 49 | |
| 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 | |
| 54 | <bean id="dataSource" |
| 55 | class="org.apache.commons.dbcp2.BasicDataSource" lazy-init="true"> |
| 56 | <!-- <property name="driverClassName" value="${jdbc.driverClassName}" /> --> |
| 57 | <property name="url" value="${jdbc.url}" /> |
| 58 | <property name="username" value="${jdbc.username}" /> |
| 59 | <property name="password" value="${jdbc.password}" /> |
| 60 | <property name="maxTotal" value="4" /> |
| 61 | <property name="maxIdle" value="1" /> |
| 62 | <property name="minIdle" value="1" /> |
| 63 | <property name="maxWaitMillis" value="15000" /> |
| 64 | <!--<property name="poolPreparedStatements" value="true"/> --> |
| 65 | </bean> |
| 66 | |
| 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 | --> |
| 86 | <bean id="c3p0DataSource" |
| 87 | class="com.mchange.v2.c3p0.ComboPooledDataSource" |
| 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 --> |
| 100 | <bean id="flywayConfig" |
| 101 | class="org.flywaydb.core.api.configuration.ClassicConfiguration"> |
| 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" /> |
| 106 | <property name="locations" |
| 107 | value="#{'${jdbc.schemaPath}'.split(',')}" /> |
| 108 | <!-- <property name="dataSource" ref="sqliteDataSource" /> --> |
| 109 | <property name="dataSource" ref="dataSource" /> |
| 110 | <property name="outOfOrder" value="true" /> |
| 111 | </bean> |
| 112 | |
| 113 | <bean id="flyway" class="org.flywaydb.core.Flyway" |
| 114 | init-method="migrate"> |
| 115 | <constructor-arg ref="flywayConfig" /> |
| 116 | </bean> |
| 117 | |
| 118 | |
| 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> |
| 125 | <value>de.ids_mannheim.korap.core.entity</value> |
| 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"> |
| 133 | <property name="databasePlatform" |
| 134 | value="${hibernate.dialect}" /> |
| 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" /> |
| 155 | <bean id="transactionManager" |
| 156 | class="org.springframework.orm.jpa.JpaTransactionManager"> |
| 157 | <property name="entityManagerFactory" |
| 158 | ref="entityManagerFactory" /> |
| 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" /> |
| 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 | |
| 175 | <!-- Services --> |
| 176 | <bean id="scopeService" |
| 177 | class="de.ids_mannheim.korap.oauth2.service.OAuth2ScopeServiceImpl" /> |
| 178 | |
| 179 | <!-- props are injected from default-config.xml --> |
| 180 | <bean id="kustvakt_config" |
| 181 | class="de.ids_mannheim.korap.config.FullConfiguration"> |
| 182 | <constructor-arg name="properties" ref="props" /> |
| 183 | </bean> |
| 184 | |
| 185 | <bean id="initializator" |
| 186 | class="de.ids_mannheim.korap.init.Initializator" |
| 187 | init-method="initTest"> |
| 188 | </bean> |
| 189 | |
| 190 | <!-- Krill --> |
| 191 | <bean id="search_krill" |
| 192 | class="de.ids_mannheim.korap.web.SearchKrill"> |
| 193 | <constructor-arg value="${krill.indexDir}" /> |
| 194 | </bean> |
| 195 | |
| 196 | <!-- Validator --> |
| 197 | <bean id="validator" |
| 198 | class="de.ids_mannheim.korap.validator.ApacheValidator" /> |
| 199 | |
| 200 | <!-- URLValidator --> |
| 201 | <bean id="redirectURIValidator" |
| 202 | class="org.apache.commons.validator.routines.UrlValidator"> |
| 203 | <constructor-arg value="http,https" index="0" /> |
| 204 | <constructor-arg index="1" type="long" |
| 205 | value="#{T(org.apache.commons.validator.routines.UrlValidator).ALLOW_LOCAL_URLS + |
| 206 | T(org.apache.commons.validator.routines.UrlValidator).NO_FRAGMENTS}" /> |
| 207 | </bean> |
| 208 | <bean id="urlValidator" |
| 209 | class="org.apache.commons.validator.routines.UrlValidator"> |
| 210 | <constructor-arg value="http,https" /> |
| 211 | </bean> |
| 212 | |
| 213 | <!-- Rewrite --> |
| 214 | <bean id="foundryRewrite" |
| 215 | class="de.ids_mannheim.korap.rewrite.FoundryRewrite" /> |
margaretha | c105e2f | 2024-12-19 09:55:46 +0100 | [diff] [blame^] | 216 | <bean id="availabilityRewrite" |
| 217 | class="de.ids_mannheim.korap.rewrite.AvailabilityRewrite" /> |
margaretha | 46e2c95 | 2024-05-23 09:09:54 +0200 | [diff] [blame] | 218 | <bean id="virtualCorpusRewrite" |
| 219 | class="de.ids_mannheim.korap.rewrite.VirtualCorpusRewrite" /> |
margaretha | 46e2c95 | 2024-05-23 09:09:54 +0200 | [diff] [blame] | 220 | <bean id="queryReferenceRewrite" |
| 221 | class="de.ids_mannheim.korap.rewrite.QueryReferenceRewrite" /> |
| 222 | |
| 223 | <util:list id="rewriteTasks" |
| 224 | value-type="de.ids_mannheim.korap.rewrite.RewriteTask"> |
margaretha | 46e2c95 | 2024-05-23 09:09:54 +0200 | [diff] [blame] | 225 | <ref bean="foundryRewrite" /> |
margaretha | c105e2f | 2024-12-19 09:55:46 +0100 | [diff] [blame^] | 226 | <ref bean="availabilityRewrite" /> |
margaretha | 46e2c95 | 2024-05-23 09:09:54 +0200 | [diff] [blame] | 227 | <ref bean="virtualCorpusRewrite" /> |
| 228 | <ref bean="queryReferenceRewrite" /> |
| 229 | </util:list> |
| 230 | |
| 231 | <bean id="rewriteHandler" |
| 232 | class="de.ids_mannheim.korap.rewrite.RewriteHandler"> |
| 233 | <constructor-arg ref="rewriteTasks" /> |
| 234 | </bean> |
| 235 | |
| 236 | <bean id="kustvaktResponseHandler" |
| 237 | class="de.ids_mannheim.korap.web.KustvaktResponseHandler"> |
| 238 | </bean> |
| 239 | |
| 240 | <!-- OAuth --> |
| 241 | <bean id="oauth2ResponseHandler" |
| 242 | class="de.ids_mannheim.korap.web.OAuth2ResponseHandler"> |
| 243 | </bean> |
| 244 | |
| 245 | <bean name="kustvakt_encryption" |
| 246 | class="de.ids_mannheim.korap.encryption.KustvaktEncryption"> |
| 247 | <constructor-arg ref="kustvakt_config" /> |
| 248 | </bean> |
| 249 | |
| 250 | <!-- authentication providers to use --> |
| 251 | <bean id="basic_auth" |
| 252 | class="de.ids_mannheim.korap.authentication.BasicAuthentication" /> |
| 253 | |
| 254 | |
| 255 | <bean id="session_auth" |
| 256 | class="de.ids_mannheim.korap.authentication.SessionAuthentication"> |
| 257 | <constructor-arg |
| 258 | type="de.ids_mannheim.korap.config.KustvaktConfiguration" |
| 259 | ref="kustvakt_config" /> |
| 260 | <constructor-arg |
| 261 | type="de.ids_mannheim.korap.interfaces.EncryptionIface" |
| 262 | ref="kustvakt_encryption" /> |
| 263 | </bean> |
| 264 | |
| 265 | <bean id="oauth2_auth" |
| 266 | class="de.ids_mannheim.korap.authentication.OAuth2Authentication" /> |
| 267 | |
| 268 | |
| 269 | <util:list id="kustvakt_authproviders" |
| 270 | value-type="de.ids_mannheim.korap.interfaces.AuthenticationIface"> |
| 271 | <ref bean="basic_auth" /> |
| 272 | <ref bean="session_auth" /> |
| 273 | <ref bean="oauth2_auth" /> |
| 274 | </util:list> |
| 275 | |
| 276 | <!-- specify type for constructor argument --> |
| 277 | <bean id="authenticationManager" |
| 278 | class="de.ids_mannheim.korap.authentication.KustvaktAuthenticationManager"> |
| 279 | <constructor-arg |
| 280 | type="de.ids_mannheim.korap.interfaces.EncryptionIface" |
| 281 | ref="kustvakt_encryption" /> |
| 282 | <constructor-arg ref="kustvakt_config" /> |
| 283 | <!-- inject authentication providers to use --> |
| 284 | <property name="providers" ref="kustvakt_authproviders" /> |
| 285 | </bean> |
| 286 | |
| 287 | <!-- todo: if db interfaces not loaded via spring, does transaction even |
| 288 | work then? --> |
| 289 | <!-- the transactional advice (i.e. what 'happens'; see the <aop:advisor/> |
| 290 | bean below) --> |
| 291 | <tx:advice id="txAdvice" transaction-manager="txManager"> |
| 292 | <!-- the transactional semantics... --> |
| 293 | <tx:attributes> |
| 294 | <!-- all methods starting with 'get' are read-only --> |
| 295 | <tx:method name="get*" read-only="true" |
| 296 | rollback-for="KorAPException" /> |
| 297 | <!-- other methods use the default transaction settings (see below) --> |
| 298 | <tx:method name="*" rollback-for="KorAPException" /> |
| 299 | </tx:attributes> |
| 300 | </tx:advice> |
| 301 | |
| 302 | <!-- ensure that the above transactional advice runs for any execution of |
| 303 | an operation defined by the service interface --> |
| 304 | <aop:config> |
| 305 | <aop:pointcut id="service" |
| 306 | expression="execution(* de.ids_mannheim.korap.interfaces.db.*.*(..))" /> |
| 307 | <aop:advisor advice-ref="txAdvice" pointcut-ref="service" /> |
| 308 | </aop:config> |
| 309 | |
| 310 | <!-- similarly, don't forget the PlatformTransactionManager --> |
| 311 | <bean id="txManager" |
| 312 | class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> |
| 313 | <property name="dataSource" ref="dataSource" /> |
| 314 | </bean> |
| 315 | |
margaretha | 46e2c95 | 2024-05-23 09:09:54 +0200 | [diff] [blame] | 316 | </beans> |