XWork
  1. XWork
  2. XW-267

Component Interceptor / DefaultComponentManager does not inspect superinterfaces

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.0.5
    • Fix Version/s: 1.1
    • Component/s: Interceptors
    • Labels:
      None

      Description

      Currently the component interceptor (the DefaultComponentManager) looks at only the parent interfaces and does not walk up the interface hierarchy. So if I have an enabler interface E, which is extended by an interface I which in turn is implemented by a class C, the components infrastructure will not instantiate the class C at the appropriate point when the declared enabler interface is E. The issue is most likely with the following code in DefaultComponentManager

      ---- Current Code ----
      private void addAllInterfaces(Class clazz, List allInterfaces) {
      if (clazz == null)

      { return; }

      Class[] interfaces = clazz.getInterfaces();
      allInterfaces.addAll(Arrays.asList(interfaces));
      addAllInterfaces(clazz.getSuperclass(), allInterfaces);
      }

      What possibly needs to be done is (one may replace List by Set for optimization purposes)

      — Suggested Code ----

      private void addAllInterfaces(Class clazz, List allInterfaces) {
      if (clazz == null) { return; }

      Class[] interfaces = clazz.getInterfaces();
      allInterfaces.addAll(Arrays.asList(interfaces));
      addAllInterfaces(interfaces, allInterfaces);
      addAllInterfaces(clazz.getSuperclass(), allInterfaces);
      }

      private void addAllInterfaces(Class[] clazzes, List allInterfaces) {
      if (clazzes != null)
      {
      for(int i = 0 ; i < clazzes.length; i++)

      { addAllInterfaces(clazzes[i],allInterfaces); }

      }

      }

        Activity

        Tony Stevenson made changes -
        Project Import Mon Jun 18 07:22:17 UTC 2012 [ 1340004137313 ]
        Patrick Lightbody made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Hide
        Patrick Lightbody added a comment -

        All fixed!

        Show
        Patrick Lightbody added a comment - All fixed!
        Patrick Lightbody made changes -
        Fix Version/s 1.1 [ 21330 ]
        Assignee Patrick Lightbody [ plightbo ]
        Dhananjay Nene made changes -
        Field Original Value New Value
        Attachment patch-components.zip [ 11210 ]
        Hide
        Dhananjay Nene added a comment -

        Attaching a patch file which includes updates to the source and to the test cases along with the additional classes necessary for the test.

        Show
        Dhananjay Nene added a comment - Attaching a patch file which includes updates to the source and to the test cases along with the additional classes necessary for the test.
        Dhananjay Nene created issue -

          People

          • Assignee:
            Patrick Lightbody
            Reporter:
            Dhananjay Nene
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development