struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jo...@apache.org
Subject [1/6] struts git commit: WW-4510 Upgrade spring plugin dependencies to spring version 4.x
Date Sun, 07 Jun 2015 19:04:20 GMT
Repository: struts
Updated Branches:
  refs/heads/master 72e6f7073 -> b074c0888


WW-4510 Upgrade spring plugin dependencies to spring version 4.x


Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/d7887000
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/d7887000
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/d7887000

Branch: refs/heads/master
Commit: d788700009a09a2ae9ca7107008cbe773dc2b3f5
Parents: 72e6f70
Author: Johannes Geppert <johgep@gmail.com>
Authored: Sun Jun 7 11:35:46 2015 +0200
Committer: Johannes Geppert <johgep@gmail.com>
Committed: Sun Jun 7 11:35:46 2015 +0200

----------------------------------------------------------------------
 plugins/spring/pom.xml                          |  8 +++++
 .../spring/StrutsSpringObjectFactory.java       | 16 ++++------
 .../spring/StrutsSpringObjectFactoryTest.java   |  8 ++---
 pom.xml                                         |  2 +-
 .../xwork2/spring/SpringObjectFactory.java      | 28 +++++-------------
 .../spring/SpringProxyableObjectFactory.java    | 31 +++++++-------------
 6 files changed, 35 insertions(+), 58 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/struts/blob/d7887000/plugins/spring/pom.xml
----------------------------------------------------------------------
diff --git a/plugins/spring/pom.xml b/plugins/spring/pom.xml
index 0b06dbd..4e509f1 100644
--- a/plugins/spring/pom.xml
+++ b/plugins/spring/pom.xml
@@ -77,6 +77,14 @@
             <scope>test</scope>
         </dependency>
 
+        <!-- The Servlet API mocks in Spring Framework 4.0 support Servlet 3.0 and higher
+           So this is only necessary in tests-->
+        <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>javax.servlet-api</artifactId>
+            <version>3.1.0</version>
+            <scope>test</scope>
+        </dependency>
    </dependencies>
 
     <properties>

http://git-wip-us.apache.org/repos/asf/struts/blob/d7887000/plugins/spring/src/main/java/org/apache/struts2/spring/StrutsSpringObjectFactory.java
----------------------------------------------------------------------
diff --git a/plugins/spring/src/main/java/org/apache/struts2/spring/StrutsSpringObjectFactory.java
b/plugins/spring/src/main/java/org/apache/struts2/spring/StrutsSpringObjectFactory.java
index c34a6e4..f4a6f31 100644
--- a/plugins/spring/src/main/java/org/apache/struts2/spring/StrutsSpringObjectFactory.java
+++ b/plugins/spring/src/main/java/org/apache/struts2/spring/StrutsSpringObjectFactory.java
@@ -24,10 +24,10 @@ package org.apache.struts2.spring;
 import com.opensymphony.xwork2.inject.Container;
 import com.opensymphony.xwork2.inject.Inject;
 import com.opensymphony.xwork2.spring.SpringObjectFactory;
-import org.apache.logging.log4j.Logger;
+import org.apache.commons.lang3.StringUtils;
 import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
 import org.apache.struts2.StrutsConstants;
-import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
 import org.springframework.context.ApplicationContext;
 import org.springframework.web.context.WebApplicationContext;
@@ -74,9 +74,7 @@ public class StrutsSpringObjectFactory extends SpringObjectFactory {
           
         super();
         boolean useClassCache = "true".equals(useClassCacheStr);
-        if (LOG.isInfoEnabled()) {
-            LOG.info("Initializing Struts-Spring integration...");
-        }
+        LOG.info("Initializing Struts-Spring integration...");
 
         Object rootWebApplicationContext =  servletContext.getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE);
 
