struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lukaszlen...@apache.org
Subject struts git commit: Drops deprecation interceptor
Date Tue, 13 Oct 2015 06:38:22 GMT
Repository: struts
Updated Branches:
  refs/heads/master 9c5c568fc -> 0dd0f045d


Drops deprecation interceptor


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

Branch: refs/heads/master
Commit: 0dd0f045d2cbe6dc6144299e444fe05aa03c0180
Parents: 9c5c568
Author: Lukasz Lenart <lukaszlenart@apache.org>
Authored: Tue Oct 13 08:38:09 2015 +0200
Committer: Lukasz Lenart <lukaszlenart@apache.org>
Committed: Tue Oct 13 08:38:09 2015 +0200

----------------------------------------------------------------------
 .../interceptor/DeprecationInterceptor.java     | 106 -------------------
 core/src/main/resources/struts-default.xml      |   3 -
 2 files changed, 109 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/struts/blob/0dd0f045/core/src/main/java/org/apache/struts2/interceptor/DeprecationInterceptor.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/struts2/interceptor/DeprecationInterceptor.java
b/core/src/main/java/org/apache/struts2/interceptor/DeprecationInterceptor.java
deleted file mode 100644
index 3722efe..0000000
--- a/core/src/main/java/org/apache/struts2/interceptor/DeprecationInterceptor.java
+++ /dev/null
@@ -1,106 +0,0 @@
-package org.apache.struts2.interceptor;
-
-import com.opensymphony.xwork2.ActionInvocation;
-import com.opensymphony.xwork2.XWorkConstants;
-import com.opensymphony.xwork2.inject.Container;
-import com.opensymphony.xwork2.inject.Inject;
-import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
-import org.apache.commons.lang3.BooleanUtils;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-import org.apache.struts2.StrutsConstants;
-
-import java.lang.reflect.Field;
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * <!-- START SNIPPET: description -->
- * In devMode checks if application uses deprecated or unknown constants and displays warning
- * when logging level is set to DEBUG
- * <!-- END SNIPPET: description -->
- *
- * <!-- START SNIPPET: parameters -->
- * no special parameters yet
- * <!-- END SNIPPET: parameters -->
- */
-public class DeprecationInterceptor extends AbstractInterceptor {
-
-    private static final Logger LOG = LogManager.getLogger(DeprecationInterceptor.class);
-
-    private Container container;
-    private boolean devMode;
-
-    @Override
-    public String intercept(ActionInvocation invocation) throws Exception {
-        if (devMode) {
-            String message = validate();
-            if (message != null) {
-                LOG.debug(message);
-            }
-        }
-        return invocation.invoke();
-    }
-
-    /**
-     * Validates constants. Validation goes on only if devMode is set.
-     *
-     * @throws Exception
-     */
-    private String validate() throws Exception {
-        Set<String> constants = new HashSet<>();
-
-        readConstants(constants, StrutsConstants.class);
-        readConstants(constants, XWorkConstants.class);
-
-        Set<String> applicationConstants = container.getInstanceNames(String.class);
-        String message = null;
-        if (!constants.containsAll(applicationConstants)) {
-            Set<String> deprecated = new HashSet<>(applicationConstants);
-            deprecated.removeAll(constants);
-            message = prepareMessage(deprecated);
-        }
-        return message;
-    }
-
-    private void readConstants(Set<String> constants, Class clazz) throws IllegalAccessException
{
-        for (Field field : clazz.getDeclaredFields()) {
-            if (String.class.equals(field.getType())) {
-                constants.add((String) field.get(clazz));
-            }
-        }
-    }
-
-    /**
-     * Prepares message to display
-     *
-     * @param deprecated A set with deprecated/unknown constants
-     */
-    private String prepareMessage(Set<String> deprecated) {
-        StringBuilder sb = new StringBuilder("\n");
-        sb.append("*******************************************************************************\n");
-        sb.append("**                                                                   
       **\n");
-        sb.append("**                               WARNING                             
       **\n");
-        sb.append("**                YOU USE DEPRECATED / UNKNOWN CONSTANTS             
       **\n");
-        sb.append("**                                                                   
       **\n");
-
-        for (String dep : deprecated) {
-            sb.append(String.format("**  -> %-69s **\n", dep));
-        }
-
-        sb.append("*******************************************************************************\n");
-
-        return sb.toString();
-    }
-
-    @Inject(StrutsConstants.STRUTS_DEVMODE)
-    public void setDevMode(String state) {
-        this.devMode = BooleanUtils.toBoolean(state);
-    }
-
-    @Inject
-    public void setContainer(Container container) {
-        this.container = container;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/struts/blob/0dd0f045/core/src/main/resources/struts-default.xml
----------------------------------------------------------------------
diff --git a/core/src/main/resources/struts-default.xml b/core/src/main/resources/struts-default.xml
index b95a1a0..1f5fa17 100644
--- a/core/src/main/resources/struts-default.xml
+++ b/core/src/main/resources/struts-default.xml
@@ -215,7 +215,6 @@
             <interceptor name="roles" class="org.apache.struts2.interceptor.RolesInterceptor"
/>
             <interceptor name="annotationWorkflow" class="com.opensymphony.xwork2.interceptor.annotations.AnnotationWorkflowInterceptor"
/>
             <interceptor name="multiselect" class="org.apache.struts2.interceptor.MultiselectInterceptor"
/>
-            <interceptor name="deprecation" class="org.apache.struts2.interceptor.DeprecationInterceptor"
/>
 
             <!-- Basic stack -->
             <interceptor-stack name="basicStack">
@@ -228,7 +227,6 @@
                 <interceptor-ref name="actionMappingParams"/>
                 <interceptor-ref name="params"/>
                 <interceptor-ref name="conversionError"/>
-                <interceptor-ref name="deprecation"/>
             </interceptor-stack>
 
             <!-- Sample validation and workflow stack -->
@@ -334,7 +332,6 @@
                     <param name="excludeMethods">input,back,cancel,browse</param>
                 </interceptor-ref>
                 <interceptor-ref name="debugging"/>
-                <interceptor-ref name="deprecation"/>
             </interceptor-stack>
 
             <!-- The completeStack is here for backwards compatibility for


Mime
View raw message