[ 
https://issues.apache.org/jira/browse/FELIX-2688?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Clement Escoffier closed FELIX-2688.
------------------------------------

    
> iPojo "requires.filters" - Array object instead of Dictionary object
> --------------------------------------------------------------------
>
>                 Key: FELIX-2688
>                 URL: https://issues.apache.org/jira/browse/FELIX-2688
>             Project: Felix
>          Issue Type: Improvement
>          Components: iPOJO
>    Affects Versions: iPOJO-1.6.0
>            Reporter: Olivier Bigard
>            Assignee: Clement Escoffier
>             Fix For: iPOJO-1.8.0
>
>
> 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;
>       }

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to