@@ -112,9 +110,7 @@ public class StrutsSpringObjectFactory extends SpringObjectFactory {
 
             ClassReloadingXMLWebApplicationContext reloadingContext = (ClassReloadingXMLWebApplicationContext)
appContext;
             reloadingContext.setupReloading(watchList.split(","), acceptClasses, servletContext,
"true".equals(reloadConfig));
-            if (LOG.isInfoEnabled()) {
-        	LOG.info("Class reloading is enabled. Make sure this is not used on a production
environment!", watchList);
-            }
+            LOG.info("Class reloading is enabled. Make sure this is not used on a production
environment!\n{}", watchList);
 
             setClassLoader(reloadingContext.getReloadingClassLoader());
 
@@ -144,8 +140,6 @@ public class StrutsSpringObjectFactory extends SpringObjectFactory {
 
         this.setEnableAopSupport(enableAopSupport);
 
-        if (LOG.isInfoEnabled()) {
-            LOG.info("... initialized Struts-Spring integration successfully");
-        }
+        LOG.info("... initialized Struts-Spring integration successfully");
     }
 }

http://git-wip-us.apache.org/repos/asf/struts/blob/d7887000/plugins/spring/src/test/java/org/apache/struts2/spring/StrutsSpringObjectFactoryTest.java
----------------------------------------------------------------------
diff --git a/plugins/spring/src/test/java/org/apache/struts2/spring/StrutsSpringObjectFactoryTest.java
b/plugins/spring/src/test/java/org/apache/struts2/spring/StrutsSpringObjectFactoryTest.java
index 92ce5a4..9141b02 100644
--- a/plugins/spring/src/test/java/org/apache/struts2/spring/StrutsSpringObjectFactoryTest.java
+++ b/plugins/spring/src/test/java/org/apache/struts2/spring/StrutsSpringObjectFactoryTest.java
@@ -21,10 +21,8 @@
 
 package org.apache.struts2.spring;
 
-import javax.servlet.ServletContext;
-
+import com.opensymphony.xwork2.inject.Container;
 import junit.framework.TestCase;
-import org.apache.struts2.StrutsConstants;
 import org.easymock.EasyMock;
 import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
 import org.springframework.mock.web.MockServletContext;
@@ -32,7 +30,7 @@ import org.springframework.web.context.ConfigurableWebApplicationContext;
 import org.springframework.web.context.WebApplicationContext;
 import org.springframework.web.context.support.XmlWebApplicationContext;
 
-import com.opensymphony.xwork2.inject.Container;
+import javax.servlet.ServletContext;
 
 /**
  * Unit test for {@link StrutsSpringObjectFactory}.
@@ -55,7 +53,7 @@ public class StrutsSpringObjectFactoryTest extends TestCase {
         EasyMock.replay(container);
 
         ConfigurableWebApplicationContext ac = new XmlWebApplicationContext();
-        ServletContext msc = (ServletContext) new MockServletContext();
+        ServletContext msc = new MockServletContext();
         msc.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, ac);
         ac.setServletContext(msc);
         ac.setConfigLocations(new String[] {"org/apache/struts2/spring/StrutsSpringObjectFactoryTest-applicationContext.xml"});

http://git-wip-us.apache.org/repos/asf/struts/blob/d7887000/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 9fdec9d..bf48092 100644
--- a/pom.xml
+++ b/pom.xml
@@ -85,7 +85,7 @@
 
     <properties>
         <currentVersion>${project.version}</currentVersion>
-        <struts2.springPlatformVersion>3.0.5.RELEASE</struts2.springPlatformVersion>
+        <struts2.springPlatformVersion>4.1.6.RELEASE</struts2.springPlatformVersion>
         <ognl.version>3.0.6</ognl.version>
         <asm.version>3.3</asm.version>
         <asm5.version>5.0.2</asm5.version>

http://git-wip-us.apache.org/repos/asf/struts/blob/d7887000/xwork-core/src/main/java/com/opensymphony/xwork2/spring/SpringObjectFactory.java
----------------------------------------------------------------------
diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/spring/SpringObjectFactory.java
b/xwork-core/src/main/java/com/opensymphony/xwork2/spring/SpringObjectFactory.java
index 2cfb091..718480f 100644
--- a/xwork-core/src/main/java/com/opensymphony/xwork2/spring/SpringObjectFactory.java
+++ b/xwork-core/src/main/java/com/opensymphony/xwork2/spring/SpringObjectFactory.java
@@ -17,8 +17,8 @@ package com.opensymphony.xwork2.spring;
 
 import com.opensymphony.xwork2.ObjectFactory;
 import com.opensymphony.xwork2.inject.Inject;
-import org.apache.logging.log4j.Logger;
 import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
 import org.springframework.beans.BeansException;
 import org.springframework.beans.factory.UnsatisfiedDependencyException;
 import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
@@ -70,8 +70,7 @@ public class SpringObjectFactory extends ObjectFactory implements ApplicationCon
      *
      * @param appContext The Spring ApplicationContext that should be used to look beans
up with.
      */
-    public void setApplicationContext(ApplicationContext appContext)
-            throws BeansException {
+    public void setApplicationContext(ApplicationContext appContext) throws BeansException
{
         this.appContext = appContext;
         autoWiringFactory = findAutoWiringBeanFactory(this.appContext);
     }
@@ -84,33 +83,23 @@ public class SpringObjectFactory extends ObjectFactory implements ApplicationCon
     public void setAutowireStrategy(int autowireStrategy) {
         switch (autowireStrategy) {
             case AutowireCapableBeanFactory.AUTOWIRE_AUTODETECT:
-                if (LOG.isInfoEnabled()) {
-                    LOG.info("Setting autowire strategy to autodetect");
-                }
+                LOG.info("Setting autowire strategy to autodetect");
                 this.autowireStrategy = autowireStrategy;
                 break;
             case AutowireCapableBeanFactory.AUTOWIRE_BY_NAME:
-                if (LOG.isInfoEnabled()) {
-                    LOG.info("Setting autowire strategy to name");
-                }
+                LOG.info("Setting autowire strategy to name");
                 this.autowireStrategy = autowireStrategy;
                 break;
             case AutowireCapableBeanFactory.AUTOWIRE_BY_TYPE:
-                if (LOG.isInfoEnabled()) {
-                    LOG.info("Setting autowire strategy to type");
-                }
+                LOG.info("Setting autowire strategy to type");
                 this.autowireStrategy = autowireStrategy;
                 break;
             case AutowireCapableBeanFactory.AUTOWIRE_CONSTRUCTOR:
-                if (LOG.isInfoEnabled()) {
-                    LOG.info("Setting autowire strategy to constructor");
-                }
+                LOG.info("Setting autowire strategy to constructor");
                 this.autowireStrategy = autowireStrategy;
                 break;
             case AutowireCapableBeanFactory.AUTOWIRE_NO:
-                if (LOG.isInfoEnabled()) {
-                    LOG.info("Setting autowire strategy to none");
-                }
+                LOG.info("Setting autowire strategy to none");
                 this.autowireStrategy = autowireStrategy;
                 break;
             default:
@@ -198,8 +187,7 @@ public class SpringObjectFactory extends ObjectFactory implements ApplicationCon
                 return autoWireBean(bean, autoWiringFactory);
             }
         } catch (UnsatisfiedDependencyException e) {
-            if (LOG.isErrorEnabled())
-                LOG.error("Error building bean", e);
+            LOG.error("Error building bean", e);
             // Fall back
             return autoWireBean(super.buildBean(clazz, extraContext), autoWiringFactory);
         }

http://git-wip-us.apache.org/repos/asf/struts/blob/d7887000/xwork-core/src/main/java/com/opensymphony/xwork2/spring/SpringProxyableObjectFactory.java
----------------------------------------------------------------------
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 616ac0f..3f701a1 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
@@ -15,9 +15,10 @@
  */
 package com.opensymphony.xwork2.spring;
 
-import org.apache.logging.log4j.Logger;
 import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
 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);
     }
 


Mime
View raw message