Michael Hanl | bd852b8 | 2015-11-18 22:17:00 +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" |
| 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:cache="http://www.springframework.org/schema/cache" |
| 9 | xsi:schemaLocation="http://www.springframework.org/schema/beans |
| 10 | http://www.springframework.org/schema/beans/spring-beans-4.0.xsd |
| 11 | http://www.springframework.org/schema/tx |
| 12 | http://www.springframework.org/schema/tx/spring-tx-4.0.xsd |
| 13 | |
| 14 | |
| 15 | http://www.springframework.org/schema/aop |
| 16 | http://www.springframework.org/schema/aop/spring-aop-4.0.xsd |
| 17 | http://www.springframework.org/schema/cache |
| 18 | http://www.springframework.org/schema/cache/spring-cache-4.0.xsd |
| 19 | |
| 20 | |
| 21 | http://www.springframework.org/schema/util |
| 22 | http://www.springframework.org/schema/util/spring-util-4.0.xsd"> |
| 23 | |
| 24 | <cache:annotation-driven/> |
| 25 | |
| 26 | <bean id="props" |
| 27 | class="org.springframework.beans.factory.config.PropertiesFactoryBean"> |
| 28 | <property name="ignoreResourceNotFound" value="true"/> |
| 29 | <property name="locations"> |
| 30 | <array> |
| 31 | <value>classpath:kustvakt.conf</value> |
| 32 | <value>file:./kustvakt.conf</value> |
| 33 | </array> |
| 34 | </property> |
| 35 | </bean> |
| 36 | |
| 37 | <bean id="jdbc_props" |
| 38 | class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> |
| 39 | <property name="ignoreResourceNotFound" value="true"/> |
| 40 | <property name="locations"> |
| 41 | <array> |
| 42 | <value>classpath:jdbc.properties</value> |
Michael Hanl | daf8660 | 2016-05-12 14:31:52 +0200 | [diff] [blame] | 43 | <value>file:./jdbc_tests.properties</value> |
Michael Hanl | bd852b8 | 2015-11-18 22:17:00 +0100 | [diff] [blame] | 44 | </array> |
| 45 | </property> |
| 46 | </bean> |
| 47 | |
| 48 | <bean id='cacheManager' |
| 49 | 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' |
| 55 | p:shared='true'/> |
| 56 | |
| 57 | <!-- props are injected from default-config.xml --> |
| 58 | <bean id="kustvakt_config" |
| 59 | class="de.ids_mannheim.korap.config.KustvaktConfiguration"> |
| 60 | <property name="properties" ref="props"/> |
| 61 | </bean> |
| 62 | |
| 63 | <!--class="org.apache.commons.dbcp2.BasicDataSource"--> |
| 64 | <!-- org.springframework.jdbc.datasource.SingleConnectionDataSource --> |
Michael Hanl | daf8660 | 2016-05-12 14:31:52 +0200 | [diff] [blame] | 65 | <!-- org.springframework.jdbc.datasource.DriverManagerDataSource --> |
Michael Hanl | bd852b8 | 2015-11-18 22:17:00 +0100 | [diff] [blame] | 66 | <bean id="dataSource" |
| 67 | class="org.springframework.jdbc.datasource.SingleConnectionDataSource" |
Michael Hanl | daf8660 | 2016-05-12 14:31:52 +0200 | [diff] [blame] | 68 | lazy-init="false"> |
| 69 | <property name="driverClassName" value="org.sqlite.JDBC"/> |
| 70 | <property name="url" value="jdbc:sqlite:tmp_new.sqlite"/> |
| 71 | <!--<property name="initialSize" value="1" />--> |
| 72 | <!--<property name="maxTotal" value="1" />--> |
| 73 | <!--<property name="maxIdle" value="1" />--> |
| 74 | <!--<property name="username" value="${jdbc.username}"/>--> |
| 75 | <!--<property name="password" value="${jdbc.password}"/>--> |
Michael Hanl | efb54c4 | 2016-01-16 18:54:03 +0100 | [diff] [blame] | 76 | <!-- relevant for single connection datasource and sqlite --> |
Michael Hanl | bd852b8 | 2015-11-18 22:17:00 +0100 | [diff] [blame] | 77 | <property name="suppressClose"> |
| 78 | <value>true</value> |
| 79 | </property> |
Michael Hanl | efb54c4 | 2016-01-16 18:54:03 +0100 | [diff] [blame] | 80 | <!--<property name="initialSize" value="2"/>--> |
| 81 | <!--<property name="maxIdle" value="2"/>--> |
| 82 | <!--<property name="poolPreparedStatements" value="true"/>--> |
Michael Hanl | bd852b8 | 2015-11-18 22:17:00 +0100 | [diff] [blame] | 83 | </bean> |
| 84 | |
| 85 | <!-- to configure database for sqlite, mysql, etc. migrations --> |
| 86 | <bean id="flyway" class="org.flywaydb.core.Flyway" init-method="migrate"> |
| 87 | <property name="baselineOnMigrate" value="false"/> |
| 88 | <property name="locations" |
Michael Hanl | daf8660 | 2016-05-12 14:31:52 +0200 | [diff] [blame] | 89 | value="classpath:db.sqlite"/> |
Michael Hanl | bd852b8 | 2015-11-18 22:17:00 +0100 | [diff] [blame] | 90 | <property name="dataSource" ref="dataSource"/> |
| 91 | </bean> |
| 92 | |
| 93 | <bean id="kustvakt_db" |
| 94 | class="de.ids_mannheim.korap.handlers.JDBCClient"> |
| 95 | <constructor-arg index="0" ref="dataSource"/> |
Michael Hanl | daf8660 | 2016-05-12 14:31:52 +0200 | [diff] [blame] | 96 | <property name="database" value="jdbc:sqlite::memory:"/> |
Michael Hanl | bd852b8 | 2015-11-18 22:17:00 +0100 | [diff] [blame] | 97 | </bean> |
| 98 | |
Michael Hanl | e4fc775 | 2016-02-17 11:41:18 +0100 | [diff] [blame] | 99 | <bean id="kustvakt_userdetails" |
| 100 | class="de.ids_mannheim.korap.handlers.UserDetailsDao"> |
| 101 | <constructor-arg ref="kustvakt_db"/> |
| 102 | </bean> |
| 103 | |
| 104 | <bean id="kustvakt_usersettings" |
| 105 | class="de.ids_mannheim.korap.handlers.UserSettingsDao"> |
| 106 | <constructor-arg ref="kustvakt_db"/> |
| 107 | </bean> |
| 108 | |
Michael Hanl | bd852b8 | 2015-11-18 22:17:00 +0100 | [diff] [blame] | 109 | <bean id="kustvakt_auditing" |
| 110 | class="de.ids_mannheim.korap.handlers.JDBCAuditing"> |
| 111 | <constructor-arg ref="kustvakt_db"/> |
| 112 | </bean> |
| 113 | |
| 114 | <bean id="kustvakt_userdb" |
| 115 | class="de.ids_mannheim.korap.handlers.EntityDao"> |
| 116 | <constructor-arg ref="kustvakt_db"/> |
| 117 | </bean> |
| 118 | |
Michael Hanl | 9b84eff | 2016-01-27 17:11:11 +0100 | [diff] [blame] | 119 | <!--<bean id="collectionProvider"--> |
Michael Hanl | daf8660 | 2016-05-12 14:31:52 +0200 | [diff] [blame] | 120 | <!--class="de.ids_mannheim.korap.handlers.CollectionDao">--> |
| 121 | <!--<constructor-arg ref="kustvakt_db"/>--> |
Michael Hanl | 9b84eff | 2016-01-27 17:11:11 +0100 | [diff] [blame] | 122 | <!--</bean>--> |
Michael Hanl | bd852b8 | 2015-11-18 22:17:00 +0100 | [diff] [blame] | 123 | |
| 124 | <!--fixme: change name according to convention --> |
| 125 | <bean id="resourceProvider" |
| 126 | class="de.ids_mannheim.korap.handlers.ResourceDao"> |
| 127 | <constructor-arg ref="kustvakt_db"/> |
| 128 | </bean> |
| 129 | |
| 130 | <bean id="kustvakt_policies" |
| 131 | class="de.ids_mannheim.korap.security.ac.PolicyDao"> |
| 132 | <constructor-arg ref="kustvakt_db"/> |
| 133 | </bean> |
| 134 | |
| 135 | <bean name="kustvakt_encryption" |
| 136 | class="de.ids_mannheim.korap.interfaces.defaults.KustvaktEncryption"> |
| 137 | <constructor-arg ref="kustvakt_config"/> |
| 138 | </bean> |
| 139 | |
| 140 | <!-- authentication providers to use --> |
| 141 | <bean id="api_auth" |
| 142 | class="de.ids_mannheim.korap.security.auth.APIAuthentication"> |
| 143 | <constructor-arg |
| 144 | type="de.ids_mannheim.korap.config.KustvaktConfiguration" |
| 145 | ref="kustvakt_config"/> |
| 146 | </bean> |
| 147 | |
| 148 | <bean id="openid_auth" |
| 149 | class="de.ids_mannheim.korap.security.auth.OpenIDconnectAuthentication"> |
| 150 | <constructor-arg |
| 151 | type="de.ids_mannheim.korap.config.KustvaktConfiguration" |
| 152 | ref="kustvakt_config"/> |
| 153 | <constructor-arg |
| 154 | type="de.ids_mannheim.korap.interfaces.db.PersistenceClient" |
| 155 | ref="kustvakt_db"/> |
| 156 | </bean> |
| 157 | |
| 158 | <bean id="basic_auth" |
| 159 | class="de.ids_mannheim.korap.security.auth.BasicHttpAuth"/> |
| 160 | |
| 161 | |
| 162 | <bean id="session_auth" |
| 163 | class="de.ids_mannheim.korap.security.auth.SessionAuthentication"> |
| 164 | <constructor-arg |
| 165 | type="de.ids_mannheim.korap.config.KustvaktConfiguration" |
| 166 | ref="kustvakt_config"/> |
| 167 | <constructor-arg |
| 168 | type="de.ids_mannheim.korap.interfaces.EncryptionIface" |
| 169 | ref="kustvakt_encryption"/> |
| 170 | </bean> |
| 171 | |
Michael Hanl | daf8660 | 2016-05-12 14:31:52 +0200 | [diff] [blame] | 172 | <util:list id="kustvakt_authproviders" |
Michael Hanl | bd852b8 | 2015-11-18 22:17:00 +0100 | [diff] [blame] | 173 | value-type="de.ids_mannheim.korap.interfaces.AuthenticationIface"> |
| 174 | <ref bean="basic_auth"/> |
| 175 | <ref bean="session_auth"/> |
| 176 | <ref bean="api_auth"/> |
| 177 | <ref bean="openid_auth"/> |
| 178 | </util:list> |
| 179 | |
Michael Hanl | daf8660 | 2016-05-12 14:31:52 +0200 | [diff] [blame] | 180 | <bean id="userdata_details" |
| 181 | class="de.ids_mannheim.korap.handlers.UserDetailsDao"> |
| 182 | <constructor-arg |
| 183 | type="de.ids_mannheim.korap.interfaces.db.PersistenceClient" |
| 184 | ref="kustvakt_db"/> |
| 185 | </bean> |
| 186 | <bean id="userdata_settings" |
| 187 | class="de.ids_mannheim.korap.handlers.UserDetailsDao"> |
| 188 | <constructor-arg |
| 189 | type="de.ids_mannheim.korap.interfaces.db.PersistenceClient" |
| 190 | ref="kustvakt_db"/> |
| 191 | </bean> |
| 192 | |
| 193 | <util:list id="kustvakt_userdata" |
| 194 | value-type="de.ids_mannheim.korap.interfaces.db.UserdataDbIface"> |
| 195 | <ref bean="userdata_details"/> |
| 196 | <ref bean="userdata_settings"/> |
| 197 | </util:list> |
| 198 | |
| 199 | |
Michael Hanl | bd852b8 | 2015-11-18 22:17:00 +0100 | [diff] [blame] | 200 | <!-- specify type for constructor argument --> |
| 201 | <bean id="kustvakt_authenticationmanager" |
| 202 | class="de.ids_mannheim.korap.security.auth.KustvaktAuthenticationManager"> |
| 203 | <constructor-arg |
| 204 | type="de.ids_mannheim.korap.interfaces.db.EntityHandlerIface" |
| 205 | ref="kustvakt_userdb"/> |
| 206 | <constructor-arg type="de.ids_mannheim.korap.interfaces.EncryptionIface" |
| 207 | ref="kustvakt_encryption"/> |
| 208 | <constructor-arg ref="kustvakt_config"/> |
| 209 | <constructor-arg |
| 210 | type="de.ids_mannheim.korap.interfaces.db.AuditingIface" |
| 211 | ref="kustvakt_auditing"/> |
Michael Hanl | daf8660 | 2016-05-12 14:31:52 +0200 | [diff] [blame] | 212 | <constructor-arg ref="kustvakt_userdata"/> |
Michael Hanl | bd852b8 | 2015-11-18 22:17:00 +0100 | [diff] [blame] | 213 | <!-- inject authentication providers to use --> |
Michael Hanl | daf8660 | 2016-05-12 14:31:52 +0200 | [diff] [blame] | 214 | <property name="providers" ref="kustvakt_authproviders"/> |
Michael Hanl | bd852b8 | 2015-11-18 22:17:00 +0100 | [diff] [blame] | 215 | </bean> |
| 216 | |
| 217 | <!-- todo: if db interfaces not loaded via spring, does transaction even work then? --> |
| 218 | <!-- the transactional advice (i.e. what 'happens'; see the <aop:advisor/> bean below) --> |
| 219 | <tx:advice id="txAdvice" transaction-manager="txManager"> |
| 220 | <!-- the transactional semantics... --> |
| 221 | <tx:attributes> |
| 222 | <!-- all methods starting with 'get' are read-only --> |
| 223 | <tx:method name="get*" read-only="true" |
| 224 | rollback-for="KorAPException"/> |
| 225 | <!-- other methods use the default transaction settings (see below) --> |
| 226 | <tx:method name="*" rollback-for="KorAPException"/> |
| 227 | </tx:attributes> |
| 228 | </tx:advice> |
| 229 | |
| 230 | <!-- ensure that the above transactional advice runs for any execution |
| 231 | of an operation defined by the service interface --> |
| 232 | <aop:config> |
| 233 | <aop:pointcut id="service" |
| 234 | expression="execution(* de.ids_mannheim.korap.interfaces.db.*.*(..))"/> |
| 235 | <aop:advisor advice-ref="txAdvice" pointcut-ref="service"/> |
| 236 | </aop:config> |
| 237 | |
| 238 | <!-- similarly, don't forget the PlatformTransactionManager --> |
| 239 | <bean id="txManager" |
| 240 | class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> |
| 241 | <property name="dataSource" ref="dataSource"/> |
| 242 | </bean> |
| 243 | </beans> |