struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lukaszlen...@apache.org
Subject [struts] 06/08: Upgrades to latest Spring 4 version
Date Sun, 15 Apr 2018 19:10:53 GMT
This is an automated email from the ASF dual-hosted git repository.

lukaszlenart pushed a commit to branch struts-2-4
in repository https://gitbox.apache.org/repos/asf/struts.git

commit fd8d3db8b854a74239bebb93ed5cd8afe1843c97
Author: Lukasz Lenart <lukaszlenart@apache.org>
AuthorDate: Sun Apr 1 18:54:55 2018 +0200

    Upgrades to latest Spring 4 version
---
 apps/pom.xml                                       |  2 +-
 .../src/main/webapp/WEB-INF/applicationContext.xml | 30 ++++----
 .../src/main/resources/applicationContext.xml      | 17 ++---
 bom/pom.xml                                        |  1 +
 pom.xml                                            | 20 +++---
 .../spring/SpringProxyableObjectFactory.java       | 29 +++-----
 .../xwork2/spring/actionContext-spring.xml         | 81 +++++++++++++---------
 7 files changed, 93 insertions(+), 87 deletions(-)

diff --git a/apps/pom.xml b/apps/pom.xml
index 2ad3f24..bb1b6df 100644
--- a/apps/pom.xml
+++ b/apps/pom.xml
@@ -106,7 +106,7 @@
         <dependency>
             <groupId>org.springframework</groupId>
             <artifactId>spring-test</artifactId>
-            <version>${struts2.springPlatformVersion}</version>
+            <version>${spring.platformVersion}</version>
             <scope>test</scope>
         </dependency>
     </dependencies>
diff --git a/apps/portlet/src/main/webapp/WEB-INF/applicationContext.xml b/apps/portlet/src/main/webapp/WEB-INF/applicationContext.xml
index 6bd3e54..e46fb4a 100644
--- a/apps/portlet/src/main/webapp/WEB-INF/applicationContext.xml
+++ b/apps/portlet/src/main/webapp/WEB-INF/applicationContext.xml
@@ -1,18 +1,20 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
+<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.xsd">
 
-<!--
-	- Application context definition for "springapp" DispatcherServlet.
--->
+  <!--
+    - Application context definition for "springapp" DispatcherServlet.
+  -->
 
-<beans default-autowire="autodetect">
-	<bean id="thingManager"
-		class="org.apache.struts2.portlet.example.spring.ThingManager">
-	</bean>
-	<bean id="springAction"
-		class="org.apache.struts2.portlet.example.spring.SpringAction" singleton="false">
-		<property name="thingManager">
-			<ref bean="thingManager" />
-		</property>
-	</bean>
+  <bean id="thingManager"
+        class="org.apache.struts2.portlet.example.spring.ThingManager">
+  </bean>
+  <bean id="springAction"
+        class="org.apache.struts2.portlet.example.spring.SpringAction" scope="prototype">
+    <property name="thingManager">
+      <ref bean="thingManager"/>
+    </property>
+  </bean>
 </beans>
diff --git a/archetypes/struts2-archetype-starter/src/main/resources/archetype-resources/src/main/resources/applicationContext.xml
b/archetypes/struts2-archetype-starter/src/main/resources/archetype-resources/src/main/resources/applicationContext.xml
index 88c31b2..eeaba15 100644
--- a/archetypes/struts2-archetype-starter/src/main/resources/archetype-resources/src/main/resources/applicationContext.xml
+++ b/archetypes/struts2-archetype-starter/src/main/resources/archetype-resources/src/main/resources/applicationContext.xml
@@ -1,10 +1,11 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE beans PUBLIC 
-	"-//SPRING//DTD BEAN//EN" 
-	"http://www.springframework.org/dtd/spring-beans.dtd">
-	
-<beans>
-	<!-- Example of SAF2 action instantiated by Spring -->
-    <bean id="helloWorldAction" class="${package}.HelloWorldAction" singleton="false"
/>
-</beans>
+<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.xsd">
+
+  <beans>
+    <!-- Example of SAF2 action instantiated by Spring -->
+    <bean id="helloWorldAction" class="${package}.HelloWorldAction" scope="prototype"/>
+  </beans>
 
diff --git a/bom/pom.xml b/bom/pom.xml
index 51679f2..1c04909 100644
--- a/bom/pom.xml
+++ b/bom/pom.xml
@@ -34,6 +34,7 @@
                 <configuration>
                     <skip>true</skip>
                     <skipDeploy>true</skipDeploy>
+
                     <generateReports>false</generateReports>
                 </configuration>
             </plugin>
diff --git a/pom.xml b/pom.xml
index b385b74..3da99f4 100644
--- a/pom.xml
+++ b/pom.xml
@@ -76,7 +76,7 @@
     </organization>
 
     <properties>
-        <struts2.springPlatformVersion>3.0.5.RELEASE</struts2.springPlatformVersion>
+        <spring.platformVersion>4.3.13.RELEASE</spring.platformVersion>
         <ognl.version>3.1.17</ognl.version>
         <asm.version>5.2</asm.version>
         <tiles.version>2.2.2</tiles.version>
