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