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 | 543f200 | 2017-07-14 00:27:15 +0200 | [diff] [blame] | 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:jdbc.properties</value> |
| 38 | <value>classpath:hibernate.properties</value> |
| 39 | <!-- <value>file:./jdbc.properties</value> --> |
| 40 | </array> |
| 41 | </property> |
| 42 | </bean> |
| 43 | |
| 44 | <bean id='cacheManager' class='org.springframework.cache.ehcache.EhCacheCacheManager' |
| 45 | p:cacheManager-ref='ehcache' /> |
| 46 | |
| 47 | <bean id='ehcache' |
| 48 | class='org.springframework.cache.ehcache.EhCacheManagerFactoryBean' |
| 49 | p:configLocation='classpath:ehcache.xml' p:shared='true' /> |
| 50 | |
| 51 | <!-- props are injected from default-config.xml --> |
| 52 | <bean id="kustvakt_config" class="de.ids_mannheim.korap.config.KustvaktConfiguration"> |
| 53 | <property name="properties" ref="props" /> |
| 54 | </bean> |
| 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 | <!-- relevant for single connection datasource and sqlite --> |
| 82 | <property name="suppressClose"> |
| 83 | <value>true</value> |
| 84 | </property> |
| 85 | <!--<property name="initialSize" value="2"/> --> |
| 86 | <!--<property name="poolPreparedStatements" value="true"/> --> |
| 87 | </bean> |
| 88 | |
| 89 | <!-- to configure database for sqlite, mysql, etc. migrations --> |
| 90 | <bean id="flyway" class="org.flywaydb.core.Flyway" init-method="migrate"> |
| 91 | <property name="baselineOnMigrate" value="false" /> |
| 92 | <property name="validateOnMigrate" value="false" /> |
| 93 | <property name="locations" value="${jdbc.schemaPath}" /> |
| 94 | <property name="dataSource" ref="dataSource" /> |
| 95 | </bean> |
| 96 | |
| 97 | <bean id="kustvakt_db" class="de.ids_mannheim.korap.handlers.JDBCClient"> |
| 98 | <constructor-arg index="0" ref="dataSource" /> |
| 99 | <!-- deprecated property --> |
| 100 | <property name="database" value="${jdbc.database}" /> |
| 101 | </bean> |
| 102 | |
| 103 | <bean id="entityManagerFactory" |
| 104 | class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"> |
| 105 | <property name="dataSource" ref="dataSource" /> |
| 106 | <property name="packagesToScan" value="de.ids_mannheim.korap.entity" /> |
| 107 | <property name="jpaVendorAdapter"> |
| 108 | <bean id="jpaVendorAdapter" |
| 109 | class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"> |
| 110 | <property name="databasePlatform" value="${hibernate.dialect}" /> |
| 111 | </bean> |
| 112 | </property> |
| 113 | <property name="jpaProperties"> |
| 114 | <props> |
| 115 | <prop key="hibernate.dialect">${hibernate.dialect}</prop> |
| 116 | <prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop> |
| 117 | <prop key="hibernate.show_sql">${hibernate.show_sql}</prop> |
| 118 | <prop key="hibernate.cache.use_query_cache">${hibernate.cache.use_query_cache}</prop> |
| 119 | <prop key="hibernate.cache.use_second_level_cache">${hibernate.cache.use_second_level_cache} |
| 120 | </prop> |
| 121 | <prop key="hibernate.cache.provider_class">${hibernate.cache.provider}</prop> |
| 122 | <prop key="hibernate.cache.region.factory_class">${hibernate.cache.region.factory}</prop> |
| 123 | <!-- <prop key="net.sf.ehcache.configurationResourceName">classpath:ehcache.xml</prop> --> |
| 124 | </props> |
| 125 | </property> |
| 126 | </bean> |
| 127 | |
| 128 | <tx:annotation-driven proxy-target-class="true" |
| 129 | transaction-manager="transactionManager" /> |
| 130 | <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"> |
| 131 | <property name="entityManagerFactory" ref="entityManagerFactory" /> |
| 132 | </bean> |
| 133 | |
| 134 | <bean id="transactionTemplate" |
| 135 | class="org.springframework.transaction.support.TransactionTemplate"> |
| 136 | <constructor-arg ref="transactionManager" /> |
| 137 | </bean> |
| 138 | |
| 139 | <bean id="resourceDao" class="de.ids_mannheim.korap.dao.ResourceDao"> |
| 140 | </bean> |
| 141 | |
| 142 | <bean id="kustvakt_auditing" class="de.ids_mannheim.korap.handlers.JDBCAuditing"> |
| 143 | <constructor-arg ref="kustvakt_db" /> |
| 144 | </bean> |
| 145 | |
| 146 | <bean id="kustvakt_userdb" class="de.ids_mannheim.korap.handlers.EntityDao"> |
| 147 | <constructor-arg ref="kustvakt_db" /> |
| 148 | </bean> |
| 149 | |
| 150 | <bean id="kustvakt_admindb" class="de.ids_mannheim.korap.handlers.AdminDao"> |
| 151 | <constructor-arg ref="kustvakt_db" /> |
| 152 | </bean> |
| 153 | |
| 154 | <bean id="resource_provider" class="de.ids_mannheim.korap.handlers.ResourceDao"> |
| 155 | <constructor-arg ref="kustvakt_db" /> |
| 156 | </bean> |
| 157 | |
| 158 | <bean id="document_provider" class="de.ids_mannheim.korap.handlers.DocumentDao"> |
| 159 | <constructor-arg ref="kustvakt_db" /> |
| 160 | </bean> |
| 161 | |
| 162 | <bean id="kustvakt_policies" class="de.ids_mannheim.korap.security.ac.PolicyDao"> |
| 163 | <constructor-arg ref="kustvakt_db" /> |
| 164 | </bean> |
| 165 | |
| 166 | <bean name="kustvakt_encryption" |
| 167 | class="de.ids_mannheim.korap.interfaces.defaults.KustvaktEncryption"> |
| 168 | <constructor-arg ref="kustvakt_config" /> |
| 169 | </bean> |
| 170 | |
| 171 | <!-- authentication providers to use --> |
| 172 | <bean id="api_auth" class="de.ids_mannheim.korap.security.auth.APIAuthentication"> |
| 173 | <constructor-arg type="de.ids_mannheim.korap.config.KustvaktConfiguration" |
| 174 | ref="kustvakt_config" /> |
| 175 | </bean> |
| 176 | |
| 177 | <bean id="openid_auth" |
| 178 | class="de.ids_mannheim.korap.security.auth.OpenIDconnectAuthentication"> |
| 179 | <constructor-arg type="de.ids_mannheim.korap.config.KustvaktConfiguration" |
| 180 | ref="kustvakt_config" /> |
| 181 | <constructor-arg |
| 182 | type="de.ids_mannheim.korap.interfaces.db.PersistenceClient" ref="kustvakt_db" /> |
| 183 | </bean> |
| 184 | |
| 185 | <bean id="basic_auth" class="de.ids_mannheim.korap.security.auth.BasicHttpAuth" /> |
Michael Hanl | e4fc775 | 2016-02-17 11:41:18 +0100 | [diff] [blame] | 186 | |
| 187 | |
margaretha | 543f200 | 2017-07-14 00:27:15 +0200 | [diff] [blame] | 188 | <bean id="session_auth" |
| 189 | class="de.ids_mannheim.korap.security.auth.SessionAuthentication"> |
| 190 | <constructor-arg type="de.ids_mannheim.korap.config.KustvaktConfiguration" |
| 191 | ref="kustvakt_config" /> |
| 192 | <constructor-arg type="de.ids_mannheim.korap.interfaces.EncryptionIface" |
| 193 | ref="kustvakt_encryption" /> |
| 194 | </bean> |
Michael Hanl | ca740d7 | 2015-06-16 10:04:58 +0200 | [diff] [blame] | 195 | |
margaretha | 543f200 | 2017-07-14 00:27:15 +0200 | [diff] [blame] | 196 | <util:list id="kustvakt_authproviders" |
| 197 | value-type="de.ids_mannheim.korap.interfaces.AuthenticationIface"> |
| 198 | <ref bean="basic_auth" /> |
| 199 | <ref bean="session_auth" /> |
| 200 | <ref bean="api_auth" /> |
| 201 | <ref bean="openid_auth" /> |
| 202 | </util:list> |
Michael Hanl | 72c7b83 | 2015-09-03 08:42:15 +0200 | [diff] [blame] | 203 | |
| 204 | |
margaretha | 543f200 | 2017-07-14 00:27:15 +0200 | [diff] [blame] | 205 | <bean id="userdata_details" class="de.ids_mannheim.korap.handlers.UserDetailsDao"> |
| 206 | <constructor-arg ref="kustvakt_db" /> |
| 207 | </bean> |
Michael Hanl | 72c7b83 | 2015-09-03 08:42:15 +0200 | [diff] [blame] | 208 | |
margaretha | 543f200 | 2017-07-14 00:27:15 +0200 | [diff] [blame] | 209 | <bean id="userdata_settings" class="de.ids_mannheim.korap.handlers.UserSettingsDao"> |
| 210 | <constructor-arg ref="kustvakt_db" /> |
| 211 | </bean> |
| 212 | |
| 213 | <util:list id="kustvakt_userdata" |
| 214 | value-type="de.ids_mannheim.korap.interfaces.db.UserdataDbIface"> |
| 215 | <ref bean="userdata_details" /> |
| 216 | <ref bean="userdata_settings" /> |
| 217 | </util:list> |
Michael Hanl | 72c7b83 | 2015-09-03 08:42:15 +0200 | [diff] [blame] | 218 | |
Michael Hanl | daf8660 | 2016-05-12 14:31:52 +0200 | [diff] [blame] | 219 | |
margaretha | 543f200 | 2017-07-14 00:27:15 +0200 | [diff] [blame] | 220 | <util:list id="kustvakt_resources" |
| 221 | value-type="de.ids_mannheim.korap.interfaces.db.ResourceOperationIface"> |
| 222 | <ref bean="document_provider" /> |
| 223 | <ref bean="resource_provider" /> |
| 224 | </util:list> |
Michael Hanl | f8fcc7a | 2016-06-03 17:41:07 +0200 | [diff] [blame] | 225 | |
margaretha | 543f200 | 2017-07-14 00:27:15 +0200 | [diff] [blame] | 226 | <!-- specify type for constructor argument --> |
| 227 | <bean id="kustvakt_authenticationmanager" |
| 228 | class="de.ids_mannheim.korap.security.auth.KustvaktAuthenticationManager"> |
| 229 | <constructor-arg |
| 230 | type="de.ids_mannheim.korap.interfaces.db.EntityHandlerIface" ref="kustvakt_userdb" /> |
| 231 | <constructor-arg |
| 232 | type="de.ids_mannheim.korap.interfaces.db.AdminHandlerIface" ref="kustvakt_admindb" /> |
| 233 | <constructor-arg type="de.ids_mannheim.korap.interfaces.EncryptionIface" |
| 234 | ref="kustvakt_encryption" /> |
| 235 | <constructor-arg ref="kustvakt_config" /> |
| 236 | <constructor-arg type="de.ids_mannheim.korap.interfaces.db.AuditingIface" |
| 237 | ref="kustvakt_auditing" /> |
| 238 | <constructor-arg ref="kustvakt_userdata" /> |
| 239 | <!-- inject authentication providers to use --> |
| 240 | <property name="providers" ref="kustvakt_authproviders" /> |
| 241 | </bean> |
Michael Hanl | daf8660 | 2016-05-12 14:31:52 +0200 | [diff] [blame] | 242 | |
margaretha | 543f200 | 2017-07-14 00:27:15 +0200 | [diff] [blame] | 243 | <!-- todo: if db interfaces not loaded via spring, does transaction even |
| 244 | work then? --> |
| 245 | <!-- the transactional advice (i.e. what 'happens'; see the <aop:advisor/> |
| 246 | bean below) --> |
| 247 | <tx:advice id="txAdvice" transaction-manager="txManager"> |
| 248 | <!-- the transactional semantics... --> |
| 249 | <tx:attributes> |
| 250 | <!-- all methods starting with 'get' are read-only --> |
| 251 | <tx:method name="get*" read-only="true" rollback-for="KorAPException" /> |
| 252 | <!-- other methods use the default transaction settings (see below) --> |
| 253 | <tx:method name="*" rollback-for="KorAPException" /> |
| 254 | </tx:attributes> |
| 255 | </tx:advice> |
Michael Hanl | daf8660 | 2016-05-12 14:31:52 +0200 | [diff] [blame] | 256 | |
margaretha | 543f200 | 2017-07-14 00:27:15 +0200 | [diff] [blame] | 257 | <!-- ensure that the above transactional advice runs for any execution of |
| 258 | an operation defined by the service interface --> |
| 259 | <aop:config> |
| 260 | <aop:pointcut id="service" |
| 261 | expression="execution(* de.ids_mannheim.korap.interfaces.db.*.*(..))" /> |
| 262 | <aop:advisor advice-ref="txAdvice" pointcut-ref="service" /> |
| 263 | </aop:config> |
Michael Hanl | f8fcc7a | 2016-06-03 17:41:07 +0200 | [diff] [blame] | 264 | |
margaretha | 543f200 | 2017-07-14 00:27:15 +0200 | [diff] [blame] | 265 | <!-- similarly, don't forget the PlatformTransactionManager --> |
| 266 | <bean id="txManager" |
| 267 | class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> |
| 268 | <property name="dataSource" ref="dataSource" /> |
| 269 | </bean> |
Michael Hanl | ca740d7 | 2015-06-16 10:04:58 +0200 | [diff] [blame] | 270 | </beans> |