Uploaded image for project: 'Struts 2'
  1. Struts 2
  2. WW-4174

Make OgnlValueStack and OgnlValueStackFactory More Extensible

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.3.15.1
    • Fix Version/s: 2.5.10
    • Component/s: Value Stack
    • Labels:
      None

      Description

      I'm not trying to reopen XW-613 and have taken the advice from the mailing list seriously about not just requesting changes to the default behavior or log levels.

      http://mail-archives.apache.org/mod_mbox/struts-user/200907.mbox/%3Ce34c19110907310623y36a23e81paabd04e23a6d725e@mail.gmail.com%3E

      Instead, I'd like to propose changing some private methods in OgnlValueStack to be protected so that developers can more easily extend OgnlValueStack to implement their desired logging/warning/exception behavior for their application.

      I'd like to propose that the following methods in OgnlValueStack (currently private in scope) should be changed to protected:

      protected void handleRuntimeException(String expr, Object value, boolean throwExceptionOnFailure, RuntimeException re)
      protected void handleOgnlException(String expr, Object value, boolean throwExceptionOnFailure, OgnlException e)
      protected void setupExceptionOnFailure(boolean throwExceptionOnFailure)
      protected Object handleOtherException(String expr, boolean throwExceptionOnFailure, Exception e)
      protected Object handleOgnlException(String expr, boolean throwExceptionOnFailure, OgnlException e)
      protected boolean shouldLogNoSuchPropertyWarning(OgnlException e)
      protected Object findInContext(String name)
      

      Additionally, to enable the OgnlValueStackFactory to be easily extended to return any overridden OgnlValueStack implementations, the currently private data members should be given protected getters:

         protected XWorkConverter getXworkConverter()
         {
            return xworkConverter;
         }
      
         protected CompoundRootAccessor getCompoundRootAccessor()
         {
            return compoundRootAccessor;
         }
      
         protected TextProvider getTextProvider()
         {
            return textProvider;
         }
      
         protected Container getContainer()
         {
            return container;
         }
      
         protected boolean isAllowStaticMethodAccess()
         {
            return allowStaticMethodAccess;
         }
      

      This would allow developers like myself to more easily extend and override behavior to better fit our own desired notification levels. For example, these changes would allow me to set it up to provide info level warnings in the log file while suppressing the exception that gets thrown.

      Protected level scope ensures that my custom extensions can more easily inherit bug fixes and behavior changes from future versions.

      Thanks!

        Activity

        Hide
        jira-bot ASF subversion and git services added a comment -

        Commit 55fed537646ba33d6789deb15f0d8ef99b870594 in struts's branch refs/heads/master from Lukasz Lenart
        [ https://git-wip-us.apache.org/repos/asf?p=struts.git;h=55fed53 ]

        WW-4174 Makes fields protected to allow easily override

        Show
        jira-bot ASF subversion and git services added a comment - Commit 55fed537646ba33d6789deb15f0d8ef99b870594 in struts's branch refs/heads/master from Lukasz Lenart [ https://git-wip-us.apache.org/repos/asf?p=struts.git;h=55fed53 ] WW-4174 Makes fields protected to allow easily override
        Hide
        lukaszlenart Lukasz Lenart added a comment -

        Kevin Conroy Kevin Conroy done, instead of protected getters (which may looks awkward) I have made those fields protected

        Show
        lukaszlenart Lukasz Lenart added a comment - Kevin Conroy Kevin Conroy done, instead of protected getters (which may looks awkward) I have made those fields protected
        Hide
        hudson Hudson added a comment -

        SUCCESS: Integrated in Jenkins build Struts-JDK7-master #576 (See https://builds.apache.org/job/Struts-JDK7-master/576/)
        WW-4174 Makes fields protected to allow easily override (lukaszlenart: rev 55fed537646ba33d6789deb15f0d8ef99b870594)

        • (edit) core/src/main/java/com/opensymphony/xwork2/ognl/OgnlValueStack.java
        • (edit) core/src/main/java/com/opensymphony/xwork2/ognl/OgnlValueStackFactory.java
        Show
        hudson Hudson added a comment - SUCCESS: Integrated in Jenkins build Struts-JDK7-master #576 (See https://builds.apache.org/job/Struts-JDK7-master/576/ ) WW-4174 Makes fields protected to allow easily override (lukaszlenart: rev 55fed537646ba33d6789deb15f0d8ef99b870594) (edit) core/src/main/java/com/opensymphony/xwork2/ognl/OgnlValueStack.java (edit) core/src/main/java/com/opensymphony/xwork2/ognl/OgnlValueStackFactory.java
        Hide
        kconroy Kevin Conroy added a comment -

        Thank you!

        Show
        kconroy Kevin Conroy added a comment - Thank you!

          People

          • Assignee:
            lukaszlenart Lukasz Lenart
            Reporter:
            kconroy Kevin Conroy
          • Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development