Michael Hanl | ca740d7 | 2015-06-16 10:04:58 +0200 | [diff] [blame] | 1 | <?xml version="1.0" encoding="UTF-8"?> |
| 2 | <beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
margaretha | 14503cd | 2017-09-08 15:35:24 +0200 | [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 | 543f200 | 2017-07-14 00:27:15 +0200 | [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-4.0.xsd |
| 12 | http://www.springframework.org/schema/tx |
| 13 | http://www.springframework.org/schema/tx/spring-tx-4.0.xsd |
| 14 | http://www.springframework.org/schema/aop |
| 15 | http://www.springframework.org/schema/aop/spring-aop-4.0.xsd |
| 16 | http://www.springframework.org/schema/context |
| 17 | http://www.springframework.org/schema/context/spring-context-4.0.xsd |
| 18 | http://www.springframework.org/schema/util |
| 19 | http://www.springframework.org/schema/util/spring-util-4.0.xsd"> |
| 20 | |
| 21 | <context:component-scan base-package="de.ids_mannheim.korap" /> |
| 22 | <context:annotation-config /> |
| 23 | |
margaretha | ade7d4a | 2017-07-20 19:53:35 +0200 | [diff] [blame] | 24 | <!-- <bean id="test" class="de.ids_mannheim.korap.web.Test"> |
| 25 | <property name="config" ref="kustvakt_config" /> |
| 26 | </bean> --> |
| 27 | |
margaretha | 543f200 | 2017-07-14 00:27:15 +0200 | [diff] [blame] | 28 | <bean id="props" |
| 29 | class="org.springframework.beans.factory.config.PropertiesFactoryBean"> |
| 30 | <property name="ignoreResourceNotFound" value="true" /> |
| 31 | <property name="locations"> |
| 32 | <array> |
| 33 | <value>classpath:kustvakt.conf</value> |
| 34 | <value>file:./kustvakt.conf</value> |
| 35 | </array> |
| 36 | </property> |
| 37 | </bean> |
| 38 | |
| 39 | <bean id="placeholders" |
| 40 | class="org.springframework.context.support.PropertySourcesPlaceholderConfigurer"> |
| 41 | <property name="ignoreResourceNotFound" value="true" /> |
| 42 | <property name="locations"> |
| 43 | <array> |
| 44 | <value>classpath:jdbc.properties</value> |
margaretha | ea68a0a | 2017-09-21 03:09:49 +0200 | [diff] [blame] | 45 | <value>file:./jdbc.properties</value> |
margaretha | 543f200 | 2017-07-14 00:27:15 +0200 | [diff] [blame] | 46 | <value>classpath:hibernate.properties</value> |
margaretha | ade7d4a | 2017-07-20 19:53:35 +0200 | [diff] [blame] | 47 | <value>classpath:kustvakt.conf</value> |
margaretha | 14503cd | 2017-09-08 15:35:24 +0200 | [diff] [blame] | 48 | <value>file:./kustvakt.conf</value> |
margaretha | 543f200 | 2017-07-14 00:27:15 +0200 | [diff] [blame] | 49 | </array> |
| 50 | </property> |
| 51 | </bean> |
| 52 | |
| 53 | <bean id='cacheManager' class='org.springframework.cache.ehcache.EhCacheCacheManager' |
| 54 | p:cacheManager-ref='ehcache' /> |
| 55 | |
| 56 | <bean id='ehcache' |
| 57 | class='org.springframework.cache.ehcache.EhCacheManagerFactoryBean' |
| 58 | p:configLocation='classpath:ehcache.xml' p:shared='true' /> |
| 59 | |
| 60 | <!-- props are injected from default-config.xml --> |
| 61 | <bean id="kustvakt_config" class="de.ids_mannheim.korap.config.KustvaktConfiguration"> |
margaretha | f68daa6 | 2017-09-21 02:11:24 +0200 | [diff] [blame] | 62 | <constructor-arg name="properties" ref="props" /> |
margaretha | 543f200 | 2017-07-14 00:27:15 +0200 | [diff] [blame] | 63 | </bean> |
| 64 | |
| 65 | <!--class="org.apache.commons.dbcp2.BasicDataSource" --> |
| 66 | <!-- org.springframework.jdbc.datasource.SingleConnectionDataSource --> |
| 67 | <bean id="dataSource" class="org.apache.commons.dbcp2.BasicDataSource" |
| 68 | lazy-init="true"> |
| 69 | <property name="driverClassName" value="${jdbc.driverClassName}" /> |
| 70 | <property name="url" value="${jdbc.url}" /> |
| 71 | <property name="username" value="${jdbc.username}" /> |
| 72 | <property name="password" value="${jdbc.password}" /> |
| 73 | <!-- relevant for single connection datasource and sqlite --> |
| 74 | <!-- <property name="suppressClose"> <value>true</value> </property> --> |
| 75 | <!--<property name="initialSize" value="2"/> --> |
| 76 | <property name="maxTotal" value="4" /> |
| 77 | <property name="maxIdle" value="2" /> |
| 78 | <property name="minIdle" value="1" /> |
| 79 | <property name="maxWaitMillis" value="15000" /> |
| 80 | <!--<property name="poolPreparedStatements" value="true"/> --> |
| 81 | </bean> |
| 82 | |
| 83 | <bean id="sqliteDataSource" |
| 84 | class="org.springframework.jdbc.datasource.SingleConnectionDataSource" |
| 85 | lazy-init="true"> |
| 86 | <property name="driverClassName" value="${jdbc.driverClassName}" /> |
| 87 | <property name="url" value="${jdbc.url}" /> |
| 88 | <property name="username" value="${jdbc.username}" /> |
| 89 | <property name="password" value="${jdbc.password}" /> |
| 90 | <!-- relevant for single connection datasource and sqlite --> |
| 91 | <property name="suppressClose"> |
| 92 | <value>true</value> |
| 93 | </property> |
| 94 | <!--<property name="initialSize" value="2"/> --> |
| 95 | <!--<property name="poolPreparedStatements" value="true"/> --> |
| 96 | </bean> |
| 97 | |
| 98 | <!-- to configure database for sqlite, mysql, etc. migrations --> |
| 99 | <bean id="flyway" class="org.flywaydb.core.Flyway" init-method="migrate"> |
| 100 | <property name="baselineOnMigrate" value="false" /> |
margaretha | ecbe72d | 2017-07-26 17:13:32 +0200 | [diff] [blame] | 101 | <!-- <property name="validateOnMigrate" value="false" /> --> |
| 102 | <!-- <property name="cleanOnValidationError" value="true" /> --> |
margaretha | 543f200 | 2017-07-14 00:27:15 +0200 | [diff] [blame] | 103 | <property name="locations" value="${jdbc.schemaPath}" /> |
margaretha | 6240a6e | 2017-09-21 13:16:17 +0200 | [diff] [blame] | 104 | <!-- <property name="dataSource" ref="dataSource" /> --> |
| 105 | <property name="dataSource" ref="sqliteDataSource" /> |
margaretha | 543f200 | 2017-07-14 00:27:15 +0200 | [diff] [blame] | 106 | </bean> |
margaretha | f18298b | 2017-09-14 22:14:32 +0200 | [diff] [blame] | 107 | |
| 108 | |
margaretha | 543f200 | 2017-07-14 00:27:15 +0200 | [diff] [blame] | 109 | <bean id="kustvakt_db" class="de.ids_mannheim.korap.handlers.JDBCClient"> |
| 110 | <constructor-arg index="0" ref="dataSource" /> |
| 111 | <!-- deprecated property --> |
| 112 | <property name="database" value="${jdbc.database}" /> |
| 113 | </bean> |
| 114 | |
| 115 | <bean id="entityManagerFactory" |
| 116 | class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"> |
| 117 | <property name="dataSource" ref="dataSource" /> |
| 118 | <property name="packagesToScan" value="de.ids_mannheim.korap.entity" /> |
| 119 | <property name="jpaVendorAdapter"> |
| 120 | <bean id="jpaVendorAdapter" |
| 121 | class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"> |
| 122 | <property name="databasePlatform" value="${hibernate.dialect}" /> |
| 123 | </bean> |
| 124 | </property> |
| 125 | <property name="jpaProperties"> |
| 126 | <props> |
| 127 | <prop key="hibernate.dialect">${hibernate.dialect}</prop> |
| 128 | <prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop> |
| 129 | <prop key="hibernate.show_sql">${hibernate.show_sql}</prop> |
| 130 | <prop key="hibernate.cache.use_query_cache">${hibernate.cache.use_query_cache}</prop> |
| 131 | <prop key="hibernate.cache.use_second_level_cache">${hibernate.cache.use_second_level_cache} |
| 132 | </prop> |
| 133 | <prop key="hibernate.cache.provider_class">${hibernate.cache.provider}</prop> |
| 134 | <prop key="hibernate.cache.region.factory_class">${hibernate.cache.region.factory}</prop> |
| 135 | <!-- <prop key="net.sf.ehcache.configurationResourceName">classpath:ehcache.xml</prop> --> |
| 136 | </props> |
| 137 | </property> |
| 138 | </bean> |
| 139 | |
| 140 | <tx:annotation-driven proxy-target-class="true" |
| 141 | transaction-manager="transactionManager" /> |
| 142 | <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"> |
| 143 | <property name="entityManagerFactory" ref="entityManagerFactory" /> |
| 144 | </bean> |
| 145 | |
| 146 | <bean id="transactionTemplate" |
| 147 | class="org.springframework.transaction.support.TransactionTemplate"> |
| 148 | <constructor-arg ref="transactionManager" /> |
| 149 | </bean> |
| 150 | |
margaretha | ade7d4a | 2017-07-20 19:53:35 +0200 | [diff] [blame] | 151 | <!-- Data access objects --> |
| 152 | <bean id="resourceDao" class="de.ids_mannheim.korap.dao.ResourceDao"/> |
| 153 | <!-- <bean id="annotationDao" class="de.ids_mannheim.korap.dao.AnnotationDao"/> --> |
| 154 | |
| 155 | <!-- Krill --> |
| 156 | <bean id="search_krill" class="de.ids_mannheim.korap.web.SearchKrill"> |
| 157 | <constructor-arg value="${krill.indexDir}"/> |
margaretha | 543f200 | 2017-07-14 00:27:15 +0200 | [diff] [blame] | 158 | </bean> |
| 159 | |
| 160 | <bean id="kustvakt_auditing" class="de.ids_mannheim.korap.handlers.JDBCAuditing"> |
| 161 | <constructor-arg ref="kustvakt_db" /> |
| 162 | </bean> |
| 163 | |
| 164 | <bean id="kustvakt_userdb" class="de.ids_mannheim.korap.handlers.EntityDao"> |
| 165 | <constructor-arg ref="kustvakt_db" /> |
| 166 | </bean> |
| 167 | |
| 168 | <bean id="kustvakt_admindb" class="de.ids_mannheim.korap.handlers.AdminDao"> |
| 169 | <constructor-arg ref="kustvakt_db" /> |
| 170 | </bean> |
| 171 | |
| 172 | <bean id="resource_provider" class="de.ids_mannheim.korap.handlers.ResourceDao"> |
| 173 | <constructor-arg ref="kustvakt_db" /> |
| 174 | </bean> |
| 175 | |
| 176 | <bean id="document_provider" class="de.ids_mannheim.korap.handlers.DocumentDao"> |
| 177 | <constructor-arg ref="kustvakt_db" /> |
| 178 | </bean> |
| 179 | |
| 180 | <bean id="kustvakt_policies" class="de.ids_mannheim.korap.security.ac.PolicyDao"> |
| 181 | <constructor-arg ref="kustvakt_db" /> |
| 182 | </bean> |
| 183 | |
| 184 | <bean name="kustvakt_encryption" |
| 185 | class="de.ids_mannheim.korap.interfaces.defaults.KustvaktEncryption"> |
| 186 | <constructor-arg ref="kustvakt_config" /> |
| 187 | </bean> |
| 188 | |
| 189 | <!-- authentication providers to use --> |
| 190 | <bean id="api_auth" class="de.ids_mannheim.korap.security.auth.APIAuthentication"> |
| 191 | <constructor-arg type="de.ids_mannheim.korap.config.KustvaktConfiguration" |
| 192 | ref="kustvakt_config" /> |
| 193 | </bean> |
| 194 | |
| 195 | <bean id="openid_auth" |
| 196 | class="de.ids_mannheim.korap.security.auth.OpenIDconnectAuthentication"> |
| 197 | <constructor-arg type="de.ids_mannheim.korap.config.KustvaktConfiguration" |
| 198 | ref="kustvakt_config" /> |
| 199 | <constructor-arg |
| 200 | type="de.ids_mannheim.korap.interfaces.db.PersistenceClient" ref="kustvakt_db" /> |
| 201 | </bean> |
| 202 | |
| 203 | <bean id="basic_auth" class="de.ids_mannheim.korap.security.auth.BasicHttpAuth" /> |
Michael Hanl | e4fc775 | 2016-02-17 11:41:18 +0100 | [diff] [blame] | 204 | |
| 205 | |
margaretha | 543f200 | 2017-07-14 00:27:15 +0200 | [diff] [blame] | 206 | <bean id="session_auth" |
| 207 | class="de.ids_mannheim.korap.security.auth.SessionAuthentication"> |
| 208 | <constructor-arg type="de.ids_mannheim.korap.config.KustvaktConfiguration" |
| 209 | ref="kustvakt_config" /> |
| 210 | <constructor-arg type="de.ids_mannheim.korap.interfaces.EncryptionIface" |
| 211 | ref="kustvakt_encryption" /> |
| 212 | </bean> |
Michael Hanl | ca740d7 | 2015-06-16 10:04:58 +0200 | [diff] [blame] | 213 | |
margaretha | 543f200 | 2017-07-14 00:27:15 +0200 | [diff] [blame] | 214 | <util:list id="kustvakt_authproviders" |
| 215 | value-type="de.ids_mannheim.korap.interfaces.AuthenticationIface"> |
| 216 | <ref bean="basic_auth" /> |
| 217 | <ref bean="session_auth" /> |
| 218 | <ref bean="api_auth" /> |
| 219 | <ref bean="openid_auth" /> |
| 220 | </util:list> |
Michael Hanl | 72c7b83 | 2015-09-03 08:42:15 +0200 | [diff] [blame] | 221 | |
| 222 | |
margaretha | 543f200 | 2017-07-14 00:27:15 +0200 | [diff] [blame] | 223 | <bean id="userdata_details" class="de.ids_mannheim.korap.handlers.UserDetailsDao"> |
| 224 | <constructor-arg ref="kustvakt_db" /> |
| 225 | </bean> |
Michael Hanl | 72c7b83 | 2015-09-03 08:42:15 +0200 | [diff] [blame] | 226 | |
margaretha | 543f200 | 2017-07-14 00:27:15 +0200 | [diff] [blame] | 227 | <bean id="userdata_settings" class="de.ids_mannheim.korap.handlers.UserSettingsDao"> |
| 228 | <constructor-arg ref="kustvakt_db" /> |
| 229 | </bean> |
| 230 | |
| 231 | <util:list id="kustvakt_userdata" |
| 232 | value-type="de.ids_mannheim.korap.interfaces.db.UserdataDbIface"> |
| 233 | <ref bean="userdata_details" /> |
| 234 | <ref bean="userdata_settings" /> |
| 235 | </util:list> |
Michael Hanl | 72c7b83 | 2015-09-03 08:42:15 +0200 | [diff] [blame] | 236 | |
Michael Hanl | daf8660 | 2016-05-12 14:31:52 +0200 | [diff] [blame] | 237 | |
margaretha | 543f200 | 2017-07-14 00:27:15 +0200 | [diff] [blame] | 238 | <util:list id="kustvakt_resources" |
| 239 | value-type="de.ids_mannheim.korap.interfaces.db.ResourceOperationIface"> |
| 240 | <ref bean="document_provider" /> |
| 241 | <ref bean="resource_provider" /> |
| 242 | </util:list> |
Michael Hanl | f8fcc7a | 2016-06-03 17:41:07 +0200 | [diff] [blame] | 243 | |
margaretha | 543f200 | 2017-07-14 00:27:15 +0200 | [diff] [blame] | 244 | <!-- specify type for constructor argument --> |
| 245 | <bean id="kustvakt_authenticationmanager" |
| 246 | class="de.ids_mannheim.korap.security.auth.KustvaktAuthenticationManager"> |
| 247 | <constructor-arg |
| 248 | type="de.ids_mannheim.korap.interfaces.db.EntityHandlerIface" ref="kustvakt_userdb" /> |
| 249 | <constructor-arg |
| 250 | type="de.ids_mannheim.korap.interfaces.db.AdminHandlerIface" ref="kustvakt_admindb" /> |
| 251 | <constructor-arg type="de.ids_mannheim.korap.interfaces.EncryptionIface" |
| 252 | ref="kustvakt_encryption" /> |
| 253 | <constructor-arg ref="kustvakt_config" /> |
| 254 | <constructor-arg type="de.ids_mannheim.korap.interfaces.db.AuditingIface" |
| 255 | ref="kustvakt_auditing" /> |
| 256 | <constructor-arg ref="kustvakt_userdata" /> |
| 257 | <!-- inject authentication providers to use --> |
| 258 | <property name="providers" ref="kustvakt_authproviders" /> |
| 259 | </bean> |
Michael Hanl | daf8660 | 2016-05-12 14:31:52 +0200 | [diff] [blame] | 260 | |
margaretha | 543f200 | 2017-07-14 00:27:15 +0200 | [diff] [blame] | 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> |
Michael Hanl | daf8660 | 2016-05-12 14:31:52 +0200 | [diff] [blame] | 274 | |
margaretha | 543f200 | 2017-07-14 00:27:15 +0200 | [diff] [blame] | 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> |
Michael Hanl | f8fcc7a | 2016-06-03 17:41:07 +0200 | [diff] [blame] | 282 | |
margaretha | 543f200 | 2017-07-14 00:27:15 +0200 | [diff] [blame] | 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> |
margaretha | f68daa6 | 2017-09-21 02:11:24 +0200 | [diff] [blame] | 288 | |
Michael Hanl | ca740d7 | 2015-06-16 10:04:58 +0200 | [diff] [blame] | 289 | </beans> |