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> |
| 47 | |
| 48 | <bean id='cacheManager' class='org.springframework.cache.ehcache.EhCacheCacheManager' |
| 49 | p:cacheManager-ref='ehcache' /> |
| 50 | |
| 51 | <bean id='ehcache' |
| 52 | class='org.springframework.cache.ehcache.EhCacheManagerFactoryBean' |
| 53 | p:configLocation='classpath:ehcache.xml' p:shared='true' /> |
| 54 | |
| 55 | <bean id="dataSource" class="org.apache.commons.dbcp2.BasicDataSource" |
| 56 | lazy-init="true"> |
| 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 | |
| 88 | <bean id="c3p0DataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" |
| 89 | destroy-method="close"> |
| 90 | <property name="driverClass" value="${jdbc.driverClassName}" /> |
| 91 | <property name="jdbcUrl" value="${jdbc.url}" /> |
| 92 | <property name="user" value="${jdbc.username}" /> |
| 93 | <property name="password" value="${jdbc.password}" /> |
| 94 | <property name="maxPoolSize" value="4" /> |
| 95 | <property name="minPoolSize" value="1" /> |
| 96 | <property name="maxStatements" value="1" /> |
| 97 | <property name="testConnectionOnCheckout" value="true" /> |
| 98 | </bean> |
| 99 | |
| 100 | <!-- to configure database for sqlite, mysql, etc. migrations --> |
| 101 | <bean id="flywayConfig" 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" value="#{'${jdbc.schemaPath}'.split(',')}"/> |
| 107 | <property name="dataSource" ref="sqliteDataSource" /> |
| 108 | <!-- <property name="dataSource" ref="dataSource" /> --> |
| 109 | <property name="outOfOrder" value="true" /> |
| 110 | </bean> |
| 111 | |
| 112 | <bean id="flyway" class="org.flywaydb.core.Flyway" init-method="migrate"> |
| 113 | <constructor-arg ref="flywayConfig"/> |
| 114 | </bean> |
| 115 | |
| 116 | |
| 117 | <bean id="kustvakt_db" class="de.ids_mannheim.korap.handlers.JDBCClient"> |
| 118 | <!-- <constructor-arg index="0" ref="dataSource" /> --> |
| 119 | <constructor-arg index="0" ref="sqliteDataSource" /> |
| 120 | <property name="database" value="${jdbc.database}" /> |
| 121 | </bean> |
| 122 | |
| 123 | <bean id="entityManagerFactory" |
| 124 | class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"> |
| 125 | <!-- <property name="dataSource" ref="dataSource" /> --> |
| 126 | <property name="dataSource" ref="sqliteDataSource" /> |
| 127 | <property name="packagesToScan"> |
| 128 | <array> |
| 129 | <value>de.ids_mannheim.korap.entity</value> |
| 130 | <value>de.ids_mannheim.korap.oauth2.entity</value> |
| 131 | </array> |
| 132 | </property> |
| 133 | <property name="jpaVendorAdapter"> |
| 134 | <bean id="jpaVendorAdapter" |
| 135 | class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"> |
| 136 | <property name="databasePlatform" value="${hibernate.dialect}" /> |
| 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" /> |
| 157 | <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"> |
| 158 | <property name="entityManagerFactory" 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" class="de.ids_mannheim.korap.dao.ResourceDao" /> |
| 169 | <bean id="accessScopeDao" class="de.ids_mannheim.korap.oauth2.dao.AccessScopeDao" /> |
| 170 | <bean id="authorizationDao" class="de.ids_mannheim.korap.oauth2.dao.CachedAuthorizationDaoImpl" /> |
| 171 | |
| 172 | <!-- Services --> |
| 173 | <bean id="scopeService" class="de.ids_mannheim.korap.oauth2.service.OAuth2ScopeServiceImpl" /> |
| 174 | |
| 175 | |
| 176 | <!-- Controller --> |
| 177 | |
| 178 | |
| 179 | <!-- props are injected from default-config.xml --> |
| 180 | <bean id="kustvakt_config" class="de.ids_mannheim.korap.config.FullConfiguration"> |
| 181 | <constructor-arg name="properties" ref="props" /> |
| 182 | </bean> |
| 183 | |
| 184 | <bean id="initializator" class="de.ids_mannheim.de.init.Initializator" |
| 185 | init-method="initTest"> |
| 186 | </bean> |
| 187 | |
| 188 | <!-- Krill --> |
| 189 | <bean id="search_krill" class="de.ids_mannheim.korap.web.SearchKrill"> |
| 190 | <constructor-arg value="${krill.indexDir}" /> |
| 191 | </bean> |
| 192 | |
| 193 | <!-- Validator --> |
| 194 | <bean id="validator" class="de.ids_mannheim.korap.validator.ApacheValidator"/> |
| 195 | |
| 196 | <!-- URLValidator --> |
| 197 | <bean id="redirectURIValidator" class="org.apache.commons.validator.routines.UrlValidator"> |
| 198 | <constructor-arg value="http,https" index="0" /> |
| 199 | <constructor-arg index="1" type="long" |
| 200 | value="#{T(org.apache.commons.validator.routines.UrlValidator).ALLOW_LOCAL_URLS + |
| 201 | T(org.apache.commons.validator.routines.UrlValidator).NO_FRAGMENTS}"/> |
| 202 | </bean> |
| 203 | <bean id="urlValidator" class="org.apache.commons.validator.routines.UrlValidator"> |
| 204 | <constructor-arg value="http,https" /> |
| 205 | </bean> |
| 206 | |
| 207 | <!-- Rewrite --> |
| 208 | <bean id="foundryRewrite" class="de.ids_mannheim.korap.rewrite.FoundryRewrite"/> |
| 209 | <bean id="collectionRewrite" class="de.ids_mannheim.korap.rewrite.CollectionRewrite"/> |
| 210 | <bean id="collectionCleanRewrite" class="de.ids_mannheim.korap.rewrite.CollectionCleanRewrite"/> |
| 211 | <bean id="virtualCorpusRewrite" class="de.ids_mannheim.korap.rewrite.VirtualCorpusRewrite"/> |
| 212 | <bean id="collectionConstraint" class="de.ids_mannheim.korap.rewrite.CollectionConstraint"/> |
| 213 | <bean id="queryReferenceRewrite" class="de.ids_mannheim.korap.rewrite.QueryReferenceRewrite"/> |
| 214 | |
| 215 | <util:list id="rewriteTasks" |
| 216 | value-type="de.ids_mannheim.korap.rewrite.RewriteTask"> |
| 217 | <!-- <ref bean="collectionConstraint" /> |
| 218 | <ref bean="collectionCleanRewrite" /> --> |
| 219 | <ref bean="foundryRewrite" /> |
| 220 | <!-- <ref bean="collectionRewrite" /> --> |
| 221 | <ref bean="virtualCorpusRewrite" /> |
| 222 | <ref bean="queryReferenceRewrite" /> |
| 223 | </util:list> |
| 224 | |
| 225 | <bean id="rewriteHandler" class="de.ids_mannheim.korap.rewrite.RewriteHandler"> |
| 226 | <constructor-arg ref="rewriteTasks"/> |
| 227 | </bean> |
| 228 | |
| 229 | <bean id="kustvakt_auditing" class="de.ids_mannheim.korap.handlers.JDBCAuditing"> |
| 230 | <constructor-arg ref="kustvakt_db" /> |
| 231 | </bean> |
| 232 | |
| 233 | <bean id="kustvaktResponseHandler" class="de.ids_mannheim.korap.web.KustvaktResponseHandler"> |
| 234 | <constructor-arg index="0" name="iface" ref="kustvakt_auditing" /> |
| 235 | </bean> |
| 236 | |
| 237 | <!-- OAuth --> |
| 238 | <bean id="oauth2ResponseHandler" class="de.ids_mannheim.korap.web.OAuth2ResponseHandler"> |
| 239 | <constructor-arg index="0" name="iface" ref="kustvakt_auditing" /> |
| 240 | </bean> |
| 241 | |
| 242 | <bean id="mdGenerator" class="org.apache.oltu.oauth2.as.issuer.MD5Generator"> |
| 243 | </bean> |
| 244 | <bean id="oauthIssuer" class="org.apache.oltu.oauth2.as.issuer.OAuthIssuerImpl"> |
| 245 | <constructor-arg index="0" ref="mdGenerator" /> |
| 246 | </bean> |
| 247 | |
| 248 | <bean id="kustvakt_userdb" class="de.ids_mannheim.korap.handlers.EntityDao"> |
| 249 | <constructor-arg ref="kustvakt_db" /> |
| 250 | </bean> |
| 251 | |
| 252 | <bean name="kustvakt_encryption" class="de.ids_mannheim.korap.encryption.KustvaktEncryption"> |
| 253 | <constructor-arg ref="kustvakt_config" /> |
| 254 | </bean> |
| 255 | |
| 256 | <!-- authentication providers to use --> |
| 257 | <bean id="basic_auth" |
| 258 | class="de.ids_mannheim.korap.authentication.BasicAuthentication" /> |
| 259 | |
| 260 | <bean id="oauth2_auth" |
| 261 | class="de.ids_mannheim.korap.authentication.OAuth2Authentication" /> |
| 262 | |
| 263 | |
| 264 | <util:list id="kustvakt_authproviders" |
| 265 | value-type="de.ids_mannheim.korap.interfaces.AuthenticationIface"> |
| 266 | <ref bean="basic_auth" /> |
| 267 | <ref bean="oauth2_auth" /> |
| 268 | </util:list> |
| 269 | |
| 270 | |
| 271 | <bean id="userdata_details" class="de.ids_mannheim.korap.handlers.UserDetailsDao"> |
| 272 | <constructor-arg ref="kustvakt_db" /> |
| 273 | </bean> |
| 274 | |
| 275 | <bean id="userdata_settings" class="de.ids_mannheim.korap.handlers.UserSettingsDao"> |
| 276 | <constructor-arg ref="kustvakt_db" /> |
| 277 | </bean> |
| 278 | |
| 279 | <util:list id="kustvakt_userdata" |
| 280 | value-type="de.ids_mannheim.korap.interfaces.db.UserdataDbIface"> |
| 281 | <ref bean="userdata_details" /> |
| 282 | <ref bean="userdata_settings" /> |
| 283 | </util:list> |
| 284 | |
| 285 | <!-- specify type for constructor argument --> |
| 286 | <bean id="authenticationManager" |
| 287 | class="de.ids_mannheim.korap.authentication.KustvaktAuthenticationManager"> |
| 288 | <constructor-arg type="de.ids_mannheim.korap.interfaces.EntityHandlerIface" |
| 289 | ref="kustvakt_userdb" /> |
| 290 | <constructor-arg type="de.ids_mannheim.korap.interfaces.EncryptionIface" |
| 291 | ref="kustvakt_encryption" /> |
| 292 | <constructor-arg ref="kustvakt_config" /> |
| 293 | <constructor-arg type="de.ids_mannheim.korap.interfaces.db.AuditingIface" |
| 294 | ref="kustvakt_auditing" /> |
| 295 | <constructor-arg ref="kustvakt_userdata" /> |
| 296 | <!-- inject authentication providers to use --> |
| 297 | <property name="providers" ref="kustvakt_authproviders" /> |
| 298 | </bean> |
| 299 | |
| 300 | <!-- todo: if db interfaces not loaded via spring, does transaction even |
| 301 | work then? --> |
| 302 | <!-- the transactional advice (i.e. what 'happens'; see the <aop:advisor/> |
| 303 | bean below) --> |
| 304 | <tx:advice id="txAdvice" transaction-manager="txManager"> |
| 305 | <!-- the transactional semantics... --> |
| 306 | <tx:attributes> |
| 307 | <!-- all methods starting with 'get' are read-only --> |
| 308 | <tx:method name="get*" read-only="true" rollback-for="KorAPException" /> |
| 309 | <!-- other methods use the default transaction settings (see below) --> |
| 310 | <tx:method name="*" rollback-for="KorAPException" /> |
| 311 | </tx:attributes> |
| 312 | </tx:advice> |
| 313 | |
| 314 | <!-- ensure that the above transactional advice runs for any execution of |
| 315 | an operation defined by the service interface --> |
| 316 | <aop:config> |
| 317 | <aop:pointcut id="service" |
| 318 | expression="execution(* de.ids_mannheim.korap.interfaces.db.*.*(..))" /> |
| 319 | <aop:advisor advice-ref="txAdvice" pointcut-ref="service" /> |
| 320 | </aop:config> |
| 321 | |
| 322 | <!-- similarly, don't forget the PlatformTransactionManager --> |
| 323 | <bean id="txManager" |
| 324 | class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> |
| 325 | <property name="dataSource" ref="dataSource" /> |
| 326 | </bean> |
| 327 | |
| 328 | <!-- mail --> |
| 329 | <bean id="authenticator" class="de.ids_mannheim.korap.service.MailAuthenticator"> |
| 330 | <constructor-arg index="0" value="${mail.username}" /> |
| 331 | <constructor-arg index="1" value="${mail.password}" /> |
| 332 | </bean> |
| 333 | <bean id="smtpSession" class="javax.mail.Session" factory-method="getInstance"> |
| 334 | <constructor-arg index="0"> |
| 335 | <props> |
| 336 | <prop key="mail.smtp.submitter">${mail.username}</prop> |
| 337 | <prop key="mail.smtp.auth">${mail.auth}</prop> |
| 338 | <prop key="mail.smtp.host">${mail.host}</prop> |
| 339 | <prop key="mail.smtp.port">${mail.port}</prop> |
| 340 | <prop key="mail.smtp.starttls.enable">${mail.starttls.enable}</prop> |
| 341 | <prop key="mail.smtp.connectiontimeout">${mail.connectiontimeout}</prop> |
| 342 | </props> |
| 343 | </constructor-arg> |
| 344 | <constructor-arg index="1" ref="authenticator" /> |
| 345 | </bean> |
| 346 | <bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl"> |
| 347 | <property name="session" ref="smtpSession" /> |
| 348 | </bean> |
| 349 | <bean id="velocityEngine" class="org.apache.velocity.app.VelocityEngine"> |
| 350 | <constructor-arg index="0"> |
| 351 | <props> |
| 352 | <prop key="resource.loader">class</prop> |
| 353 | <prop key="class.resource.loader.class">org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader |
| 354 | </prop> |
| 355 | </props> |
| 356 | </constructor-arg> |
| 357 | </bean> |
| 358 | </beans> |