[
https://issues.apache.org/jira/browse/FELIX-5320?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15422681#comment-15422681
]
Pierre De Rop commented on FELIX-5320:
--------------------------------------
... And in case you don't need to use a DM adapter, here is another kind of
example: Here, the MyComponent depends on MyDependency, and adds a dynamic
dependency , based on the MyDependency service properties (may be this scenario
is matching your one ?):
{code}
dm.add(createComponent()
.setImplementation(MyComponent.class)
.add(createServiceDependency()
.setService(MyDependency.class.getName(),
null).setCallbacks("setDependency", null).setRequired(true).setPropagate(true));
class MyComponent {
MyDependency dep;
Map props; // MyDependency service properties
void setDependency(MyDependency dep, Map props) {
this.dep = dep;
this.props = props;
}
void init(Component comp) {
// add here an extra dependency, based on this.props (on the
MyDependency service properties)
}
}
{code}
Here, the MyComponent is first injected with the MyDependency (and the
MyDependency service properties) in the setDependency callback.
And the init() method may then dynamically add another dependency, based on the
MyDependency service properties.
Notice that in the Activator, the setPropagate(true) method is called for the
dependency, in order to propagate the MyDependency service properties to the
MyComponent service properties. If you don't call setPropagate(true), then by
default the service dependency is not propagated to the MyComponent service
properties.
hope this helps ?
> Dependency Manager: adapter service propagates adaptee properties *after* the
> init (and start) callbacks are called
> -------------------------------------------------------------------------------------------------------------------
>
> Key: FELIX-5320
> URL: https://issues.apache.org/jira/browse/FELIX-5320
> Project: Felix
> Issue Type: Bug
> Components: Dependency Manager
> Affects Versions: org.apache.felix.dependencymanager-r8
> Reporter: Andrea Leofreddi
>
> In an adapter service, created using the createAdapterService method of
> DependencyManager class, one would expect to find the adaptee's properties
> being propagated to the adapter service itself, as stated in the
> documentation
> (http://felix.apache.org/documentation/subprojects/apache-felix-dependency-manager/reference/component-adapter.html).
> Instead no propagation happens, and both init and start methods won't see any
> propagated properties.
> After investigating I've found that propagations indeed happens (via
> AdapterServiceImpl's propagateAdapteeProperties) only after the callbacks are
> called.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)