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