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