Uploaded image for project: 'Felix'
  1. Felix
  2. FELIX-2688

iPojo "requires.filters" - Array object instead of Dictionary object

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: iPOJO-1.6.0
    • Fix Version/s: iPOJO-1.8.0
    • Component/s: iPOJO
    • Labels:
      None

      Description

      I tried to dynamically update the "filter" value of a "@Requires" annotation.
      The problem is that I'm using ConfigAdmin service to create my instances (for persistence need) and ConfigAdmin doesn't support Dictionary class...

      The improvement is to have an Array of key/value pairs where keys are the identity of the dependencies and the values are the filter of each dependency. This Array could be transformed into a Dictionary object at the begining of the "configure()" method of the "DependencyHandler" class.
      Imagine you have a class with following dependencies:

      @Requires(id="myFirstDep")
      private A a;
      @Requires(id=" mySecondDep ")
      private B b;

      Build the following property to inject in the instance:

      conf.put("requires.filters", new String[]

      {"myFirstDep", "(property1=value1)", "mySecondDep", "(property2=value2)"}

      );

      And the transformation from the Array to the Dictionary could be:

      private Dictionary getRequiresFilters(Object requiresFiltersValue) throws ConfigurationException
      {
      if (requiresFiltersValue != null && requiresFiltersValue.getClass().isArray())
      {
      String[] filtersArray = (String[]) requiresFiltersValue;
      if (filtersArray.length % 2 != 0)

      { throw new ConfigurationException("A requirement filter is invalid : " + requiresFiltersValue); }

      Dictionary requiresFilters = new Hashtable();
      for (int i = 0; i < filtersArray.length; i += 2)

      { requiresFilters.put(filtersArray[i], filtersArray[i+1]); }

      return requiresFilters;
      }

      return (Dictionary) requiresFiltersValue;
      }

        Attachments

          Activity

            People

            • Assignee:
              clement.escoffier Clement Escoffier
              Reporter:
              obigard Olivier Bigard
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: