Pierre De Rop created FELIX-6888:
------------------------------------

             Summary: BundleDependency.setPropagate(instance, method) is ignored
                 Key: FELIX-6888
                 URL: https://issues.apache.org/jira/browse/FELIX-6888
             Project: Felix
          Issue Type: Bug
          Components: Dependency Manager
            Reporter: Pierre De Rop


h3. Problem

{{BundleDependencyImpl}} redeclares the fields {{m_propagate}}, 
{{m_propagateCallbackInstance}} and {{m_propagateCallbackMethod}}, which are 
already defined in {{AbstractDependency}}. The fields of the subclass hide 
those of the parent class.

{{setPropagate(Object instance, String method)}} is inherited from 
{{AbstractDependency}} and writes the parent fields, while 
{{BundleDependencyImpl.getProperties()}} reads the subclass fields, which are 
always {{null}}. As a result, the propagation callback is never invoked, and 
all the bundle manifest headers are propagated as service properties.

h3. Example

{code:java}
public class Activator extends DependencyActivatorBase {
    @Override
    public void init(BundleContext context, DependencyManager dm) throws 
Exception {
        dm.add(createComponent()
            .setInterface(MyService.class.getName(), null)
            .setImplementation(MyServiceImpl.class)
            .add(createBundleDependency()
                .setBundles(...)
                .setPropagate(this, "props")));
    }

// Expected to be called to provide the service properties
Dictionary<String, Object> props(Bundle bundle) {
    Dictionary<String, Object> d = new Hashtable<>();
    d.put("bundle.name", bundle.getSymbolicName());
    return d;
}
}
{code}

h3. Actual behavior

- The {{props}} callback is never invoked.
- {{isPropagated()}} returns {{true}}, and every header of the bundle manifest 
({{Import-Package}}, {{Export-Package}}, etc.) is published as a property of 
the registered service.

h3. Expected behavior

- When {{setPropagate(instance, method)}} is used on a {{BundleDependency}}, 
the callback is invoked and only the properties it returns are published with 
the service, as is the case for the other dependency types.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to