From 269c07d7036c8e8136cba87baf8f4db84ad74860 Mon Sep 17 00:00:00 2001 From: Nils Christian Ehmke <nie@informatik.uni-kiel.de> Date: Thu, 25 Oct 2012 15:42:59 +0200 Subject: [PATCH] Refactoring of the spring-configuration-files. --- Kieker.WebGUI/nb-configuration.xml | 2 + ...ring-config.xml => spring-bean-config.xml} | 70 ++----------------- .../webapp/WEB-INF/spring-common-config.xml | 24 +++++++ .../webapp/WEB-INF/spring-database-config.xml | 42 +++++++++++ 4 files changed, 74 insertions(+), 64 deletions(-) rename Kieker.WebGUI/src/main/webapp/WEB-INF/{spring-config.xml => spring-bean-config.xml} (69%) create mode 100644 Kieker.WebGUI/src/main/webapp/WEB-INF/spring-common-config.xml create mode 100644 Kieker.WebGUI/src/main/webapp/WEB-INF/spring-database-config.xml diff --git a/Kieker.WebGUI/nb-configuration.xml b/Kieker.WebGUI/nb-configuration.xml index 7b4b9bd0..508f207d 100644 --- a/Kieker.WebGUI/nb-configuration.xml +++ b/Kieker.WebGUI/nb-configuration.xml @@ -23,6 +23,8 @@ Any value defined here will override the pom.xml file value but is only applicab <config-files> <config-file>src/main/webapp/WEB-INF/spring-config.xml</config-file> <config-file>src/main/webapp/WEB-INF/spring-security-taglib.xml</config-file> + <config-file>src/main/webapp/WEB-INF/spring-database-config.xml</config-file> + <config-file>src/main/webapp/WEB-INF/spring-bean-config.xml</config-file> </config-files> <config-file-groups/> </spring-data> diff --git a/Kieker.WebGUI/src/main/webapp/WEB-INF/spring-config.xml b/Kieker.WebGUI/src/main/webapp/WEB-INF/spring-bean-config.xml similarity index 69% rename from Kieker.WebGUI/src/main/webapp/WEB-INF/spring-config.xml rename to Kieker.WebGUI/src/main/webapp/WEB-INF/spring-bean-config.xml index c2a0d8f2..e8da97f1 100644 --- a/Kieker.WebGUI/src/main/webapp/WEB-INF/spring-config.xml +++ b/Kieker.WebGUI/src/main/webapp/WEB-INF/spring-bean-config.xml @@ -1,67 +1,9 @@ +<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xmlns:aop="http://www.springframework.org/schema/aop" - xmlns:context="http://www.springframework.org/schema/context" - xmlns:jdbc="http://www.springframework.org/schema/jdbc" - xmlns:tx="http://www.springframework.org/schema/tx" - xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd - http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd - http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd - http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.1.xsd - http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.1.xsd - http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd" - xmlns:util="http://www.springframework.org/schema/util"> - - <!-- The database and the transaction manager. --> - <bean id="userDataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> - <property name="driverClassName" value="org.apache.derby.jdbc.EmbeddedDriver" /> - <property name="url" value="jdbc:derby:user;create=true" /> - </bean> - - <bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> - <property name="dataSource" ref="userDataSource"/> - </bean> - - <tx:advice id="txAdvice" transaction-manager="txManager"> - <tx:attributes> - <!-- all methods starting with 'get' are read-only --> - <tx:method name="get*" read-only="true"/> - <!-- other methods use the default transaction settings (see below) --> - <tx:method name="*"/> - </tx:attributes> - </tx:advice> - - <!-- ensure that the above transactional advice runs for any execution - of an operation defined by the UserManager interface --> - <aop:config> - <aop:pointcut id="userManagerOperation" expression="execution(* kieker.webgui.common.IUserManagerFacade.*(..))"/> - <aop:advisor advice-ref="txAdvice" pointcut-ref="userManagerOperation"/> - </aop:config> - - <jdbc:initialize-database ignore-failures="ALL" data-source="userDataSource"> - <jdbc:script location="classpath:sql/tables.sql"/> - <jdbc:script location="classpath:sql/test-data.sql"/> - </jdbc:initialize-database> - - <!-- As there is no view scope available in Spring, we have to use a custom defined scope for this purpose. --> - <bean class="org.springframework.beans.factory.config.CustomScopeConfigurer"> - <property name="scopes"> - <map> - <entry key="view"> - <bean class="kieker.webgui.common.util.ViewScope"/> - </entry> - </map> - </property> - </bean> - - <!-- This is for the properties-files. --> - <bean id="globalPropertiesPlaceholder" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> - <property name="locations"> - <list> - <value>classpath:global.properties</value> - </list> - </property> - </bean> + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:util="http://www.springframework.org/schema/util" + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd + http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.1.xsd"> <!-- The singleton scoped beans. --> <bean id="pluginFinder" class="kieker.webgui.common.util.PluginFinder" /> @@ -172,4 +114,4 @@ <!-- The enums. --> <util:constant id="ROLE_USER" static-field="kieker.webgui.common.Role.ROLE_USER"/> <util:constant id="ROLE_ADMIN" static-field="kieker.webgui.common.Role.ROLE_ADMIN"/> -</beans> \ No newline at end of file +</beans> diff --git a/Kieker.WebGUI/src/main/webapp/WEB-INF/spring-common-config.xml b/Kieker.WebGUI/src/main/webapp/WEB-INF/spring-common-config.xml new file mode 100644 index 00000000..b3006a95 --- /dev/null +++ b/Kieker.WebGUI/src/main/webapp/WEB-INF/spring-common-config.xml @@ -0,0 +1,24 @@ +<beans xmlns="http://www.springframework.org/schema/beans" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"> + + <!-- As there is no view scope available in Spring, we have to use a custom defined scope for this purpose. --> + <bean class="org.springframework.beans.factory.config.CustomScopeConfigurer"> + <property name="scopes"> + <map> + <entry key="view"> + <bean class="kieker.webgui.common.util.ViewScope"/> + </entry> + </map> + </property> + </bean> + + <!-- This is for the properties-files. --> + <bean id="globalPropertiesPlaceholder" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> + <property name="locations"> + <list> + <value>classpath:global.properties</value> + </list> + </property> + </bean> +</beans> \ No newline at end of file diff --git a/Kieker.WebGUI/src/main/webapp/WEB-INF/spring-database-config.xml b/Kieker.WebGUI/src/main/webapp/WEB-INF/spring-database-config.xml new file mode 100644 index 00000000..b8c976ed --- /dev/null +++ b/Kieker.WebGUI/src/main/webapp/WEB-INF/spring-database-config.xml @@ -0,0 +1,42 @@ +<?xml version="1.0" encoding="UTF-8"?> +<beans xmlns="http://www.springframework.org/schema/beans" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:tx="http://www.springframework.org/schema/tx" + xmlns:aop="http://www.springframework.org/schema/aop" + xmlns:jdbc="http://www.springframework.org/schema/jdbc" + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd + http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd + http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd + http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.1.xsd"> + + <!-- The database and the transaction manager. --> + <bean id="userDataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> + <property name="driverClassName" value="org.apache.derby.jdbc.EmbeddedDriver" /> + <property name="url" value="jdbc:derby:user;create=true" /> + </bean> + + <bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> + <property name="dataSource" ref="userDataSource"/> + </bean> + + <tx:advice id="txAdvice" transaction-manager="txManager"> + <tx:attributes> + <!-- all methods starting with 'get' are read-only --> + <tx:method name="get*" read-only="true"/> + <!-- other methods use the default transaction settings (see below) --> + <tx:method name="*"/> + </tx:attributes> + </tx:advice> + + <!-- ensure that the above transactional advice runs for any execution + of an operation defined by the UserManager interface --> + <aop:config> + <aop:pointcut id="userManagerOperation" expression="execution(* kieker.webgui.common.IUserManagerFacade.*(..))"/> + <aop:advisor advice-ref="txAdvice" pointcut-ref="userManagerOperation"/> + </aop:config> + + <jdbc:initialize-database ignore-failures="ALL" data-source="userDataSource"> + <jdbc:script location="classpath:sql/tables.sql"/> + <jdbc:script location="classpath:sql/test-data.sql"/> + </jdbc:initialize-database> +</beans> -- GitLab