Details

    • Type: New Feature New Feature
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.5
    • Component/s: Engine
    • Labels:
      None

      Description

      I've made a new patch that includes a ReferenceInsertionEventHandler ("InvalidReferenceHandler") that collects a list of all invalid references in a Velocity page.

      To see how it works, look at the test code (the last two methods) in BuiltInEventHandlerTestCase.

      To make this work, I had to make some changes to the internals. So I thought I'd hold off a couple days before committing, let any interested parties comment.

      There's a couple of interesting new pieces for plugin writers.

      (1) In any user-defined plugin (event handlers, uberspectors, etc) you can now throw a subclass of VelocityRuntimeException (new exception). to signal unrecoverable states to the calling application. This runtime exception requires no change to the interface signature and is passed through the Velocity parsing process. (In the past, all Exceptions were caught and logged).

      Example use: a custom uberspector or event handler that wishes to stop page processing. For example, the InvalidReferenceHandler can be configured to throw an exception at the first reference error.

      (2) Event handlers can now receive information on the template name, line number, and column by implementing InfoAware. This only works for Local event handlers attached to a context (as opposed to the new Global type defined in Velocity properties).

      Example use: InvalidReferenceHandler reports out the line,column, and template name of each reference error.

      Everything is completely backwards compatible. It'd be simpler if it wasn't of course as they we could just redo the interfaces.

      1. invalidreference.txt
        49 kB
        Will Glass-Husain

        Activity

        Hide
        Will Glass-Husain added a comment -

        I've added a new event handler InvalidReferenceEventHandler to address this. It's a little experimental – may need some tweaking, but should be quite useful.

        Going to resolve this issue in the meantime. Please feel free to ask questions on the lists.

        Show
        Will Glass-Husain added a comment - I've added a new event handler InvalidReferenceEventHandler to address this. It's a little experimental – may need some tweaking, but should be quite useful. Going to resolve this issue in the meantime. Please feel free to ask questions on the lists.
        Hide
        Henning Schmiedehausen added a comment -

        The following Javadoc Issues were introduced by the patches related here. As Javadocs are currently the most important documentation for this feature, it would be good if the docs are really up to date to the function. I e.g. hunted for quite a while for what is returned from invalidGetMethod()...

        [javadoc] /home/scratch/velocity/engine/bin/src/org/apache/velocity/app/event/EventHandlerMethodExecutor.java:47: warning - @return tag has no arguments.
        [javadoc] /home/scratch/velocity/engine/bin/src/org/apache/velocity/app/event/EventHandlerUtil.java:248: warning - @return tag has no arguments.
        [javadoc] /home/scratch/velocity/engine/bin/src/org/apache/velocity/app/event/EventHandlerUtil.java:296: warning - @return tag has no arguments.
        [javadoc] /home/scratch/velocity/engine/bin/src/org/apache/velocity/app/event/EventHandlerUtil.java:316: warning - @return tag has no arguments.
        [javadoc] /home/scratch/velocity/engine/bin/src/org/apache/velocity/app/event/EventHandlerUtil.java:271: warning - @param argument "reference" is not a parameter name.
        [javadoc] /home/scratch/velocity/engine/bin/src/org/apache/velocity/app/event/EventHandlerUtil.java:271: warning - @param argument "object" is not a parameter name.
        [javadoc] /home/scratch/velocity/engine/bin/src/org/apache/velocity/app/event/EventHandlerUtil.java:271: warning - @param argument "property" is not a parameter name.
        [javadoc] /home/scratch/velocity/engine/bin/src/org/apache/velocity/app/event/InvalidReferenceEventHandler.java:70: warning - @param argument "property" is not a parameter name.
        [javadoc] /home/scratch/velocity/engine/bin/src/org/apache/velocity/app/event/InvalidReferenceEventHandler.java:70: warning - @param argument "if" is not a parameter name.
        [javadoc] /home/scratch/velocity/engine/bin/src/org/apache/velocity/app/event/MethodExceptionEventHandler.java:83: warning - @return tag cannot be used in method with void return type.
        [javadoc] /home/scratch/velocity/engine/bin/src/org/apache/velocity/app/event/implement/ReportInvalidReferences.java:131: warning - @param argument "reference" is not a parameter name.
        [javadoc] /home/scratch/velocity/engine/bin/src/org/apache/velocity/app/event/implement/ReportInvalidReferences.java:131: warning - @param argument "object" is not a parameter name.
        [javadoc] /home/scratch/velocity/engine/bin/src/org/apache/velocity/app/event/implement/ReportInvalidReferences.java:131: warning - @param argument "method" is not a parameter name.
        [javadoc] /home/scratch/velocity/engine/bin/src/org/apache/velocity/app/event/implement/ReportInvalidReferences.java:131: warning - @param argument "always" is not a parameter name.

        Show
        Henning Schmiedehausen added a comment - The following Javadoc Issues were introduced by the patches related here. As Javadocs are currently the most important documentation for this feature, it would be good if the docs are really up to date to the function. I e.g. hunted for quite a while for what is returned from invalidGetMethod()... [javadoc] /home/scratch/velocity/engine/bin/src/org/apache/velocity/app/event/EventHandlerMethodExecutor.java:47: warning - @return tag has no arguments. [javadoc] /home/scratch/velocity/engine/bin/src/org/apache/velocity/app/event/EventHandlerUtil.java:248: warning - @return tag has no arguments. [javadoc] /home/scratch/velocity/engine/bin/src/org/apache/velocity/app/event/EventHandlerUtil.java:296: warning - @return tag has no arguments. [javadoc] /home/scratch/velocity/engine/bin/src/org/apache/velocity/app/event/EventHandlerUtil.java:316: warning - @return tag has no arguments. [javadoc] /home/scratch/velocity/engine/bin/src/org/apache/velocity/app/event/EventHandlerUtil.java:271: warning - @param argument "reference" is not a parameter name. [javadoc] /home/scratch/velocity/engine/bin/src/org/apache/velocity/app/event/EventHandlerUtil.java:271: warning - @param argument "object" is not a parameter name. [javadoc] /home/scratch/velocity/engine/bin/src/org/apache/velocity/app/event/EventHandlerUtil.java:271: warning - @param argument "property" is not a parameter name. [javadoc] /home/scratch/velocity/engine/bin/src/org/apache/velocity/app/event/InvalidReferenceEventHandler.java:70: warning - @param argument "property" is not a parameter name. [javadoc] /home/scratch/velocity/engine/bin/src/org/apache/velocity/app/event/InvalidReferenceEventHandler.java:70: warning - @param argument "if" is not a parameter name. [javadoc] /home/scratch/velocity/engine/bin/src/org/apache/velocity/app/event/MethodExceptionEventHandler.java:83: warning - @return tag cannot be used in method with void return type. [javadoc] /home/scratch/velocity/engine/bin/src/org/apache/velocity/app/event/implement/ReportInvalidReferences.java:131: warning - @param argument "reference" is not a parameter name. [javadoc] /home/scratch/velocity/engine/bin/src/org/apache/velocity/app/event/implement/ReportInvalidReferences.java:131: warning - @param argument "object" is not a parameter name. [javadoc] /home/scratch/velocity/engine/bin/src/org/apache/velocity/app/event/implement/ReportInvalidReferences.java:131: warning - @param argument "method" is not a parameter name. [javadoc] /home/scratch/velocity/engine/bin/src/org/apache/velocity/app/event/implement/ReportInvalidReferences.java:131: warning - @param argument "always" is not a parameter name.
        Hide
        Will Glass-Husain added a comment -

        excellent point. cleaned them all up.

        Show
        Will Glass-Husain added a comment - excellent point. cleaned them all up.
        Hide
        Henning Schmiedehausen added a comment -

        Close all resolved issues for Engine 1.5 release.

        Show
        Henning Schmiedehausen added a comment - Close all resolved issues for Engine 1.5 release.

          People

          • Assignee:
            Will Glass-Husain
            Reporter:
            Will Glass-Husain
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development