margaretha | ceae697 | 2022-05-31 10:57:11 +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" 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-4.0.xsd |
| 9 | http://www.springframework.org/schema/tx |
| 10 | http://www.springframework.org/schema/tx/spring-tx-4.0.xsd |
| 11 | http://www.springframework.org/schema/aop |
| 12 | http://www.springframework.org/schema/aop/spring-aop-4.0.xsd |
| 13 | http://www.springframework.org/schema/context |
| 14 | http://www.springframework.org/schema/context/spring-context-4.0.xsd |
| 15 | http://www.springframework.org/schema/util |
| 16 | http://www.springframework.org/schema/util/spring-util-4.0.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>classpath:kustvakt.conf</value> |
| 27 | <value>file:./kustvakt.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:properties/basic-jdbc.properties</value> |
| 38 | <value>file:./basic-jdbc.properties</value> |
| 39 | <value>classpath:properties/mail.properties</value> |
| 40 | <value>file:./mail.properties</value> |
| 41 | <value>classpath:hibernate.properties</value> |
| 42 | |
| 43 | <value>classpath:kustvakt.conf</value> |
| 44 | <value>file:./kustvakt.conf</value> |
| 45 | </array> |
| 46 | </property> |
| 47 | </bean> |
| 48 | |
| 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' /> |
| 55 | |
| 56 | <!--class="org.apache.commons.dbcp2.BasicDataSource" --> |
| 57 | <!-- org.springframework.jdbc.datasource.SingleConnectionDataSource --> |
| 58 | <bean id="dataSource" class="org.apache.commons.dbcp2.BasicDataSource" |
| 59 | lazy-init="true"> |
| 60 | <property name="driverClassName" value="${jdbc.driverClassName}" /> |
| 61 | <property name="url" value="${jdbc.url}" /> |
| 62 | <property name="username" value="${jdbc.username}" /> |
| 63 | <property name="password" value="${jdbc.password}" /> |
| 64 | <!-- relevant for single connection datasource and sqlite --> |
| 65 | <!-- <property name="suppressClose"> <value>true</value> </property> --> |
| 66 | <!--<property name="initialSize" value="2"/> --> |
| 67 | <property name="maxTotal" value="4" /> |
| 68 | <property name="maxIdle" value="2" /> |
| 69 | <property name="minIdle" value="1" /> |
| 70 | <property name="maxWaitMillis" value="15000" /> |
| 71 | <!--<property name="poolPreparedStatements" value="true"/> --> |
| 72 | </bean> |
| 73 | |
| 74 | <bean id="sqliteDataSource" |
| 75 | class="org.springframework.jdbc.datasource.SingleConnectionDataSource" |
| 76 | lazy-init="true"> |
| 77 | <property name="driverClassName" value="${jdbc.driverClassName}" /> |
| 78 | <property name="url" value="${jdbc.url}" /> |
| 79 | <property name="username" value="${jdbc.username}" /> |
| 80 | <property name="password" value="${jdbc.password}" /> |
| 81 | <property name="connectionProperties"> |
| 82 | <props> |
| 83 | <prop key="date_string_format">yyyy-MM-dd HH:mm:ss</prop> |
| 84 | </props> |
| 85 | </property> |
| 86 | |
| 87 | <!-- relevant for single connection datasource and sqlite --> |
| 88 | <property name="suppressClose"> |
| 89 | <value>true</value> |
| 90 | </property> |
| 91 | <!--<property name="initialSize" value="2"/> --> |
| 92 | <!--<property name="poolPreparedStatements" value="true"/> --> |
| 93 | </bean> |
| 94 | |
| 95 | <!-- to configure database for sqlite, mysql, etc. migrations --> |
| 96 | <bean id="flywayConfig" class="org.flywaydb.core.api.configuration.ClassicConfiguration"> |
| 97 | <property name="baselineOnMigrate" value="true" /> |
| 98 | <!-- <property name="validateOnMigrate" value="false" /> --> |
| 99 | <!-- <property name="cleanOnValidationError" value="true" /> --> |
| 100 | <property name="locations" value="#{'${jdbc.schemaPath}'.split(',')}"/> |
| 101 | <!-- <property name="dataSource" ref="dataSource" /> --> |
| 102 | <property name="dataSource" ref="sqliteDataSource" /> |
| 103 | <property name="outOfOrder" value="true"/> |
| 104 | </bean> |
| 105 | |
| 106 | <bean id="flyway" class="org.flywaydb.core.Flyway" init-method="migrate"> |
| 107 | <constructor-arg ref="flywayConfig"/> |
| 108 | </bean> |
| 109 | |
| 110 | |
| 111 | <bean id="kustvakt_db" class="de.ids_mannheim.korap.handlers.JDBCClient"> |
| 112 | <constructor-arg index="0" ref="dataSource" /> |
| 113 | <!-- deprecated property --> |
| 114 | <property name="database" value="${jdbc.database}" /> |
| 115 | </bean> |
| 116 | |
| 117 | <bean id="entityManagerFactory" |
| 118 | class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean" |
| 119 | depends-on="flyway"> |
| 120 | <!-- <property name="dataSource" ref="dataSource" /> --> |
| 121 | <property name="dataSource" ref="sqliteDataSource" /> |
| 122 | |
| 123 | <property name="packagesToScan"> |
| 124 | <array> |
| 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 | |
| 154 | <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"> |
| 155 | <property name="entityManagerFactory" ref="entityManagerFactory" /> |
| 156 | </bean> |
| 157 | |
| 158 | <bean id="transactionTemplate" |
| 159 | class="org.springframework.transaction.support.TransactionTemplate"> |
| 160 | <constructor-arg ref="transactionManager" /> |
| 161 | </bean> |
| 162 | |
| 163 | <!-- Data access objects --> |
| 164 | <bean id="adminDao" class="de.ids_mannheim.korap.dao.AdminDaoImpl" /> |
| 165 | <bean id="authorizationDao" class="de.ids_mannheim.korap.oauth2.dao.CachedAuthorizationDaoImpl" /> |
| 166 | |
| 167 | <!-- Services --> |
| 168 | <bean id="scopeService" class="de.ids_mannheim.korap.oauth2.service.OAuth2ScopeServiceImpl" /> |
| 169 | |
| 170 | <!-- props are injected from default-config.xml --> |
| 171 | <bean id="kustvakt_config" class="de.ids_mannheim.korap.config.FullConfiguration"> |
| 172 | <constructor-arg name="properties" ref="props" /> |
| 173 | </bean> |
| 174 | |
| 175 | <bean id="initializator" class="de.ids_mannheim.de.init.Initializator" |
| 176 | init-method="init"> |
| 177 | </bean> |
| 178 | |
| 179 | <!-- Krill --> |
| 180 | <bean id="search_krill" class="de.ids_mannheim.korap.web.SearchKrill"> |
| 181 | <constructor-arg value="${krill.indexDir}" /> |
| 182 | </bean> |
| 183 | |
| 184 | <!-- Validator --> |
| 185 | <bean id="validator" class="de.ids_mannheim.korap.validator.ApacheValidator"/> |
| 186 | |
| 187 | <!-- URLValidator --> |
| 188 | <bean id="redirectURIValidator" class="org.apache.commons.validator.routines.UrlValidator"> |
| 189 | <constructor-arg value="http,https" index="0" /> |
| 190 | <constructor-arg index="1" type="long"> |
| 191 | <util:constant |
| 192 | static-field="org.apache.commons.validator.routines.UrlValidator.NO_FRAGMENTS" /> |
| 193 | </constructor-arg> |
| 194 | </bean> |
| 195 | <bean id="urlValidator" class="org.apache.commons.validator.routines.UrlValidator"> |
| 196 | <constructor-arg value="http,https" /> |
| 197 | </bean> |
| 198 | |
| 199 | <!-- Rewrite --> |
| 200 | <bean id="foundryRewrite" class="de.ids_mannheim.korap.rewrite.FoundryRewrite"/> |
| 201 | <bean id="collectionRewrite" class="de.ids_mannheim.korap.rewrite.CollectionRewrite"/> |
| 202 | <bean id="virtualCorpusRewrite" class="de.ids_mannheim.korap.rewrite.VirtualCorpusRewrite"/> |
| 203 | <bean id="queryReferenceRewrite" class="de.ids_mannheim.korap.rewrite.QueryReferenceRewrite"/> |
| 204 | |
| 205 | <util:list id="rewriteTasks" |
| 206 | value-type="de.ids_mannheim.korap.rewrite.RewriteTask"> |
| 207 | <ref bean="foundryRewrite" /> |
| 208 | <ref bean="collectionRewrite" /> |
| 209 | <ref bean="virtualCorpusRewrite" /> |
| 210 | <ref bean="queryReferenceRewrite" /> |
| 211 | </util:list> |
| 212 | |
| 213 | <bean id="rewriteHandler" class="de.ids_mannheim.korap.rewrite.RewriteHandler"> |
| 214 | <constructor-arg ref="rewriteTasks"/> |
| 215 | </bean> |
| 216 | |
| 217 | <bean id="kustvakt_auditing" class="de.ids_mannheim.korap.handlers.JDBCAuditing"> |
| 218 | <constructor-arg ref="kustvakt_db" /> |
| 219 | </bean> |
| 220 | |
| 221 | <bean id="kustvaktResponseHandler" class="de.ids_mannheim.korap.web.KustvaktResponseHandler"> |
| 222 | <constructor-arg index="0" name="iface" ref="kustvakt_auditing" /> |
| 223 | </bean> |
| 224 | |
| 225 | <!-- OAuth --> |
| 226 | <bean id="oauth2ResponseHandler" class="de.ids_mannheim.korap.web.OAuth2ResponseHandler"> |
| 227 | <constructor-arg index="0" name="iface" ref="kustvakt_auditing" /> |
| 228 | </bean> |
| 229 | |
| 230 | <bean id="mdGenerator" class="org.apache.oltu.oauth2.as.issuer.MD5Generator"> |
| 231 | </bean> |
| 232 | <bean id="oauthIssuer" class="org.apache.oltu.oauth2.as.issuer.OAuthIssuerImpl"> |
| 233 | <constructor-arg index="0" ref="mdGenerator" /> |
| 234 | </bean> |
| 235 | |
| 236 | <bean id="kustvakt_userdb" class="de.ids_mannheim.korap.handlers.EntityDao"> |
| 237 | <constructor-arg ref="kustvakt_db" /> |
| 238 | </bean> |
| 239 | |
| 240 | <bean name="kustvakt_encryption" class="de.ids_mannheim.korap.encryption.KustvaktEncryption"> |
| 241 | <constructor-arg ref="kustvakt_config" /> |
| 242 | </bean> |
| 243 | |
| 244 | <!-- authentication providers to use --> |
| 245 | <!-- <bean id="api_auth" class="de.ids_mannheim.korap.authentication.APIAuthentication"> |
| 246 | <constructor-arg type="de.ids_mannheim.korap.config.KustvaktConfiguration" |
| 247 | ref="kustvakt_config" /> </bean> --> |
| 248 | |
| 249 | <bean id="ldap_auth" class="de.ids_mannheim.korap.authentication.LdapAuth3"> |
| 250 | <constructor-arg type="de.ids_mannheim.korap.config.KustvaktConfiguration" |
| 251 | ref="kustvakt_config" /> |
| 252 | </bean> |
| 253 | |
| 254 | <bean id="basic_auth" |
| 255 | class="de.ids_mannheim.korap.authentication.BasicAuthentication" /> |
| 256 | |
| 257 | |
| 258 | <bean id="session_auth" |
| 259 | class="de.ids_mannheim.korap.authentication.SessionAuthentication"> |
| 260 | <constructor-arg type="de.ids_mannheim.korap.config.KustvaktConfiguration" |
| 261 | ref="kustvakt_config" /> |
| 262 | <constructor-arg type="de.ids_mannheim.korap.interfaces.EncryptionIface" |
| 263 | ref="kustvakt_encryption" /> |
| 264 | </bean> |
| 265 | |
| 266 | <bean id="oauth2_auth" |
| 267 | class="de.ids_mannheim.korap.authentication.OAuth2Authentication" /> |
| 268 | |
| 269 | <util:list id="kustvakt_authproviders" |
| 270 | value-type="de.ids_mannheim.korap.interfaces.AuthenticationIface"> |
| 271 | <ref bean="basic_auth" /> |
| 272 | <ref bean="ldap_auth" /> |
| 273 | <!-- |
| 274 | <ref bean="session_auth" /> |
| 275 | <ref bean="api_auth" /> |
| 276 | --> |
| 277 | <ref bean="oauth2_auth" /> |
| 278 | </util:list> |
| 279 | |
| 280 | |
| 281 | <bean id="userdata_details" class="de.ids_mannheim.korap.handlers.UserDetailsDao"> |
| 282 | <constructor-arg ref="kustvakt_db" /> |
| 283 | </bean> |
| 284 | |
| 285 | <bean id="userdata_settings" class="de.ids_mannheim.korap.handlers.UserSettingsDao"> |
| 286 | <constructor-arg ref="kustvakt_db" /> |
| 287 | </bean> |
| 288 | |
| 289 | <util:list id="kustvakt_userdata" |
| 290 | value-type="de.ids_mannheim.korap.interfaces.db.UserdataDbIface"> |
| 291 | <ref bean="userdata_details" /> |
| 292 | <ref bean="userdata_settings" /> |
| 293 | </util:list> |
| 294 | |
| 295 | <!-- specify type for constructor argument --> |
| 296 | <bean id="authenticationManager" |
| 297 | class="de.ids_mannheim.korap.authentication.KustvaktAuthenticationManager"> |
| 298 | <constructor-arg type="de.ids_mannheim.korap.interfaces.EntityHandlerIface" |
| 299 | ref="kustvakt_userdb" /> |
| 300 | <constructor-arg type="de.ids_mannheim.korap.interfaces.EncryptionIface" |
| 301 | ref="kustvakt_encryption" /> |
| 302 | <constructor-arg ref="kustvakt_config" /> |
| 303 | <constructor-arg type="de.ids_mannheim.korap.interfaces.db.AuditingIface" |
| 304 | ref="kustvakt_auditing" /> |
| 305 | <constructor-arg ref="kustvakt_userdata" /> |
| 306 | <!-- inject authentication providers to use --> |
| 307 | <property name="providers" ref="kustvakt_authproviders" /> |
| 308 | </bean> |
| 309 | |
| 310 | <!-- todo: if db interfaces not loaded via spring, does transaction even |
| 311 | work then? --> |
| 312 | <!-- the transactional advice (i.e. what 'happens'; see the <aop:advisor/> |
| 313 | bean below) --> |
| 314 | <tx:advice id="txAdvice" transaction-manager="txManager"> |
| 315 | <!-- the transactional semantics... --> |
| 316 | <tx:attributes> |
| 317 | <!-- all methods starting with 'get' are read-only --> |
| 318 | <tx:method name="get*" read-only="true" rollback-for="KorAPException" /> |
| 319 | <!-- other methods use the default transaction settings (see below) --> |
| 320 | <tx:method name="*" rollback-for="KorAPException" /> |
| 321 | </tx:attributes> |
| 322 | </tx:advice> |
| 323 | |
| 324 | <!-- ensure that the above transactional advice runs for any execution of |
| 325 | an operation defined by the service interface --> |
| 326 | <aop:config> |
| 327 | <aop:pointcut id="service" |
| 328 | expression="execution(* de.ids_mannheim.korap.interfaces.db.*.*(..))" /> |
| 329 | <aop:advisor advice-ref="txAdvice" pointcut-ref="service" /> |
| 330 | </aop:config> |
| 331 | |
| 332 | <!-- similarly, don't forget the PlatformTransactionManager --> |
| 333 | <bean id="txManager" |
| 334 | class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> |
| 335 | <!-- <property name="dataSource" ref="dataSource" /> --> |
| 336 | <property name="dataSource" ref="sqliteDataSource" /> |
| 337 | </bean> |
| 338 | |
| 339 | <!-- mail --> |
| 340 | <bean id="authenticator" class="de.ids_mannheim.korap.service.MailAuthenticator"> |
| 341 | <constructor-arg index="0" value="${mail.username}" /> |
| 342 | <constructor-arg index="1" value="${mail.password}" /> |
| 343 | </bean> |
| 344 | <bean id="smtpSession" class="javax.mail.Session" factory-method="getInstance"> |
| 345 | <constructor-arg index="0"> |
| 346 | <props> |
| 347 | <prop key="mail.smtp.submitter">${mail.username}</prop> |
| 348 | <prop key="mail.smtp.auth">${mail.auth}</prop> |
| 349 | <prop key="mail.smtp.host">${mail.host}</prop> |
| 350 | <prop key="mail.smtp.port">${mail.port}</prop> |
| 351 | <prop key="mail.smtp.starttls.enable">${mail.starttls.enable}</prop> |
| 352 | <prop key="mail.smtp.connectiontimeout">${mail.connectiontimeout}</prop> |
| 353 | </props> |
| 354 | </constructor-arg> |
| 355 | <constructor-arg index="1" ref="authenticator" /> |
| 356 | </bean> |
| 357 | <bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl"> |
| 358 | <property name="username" value="${mail.username}" /> |
| 359 | <property name="password" value="${mail.password}" /> |
| 360 | <property name="session" ref="smtpSession" /> |
| 361 | </bean> |
| 362 | <bean id="velocityEngine" class="org.apache.velocity.app.VelocityEngine"> |
| 363 | <constructor-arg index="0"> |
| 364 | <props> |
| 365 | <prop key="resource.loader">class</prop> |
| 366 | <prop key="class.resource.loader.class">org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader |
| 367 | </prop> |
| 368 | </props> |
| 369 | </constructor-arg> |
| 370 | </bean> |
| 371 | </beans> |