@@ -748,47 +748,47 @@
             <dependency>
                 <groupId>org.springframework</groupId>
                 <artifactId>spring-core</artifactId>
-                <version>${struts2.springPlatformVersion}</version>
+                <version>${spring.platformVersion}</version>
             </dependency>
             <dependency>
                 <groupId>org.springframework</groupId>
                 <artifactId>spring-webmvc-portlet</artifactId>
-                <version>${struts2.springPlatformVersion}</version>
+                <version>${spring.platformVersion}</version>
             </dependency>
             <dependency>
                 <groupId>org.springframework</groupId>
                 <artifactId>spring-context</artifactId>
-                <version>${struts2.springPlatformVersion}</version>
+                <version>${spring.platformVersion}</version>
             </dependency>
             <dependency>
                 <groupId>org.springframework</groupId>
                 <artifactId>spring-aop</artifactId>
-                <version>${struts2.springPlatformVersion}</version>
+                <version>${spring.platformVersion}</version>
             </dependency>
             <dependency>
                 <groupId>org.springframework</groupId>
                 <artifactId>spring-aspects</artifactId>
-                <version>${struts2.springPlatformVersion}</version>
+                <version>${spring.platformVersion}</version>
             </dependency>
             <dependency>
                 <groupId>org.springframework</groupId>
                 <artifactId>spring-beans</artifactId>
-                <version>${struts2.springPlatformVersion}</version>
+                <version>${spring.platformVersion}</version>
             </dependency>
             <dependency>
                 <groupId>org.springframework</groupId>
                 <artifactId>spring-test</artifactId>
-                <version>${struts2.springPlatformVersion}</version>
+                <version>${spring.platformVersion}</version>
             </dependency>
             <dependency>
                 <groupId>org.springframework</groupId>
                 <artifactId>spring-context-support</artifactId>
-                <version>${struts2.springPlatformVersion}</version>
+                <version>${spring.platformVersion}</version>
             </dependency>
             <dependency>
                 <groupId>org.springframework</groupId>
                 <artifactId>spring-web</artifactId>
-                <version>${struts2.springPlatformVersion}</version>
+                <version>${spring.platformVersion}</version>
             </dependency>
 
             <dependency>
diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/spring/SpringProxyableObjectFactory.java
b/xwork-core/src/main/java/com/opensymphony/xwork2/spring/SpringProxyableObjectFactory.java
index 8d5a524..5f08afd 100644
--- a/xwork-core/src/main/java/com/opensymphony/xwork2/spring/SpringProxyableObjectFactory.java
+++ b/xwork-core/src/main/java/com/opensymphony/xwork2/spring/SpringProxyableObjectFactory.java
@@ -18,6 +18,7 @@ package com.opensymphony.xwork2.spring;
 import com.opensymphony.xwork2.util.logging.Logger;
 import com.opensymphony.xwork2.util.logging.LoggerFactory;
 import org.springframework.beans.factory.NoSuchBeanDefinitionException;
+import org.springframework.beans.factory.config.BeanDefinition;
 import org.springframework.beans.factory.support.BeanDefinitionRegistry;
 import org.springframework.beans.factory.support.RootBeanDefinition;
 import org.springframework.context.ApplicationContext;
