portletspec3
  1. portletspec3
  2. PORTLETSPEC3-15

Issue in GenericPortlet Annotation Processing

    Details

      Description

      This problem is a bit esoteric, and I hope I can adequately present it.
      It has to do with Action dispatching using annotations in the case of inheritance.

      Working Document 3 (22.04.13) Section "PLT.5.4.5.1 Action Dispatching", beginning at line 8
      on page 48, it states:
      -------------------------
      For a received action the processAction method in the GenericPortlet class tries
      to dispatch to public methods annotated with the tag
      @ProcessAction(name=<action name>), where the action name must be set on the
      ActionURL ...
      -------------------------

      An attempt was made to use this feature in the following manner:
      -------------------------
      class PortletA extends GenericPortlet {
      @ProcessAction(name="actionA")
      void processMyActionAinA(ActionRequest req, ActionResponse resp)
      throws PortletException, java.io.IOException;
      };

      class PortletB extends PortletA

      { @ProcessAction(name="actionA") void processMyActionAinB(ActionRequest req, ActionResponse resp) throws PortletException, java.io.IOException;}

      ;
      -------------------------

      Now the question is, for portlet B, which "processMyActionA" is called when actionA occurs?

      We would want it to be "processMyActionAinB", I believe.

      However, GenericPortlet uses .getClass().getMethods() to obtain the methods for annotation processing.

      The javadoc for Class.getMethods() states:
      -------------------------
      Returns an array containing Method objects reflecting all the public member methods of the
      class or interface represented by this Class object, including those declared by the class
      or interface and those inherited from superclasses and superinterfaces. Array classes
      return all the (public) member methods inherited from the Object class. The elements in the
      array returned are not sorted and are not in any particular order.
      -------------------------

      Since GenericPortlet doesn't do any particular processing to handle methods inherited from
      superclasses, it turns out that the actual method for PortletB called when actionA occurs
      is not deterministic. It can be either "processMyActionAinB" or "processMyActionAinA", depending on
      how .getMethods() happens to order the method array.

      We may want to look into this at some point.

        Activity

        msnicklous created issue -
        Hide
        Neil Griffin added a comment -

        I think a simple fix for the private GenericPortlet.cacheAnnotatedMethods() method would be to call Method.getDeclaringClass() to see if if that is the same as this.getClass(). If true, then it should "win" over all other candidate methods in the array.

        Show
        Neil Griffin added a comment - I think a simple fix for the private GenericPortlet.cacheAnnotatedMethods() method would be to call Method.getDeclaringClass() to see if if that is the same as this.getClass(). If true, then it should "win" over all other candidate methods in the array.
        msnicklous made changes -
        Field Original Value New Value
        Assignee msnicklous [ msnicklous ]
        Hide
        msnicklous added a comment - - edited

        updated GenericPortlet.java. Code change only; no apidoc change. See: GenericPortlet.java

        Test portlet: PORTLETSPEC3_15 from portletbox.

        Show
        msnicklous added a comment - - edited updated GenericPortlet.java. Code change only; no apidoc change. See: GenericPortlet.java Test portlet: PORTLETSPEC3_15 from portletbox.
        msnicklous made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]

          People

          • Assignee:
            msnicklous
            Reporter:
            msnicklous
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: