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> |
| 43 | <value>file:./jdbc.properties</value> |
| 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 --> |
| 65 | <bean id="dataSource" |
| 66 | class="org.springframework.jdbc.datasource.SingleConnectionDataSource" |
| 67 | lazy-init="true"> |
| 68 | <property name="driverClassName" value="${jdbc.driverClassName}"/> |
| 69 | <property name="url" value="${jdbc.url}"/> |
| 70 | <property name="username" value="${jdbc.username}"/> |
| 71 | <property name="password" value="${jdbc.password}"/> |
Michael Hanl | efb54c4 | 2016-01-16 18:54:03 +0100 | [diff] [blame] | 72 | <!-- relevant for single connection datasource and sqlite --> |
Michael Hanl | bd852b8 | 2015-11-18 22:17:00 +0100 | [diff] [blame] | 73 | <property name="suppressClose"> |
| 74 | <value>true</value> |
| 75 | </property> |
Michael Hanl | efb54c4 | 2016-01-16 18:54:03 +0100 | [diff] [blame] | 76 | <!--<property name="initialSize" value="2"/>--> |
| 77 | <!--<property name="maxIdle" value="2"/>--> |
| 78 | <!--<property name="poolPreparedStatements" value="true"/>--> |
Michael Hanl | bd852b8 | 2015-11-18 22:17:00 +0100 | [diff] [blame] | 79 | </bean> |
| 80 | |
| 81 | <!-- to configure database for sqlite, mysql, etc. migrations --> |
| 82 | <bean id="flyway" class="org.flywaydb.core.Flyway" init-method="migrate"> |
| 83 | <property name="baselineOnMigrate" value="false"/> |
| 84 | <property name="locations" |
| 85 | value="classpath:${jdbc.schemaPath}"/> |
| 86 | <property name="dataSource" ref="dataSource"/> |
| 87 | </bean> |
| 88 | |
| 89 | <bean id="kustvakt_db" |
| 90 | class="de.ids_mannheim.korap.handlers.JDBCClient"> |
| 91 | <constructor-arg index="0" ref="dataSource"/> |
| 92 | <!-- deprecated property --> |
| 93 | <property name="database" value="${jdbc.database}"/> |
| 94 | </bean> |
| 95 | |
| 96 | <bean id="kustvakt_auditing" |
| 97 | class="de.ids_mannheim.korap.handlers.JDBCAuditing"> |
| 98 | <constructor-arg ref="kustvakt_db"/> |
| 99 | </bean> |
| 100 | |
| 101 | <bean id="kustvakt_userdb" |
| 102 | class="de.ids_mannheim.korap.handlers.EntityDao"> |
| 103 | <constructor-arg ref="kustvakt_db"/> |
| 104 | </bean> |
| 105 | |
Michael Hanl | 9b84eff | 2016-01-27 17:11:11 +0100 | [diff] [blame^] | 106 | <!--<bean id="collectionProvider"--> |
| 107 | <!--class="de.ids_mannheim.korap.handlers.CollectionDao">--> |
| 108 | <!--<constructor-arg ref="kustvakt_db"/>--> |
| 109 | <!--</bean>--> |
Michael Hanl | bd852b8 | 2015-11-18 22:17:00 +0100 | [diff] [blame] | 110 | |
| 111 | <!--fixme: change name according to convention --> |
| 112 | <bean id="resourceProvider" |
| 113 | class="de.ids_mannheim.korap.handlers.ResourceDao"> |
| 114 | <constructor-arg ref="kustvakt_db"/> |
| 115 | </bean> |
| 116 | |
| 117 | <bean id="kustvakt_policies" |
| 118 | class="de.ids_mannheim.korap.security.ac.PolicyDao"> |
| 119 | <constructor-arg ref="kustvakt_db"/> |
| 120 | </bean> |
| 121 | |
| 122 | <bean name="kustvakt_encryption" |
| 123 | class="de.ids_mannheim.korap.interfaces.defaults.KustvaktEncryption"> |
| 124 | <constructor-arg ref="kustvakt_config"/> |
| 125 | </bean> |
| 126 | |
| 127 | <!-- authentication providers to use --> |
| 128 | <bean id="api_auth" |
| 129 | class="de.ids_mannheim.korap.security.auth.APIAuthentication"> |
| 130 | <constructor-arg |
| 131 | type="de.ids_mannheim.korap.config.KustvaktConfiguration" |
| 132 | ref="kustvakt_config"/> |
| 133 | </bean> |
| 134 | |
| 135 | <bean id="openid_auth" |
| 136 | class="de.ids_mannheim.korap.security.auth.OpenIDconnectAuthentication"> |
| 137 | <constructor-arg |
| 138 | type="de.ids_mannheim.korap.config.KustvaktConfiguration" |
| 139 | ref="kustvakt_config"/> |
| 140 | <constructor-arg |
| 141 | type="de.ids_mannheim.korap.interfaces.db.PersistenceClient" |
| 142 | ref="kustvakt_db"/> |
| 143 | </bean> |
| 144 | |
| 145 | <bean id="basic_auth" |
| 146 | class="de.ids_mannheim.korap.security.auth.BasicHttpAuth"/> |
| 147 | |
| 148 | |
| 149 | <bean id="session_auth" |
| 150 | class="de.ids_mannheim.korap.security.auth.SessionAuthentication"> |
| 151 | <constructor-arg |
| 152 | type="de.ids_mannheim.korap.config.KustvaktConfiguration" |
| 153 | ref="kustvakt_config"/> |
| 154 | <constructor-arg |
| 155 | type="de.ids_mannheim.korap.interfaces.EncryptionIface" |
| 156 | ref="kustvakt_encryption"/> |
| 157 | </bean> |
| 158 | |
| 159 | <util:list id="auth_providers" |
| 160 | value-type="de.ids_mannheim.korap.interfaces.AuthenticationIface"> |
| 161 | <ref bean="basic_auth"/> |
| 162 | <ref bean="session_auth"/> |
| 163 | <ref bean="api_auth"/> |
| 164 | <ref bean="openid_auth"/> |
| 165 | </util:list> |
| 166 | |
| 167 | <!-- specify type for constructor argument --> |
| 168 | <bean id="kustvakt_authenticationmanager" |
| 169 | class="de.ids_mannheim.korap.security.auth.KustvaktAuthenticationManager"> |
| 170 | <constructor-arg |
| 171 | type="de.ids_mannheim.korap.interfaces.db.EntityHandlerIface" |
| 172 | ref="kustvakt_userdb"/> |
| 173 | <constructor-arg type="de.ids_mannheim.korap.interfaces.EncryptionIface" |
| 174 | ref="kustvakt_encryption"/> |
| 175 | <constructor-arg ref="kustvakt_config"/> |
| 176 | <constructor-arg |
| 177 | type="de.ids_mannheim.korap.interfaces.db.AuditingIface" |
| 178 | ref="kustvakt_auditing"/> |
| 179 | <!-- inject authentication providers to use --> |
| 180 | <property name="providers" ref="auth_providers"/> |
| 181 | </bean> |
| 182 | |
| 183 | <!-- todo: if db interfaces not loaded via spring, does transaction even work then? --> |
| 184 | <!-- the transactional advice (i.e. what 'happens'; see the <aop:advisor/> bean below) --> |
| 185 | <tx:advice id="txAdvice" transaction-manager="txManager"> |
| 186 | <!-- the transactional semantics... --> |
| 187 | <tx:attributes> |
| 188 | <!-- all methods starting with 'get' are read-only --> |
| 189 | <tx:method name="get*" read-only="true" |
| 190 | rollback-for="KorAPException"/> |
| 191 | <!-- other methods use the default transaction settings (see below) --> |
| 192 | <tx:method name="*" rollback-for="KorAPException"/> |
| 193 | </tx:attributes> |
| 194 | </tx:advice> |
| 195 | |
| 196 | <!-- ensure that the above transactional advice runs for any execution |
| 197 | of an operation defined by the service interface --> |
| 198 | <aop:config> |
| 199 | <aop:pointcut id="service" |
| 200 | expression="execution(* de.ids_mannheim.korap.interfaces.db.*.*(..))"/> |
| 201 | <aop:advisor advice-ref="txAdvice" pointcut-ref="service"/> |
| 202 | </aop:config> |
| 203 | |
| 204 | <!-- similarly, don't forget the PlatformTransactionManager --> |
| 205 | <bean id="txManager" |
| 206 | class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> |
| 207 | <property name="dataSource" ref="dataSource"/> |
| 208 | </bean> |
| 209 | </beans> |