@@ -39,36 +40,26 @@ public class SpringProxyableObjectFactory extends SpringObjectFactory
{
 
     @Override
     public Object buildBean(String beanName, Map<String, Object> extraContext) throws
Exception {
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("Building bean for name " + beanName);
-        }
+        LOG.debug("Building bean for name {}", beanName);
         if (!skipBeanNames.contains(beanName)) {
             ApplicationContext anAppContext = getApplicationContext(extraContext);
             try {
-                if (LOG.isDebugEnabled()) {
-                    LOG.debug("Trying the application context... appContext = " + anAppContext
+ ",\n bean name = " + beanName);
-                }
+                LOG.debug("Trying the application context... appContext = {},\n bean name
= {}", anAppContext, beanName);
                 return anAppContext.getBean(beanName);
             } catch (NoSuchBeanDefinitionException e) {
-                if (LOG.isDebugEnabled()) {
-                    LOG.debug("Did not find bean definition for bean named " + beanName +
", creating a new one...");
-                }
+                LOG.debug("Did not find bean definition for bean named {}, creating a new
one...", beanName);
                 if (autoWiringFactory instanceof BeanDefinitionRegistry) {
                     try {
                         Class clazz = Class.forName(beanName);
                         BeanDefinitionRegistry registry = (BeanDefinitionRegistry) autoWiringFactory;
-                        RootBeanDefinition def = new RootBeanDefinition(clazz, autowireStrategy);
-                        def.setSingleton(false);
-                         if (LOG.isDebugEnabled()) {
-                            LOG.debug("Registering a new bean definition for class " + beanName);
-                        }
+                        RootBeanDefinition def = new RootBeanDefinition(clazz, autowireStrategy,
true);
+                        def.setScope(BeanDefinition.SCOPE_SINGLETON);
+                        LOG.debug("Registering a new bean definition for class {}", beanName);
                         registry.registerBeanDefinition(beanName,def);
                         try {
                             return anAppContext.getBean(beanName);
                         } catch (NoSuchBeanDefinitionException e2) {
-                            if (LOG.isWarnEnabled()) {
-                        	LOG.warn("Could not register new bean definition for bean " + beanName);
-                            }
+                            LOG.warn("Could not register new bean definition for bean {}",
beanName);
                             skipBeanNames.add(beanName);
                         }
                     } catch (ClassNotFoundException e1) {
@@ -77,9 +68,7 @@ public class SpringProxyableObjectFactory extends SpringObjectFactory {
                 }
             }
         }
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("Returning autowired instance created by default ObjectFactory");
-        }
+        LOG.debug("Returning autowired instance created by default ObjectFactory");
         return autoWireBean(super.buildBean(beanName, extraContext), autoWiringFactory);
     }
 
diff --git a/xwork-core/src/test/resources/com/opensymphony/xwork2/spring/actionContext-spring.xml
b/xwork-core/src/test/resources/com/opensymphony/xwork2/spring/actionContext-spring.xml
index 4cc2284..e674d8d 100644
--- a/xwork-core/src/test/resources/com/opensymphony/xwork2/spring/actionContext-spring.xml
+++ b/xwork-core/src/test/resources/com/opensymphony/xwork2/spring/actionContext-spring.xml
@@ -1,42 +1,55 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
+<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.xsd">
 
-<beans>
-	<bean id="simple-action" class="com.opensymphony.xwork2.SimpleAction" singleton="false"/>
+  <bean id="simple-action" class="com.opensymphony.xwork2.SimpleAction" scope="prototype"/>
 
-    <bean id="dependency-action" class="com.opensymphony.xwork2.SimpleAction" singleton="false">
-        <property name="blah"><value>injected</value></property>
-    </bean>
+  <bean id="dependency-action" class="com.opensymphony.xwork2.SimpleAction" scope="prototype">
+    <property name="blah">
+      <value>injected</value>
+    </property>
+  </bean>
 
-    <bean id="execute-interceptor" class="com.opensymphony.xwork2.spring.ExecuteInterceptor"/>
+  <bean id="execute-interceptor" class="com.opensymphony.xwork2.spring.ExecuteInterceptor"/>
 
-    <bean id="proxied-action" class="org.springframework.aop.framework.ProxyFactoryBean">
-        <property name="singleton"><value>false</value></property>
 
-		<property name="proxyTargetClass"><value>true</value></property>
-		<property name="interceptorNames">
-			<list>
-				<value>execute-interceptor</value>
-                <!-- When "singleton" is false, the target appears to be required here
to 
-                     ensure that the config works as it should -->
-                <value>simple-action</value>
-			</list>
-		</property>
-	</bean>
+  <bean id="proxied-action" class="org.springframework.aop.framework.ProxyFactoryBean">
+    <property name="singleton">
+      <value>false</value>
+    </property>
+    <property name="proxyTargetClass">
+      <value>true</value>
+    </property>
+    <property name="interceptorNames">
+      <list>
+        <value>execute-interceptor</value>
+        <!-- When "singleton" is false, the target appears to be required here to
+             ensure that the config works as it should -->
+        <value>simple-action</value>
+      </list>
+    </property>
+  </bean>
 
-    <bean id="auto-proxied-action" class="com.opensymphony.xwork2.SimpleAction" singleton="false"/>
+  <bean id="auto-proxied-action" class="com.opensymphony.xwork2.SimpleAction" scope="prototype"/>
 
-    <bean id="xwork-actions-proxy-creator" class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
-		<property name="proxyTargetClass"><value>true</value></property>
-		<property name="interceptorNames">
-			<list>
-				<value>execute-interceptor</value>
-			</list>
-		</property>
-        <property name="beanNames"><value>auto-proxied-action</value></property>
-    </bean>
-    
-    <bean id="springResult" class="com.opensymphony.xwork2.spring.SpringResult"
-		init-method="initialize">
-		<property name="stringParameter" value="my string"/>
-	</bean>
+  <bean id="xwork-actions-proxy-creator" class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
+    <property name="proxyTargetClass">
+      <value>true</value>
+    </property>
+    <property name="interceptorNames">
+      <list>
+        <value>execute-interceptor</value>
+      </list>
+    </property>
+    <property name="beanNames">
+      <value>auto-proxied-action</value>
+    </property>
+  </bean>
+
+  <bean id="springResult" class="com.opensymphony.xwork2.spring.SpringResult"
+        init-method="initialize">
+    <property name="stringParameter" value="my string"/>
+  </bean>
 </beans>

-- 
To stop receiving notification emails like this one, please contact
lukaszlenart@apache.org.

Mime
View raw message