Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-113747

ConfigurableUtil does not take into account bnd's "-metatype-inherit"

    Details

      Description

      BND allows use of "-metatype-inherit" configuration option.

      This configuration option allows inheritance for example

       

      @ExtendedObjectClassDefinition(
              category = "some-category",
              scope = ExtendedObjectClassDefinition.Scope.SYSTEM
      )
      public interface BaseConfiguration {
      
          @Meta.AD
          public Boolean enabled();
      
      }
      
      @ExtendedObjectClassDefinition(
              category = "some-category",
              scope = ExtendedObjectClassDefinition.Scope.SYSTEM
      )
      public interface SomeConfiguration extends BaseConfiguration {
      
          @Meta.AD
          public Long id();
      
      }
      

      Problem is that com.liferay.portal.configuration.metatype.bnd.util.ConfigurableUtil does not take that option into account.

      Method _generateSnapshotClassData is finding interface methods by using

      Method[] declaredMethods = interfaceClass.getDeclaredMethods();

      which of course only finds declared methods - not mehtods inherited from superclasses.

       

      Please

       

      1) do something like this

      Method[] declaredMethods = getMethods(interfaceClass);
      
      private static Method[] getMethods(Class<?> aClass) {
          final List<Method> methods = new ArrayList<>();
      
          walk(aClass, methods);
      
          return methods.toArray(new Method[0]);
      }
      
      /* honors natural order of declared methods - super of super -> super -> this */
      private static void walk(Class<?> aClass, List<Method> methods) {
          methods.addAll(0, Arrays.asList(aClass.getDeclaredMethods()));
          for (Class<?> i : aClass.getInterfaces()) {
              walk(i, methods);
          }
      }
      

      2) or at least change

      Method[] declaredMethods = getMethods(interfaceClass);
      

       to be

      Method[] declaredMethods = interfaceClass.getMethods();
      

       

      Option 1) would be prefered as it would, in configuration admin GUI, first render configuration from super class then from class that extends it and so on.

       

      Also, to be completely able to do inheritane please add

      @Inherited to ExtendedObjectClassDefinition annotation.

       

      Thank you.

       

        Attachments

          Activity

            People

            Assignee:
            support-lep@liferay.com SE Support
            Reporter:
            mgamulin@croz.hr Martin Gamulin
            Participants of an Issue:
            Recent user:
            Martin Gamulin
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Days since last comment:
              42 weeks, 3 days ago

                Packages

                Version Package