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