Tom Pantelis created ARIES-1507:
-----------------------------------

             Summary: Extended filter is not included in OSGi service filter
                 Key: ARIES-1507
                 URL: https://issues.apache.org/jira/browse/ARIES-1507
             Project: Aries
          Issue Type: Bug
          Components: Blueprint
    Affects Versions: blueprint-core-1.4.2
            Reporter: Tom Pantelis


I'm using the extended filter, eg

<reference id="foo" interface="org.foo.Bar" ext:filter="type=one"/>

but it isn't getting included in the service filter and thus the correct 
service isn't (always) getting imported.

In AbstractServiceReferenceRecipe.getOsgiFilter:

public String getOsgiFilter() {
        if (filterRecipe != null && blueprintContainer instanceof 
BlueprintContainerImpl) {
            BlueprintContainerImpl.State state = ((BlueprintContainerImpl) 
blueprintContainer).getState();
            switch (state) {
                case InitialReferencesSatisfied:
                case WaitForInitialReferences2:
                case Create:
                case Created:
                    return createOsgiFilter(metadata, getExtendedOsgiFilter());
            }
        }
        return filter;
    }

it doesn't include a case for the Populated state which is when the 
BlueprintContainerImpl calls trackServiceReferences. So when init calls

   getBundleContextForServiceLookup().addServiceListener(this, getOsgiFilter());

the extended filter isn't included. Sometimes it does get the right service but 
it's timing and luck.

I can use the regular filter attribute but there are cases when I need to 
dynamically substitute it via cm-property-placeholder.  I'm unclear as to why 
AbstractPropertyPlaceholder substitutes the extended filter but not the regular 
one but that's another topic. 



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to