[
https://issues.apache.org/jira/browse/FELIX-4305?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Pierre De Rop updated FELIX-4305:
---------------------------------
Attachment: FELIX-4305.patch-withSetPropagate
Attached a much more simpler patch in FELIX-4305.patch-withSetPropagate, which
is using the ServiceDependency.setPropagate(Object instance, String method).
However, when using service dependency propagation, I noticed that in
ServiceDependencyImpl._modifiedService(ServiceReference ref, Object service),
we first propagate the dependency service properties to the component's service
properties; and after, we invoke the "change" callback.
So, I may be wrong but it sounds like it would be better to first invoke the
"changed" callback, and after, propagate the dependency service properties to
the component' service properties.
So, I did this patch in ServiceDependencyImpl:
private void _modifiedService(ServiceReference ref, Object service) {
Object[] services;
synchronized (this) {
services = m_services.toArray();
}
for (int i = 0; i < services.length; i++) {
DependencyService ds = (DependencyService) services[i];
if (ds.isRegistered()) {
invokeChanged(ds, ref, service);
}
ds.dependencyChanged(this); // this propagates dependency
properties to the component's service properties.
}
}
instead of
private void _modifiedService(ServiceReference ref, Object service) {
Object[] services;
synchronized (this) {
services = m_services.toArray();
}
for (int i = 0; i < services.length; i++) {
DependencyService ds = (DependencyService) services[i];
ds.dependencyChanged(this);
if (ds.isRegistered()) {
invokeChanged(ds, ref, service);
}
}
}
This ensures that the adapter is first notified in its "change" callback (if
specified), and then after, the adapter service properties are propagated.
I verified that all our tests are all passing OK with this new patch.
> DependencyMananer Adapters - service properties propagation
> -----------------------------------------------------------
>
> Key: FELIX-4305
> URL: https://issues.apache.org/jira/browse/FELIX-4305
> Project: Felix
> Issue Type: Improvement
> Components: Dependency Manager
> Reporter: Pierre De Rop
> Attachments: FELIX-4305.patch, FELIX-4305.patch-withSetPropagate
>
>
> When creating an adapter service, the adapter service inherits the service
> properties of the adapted service (aspect, service id, service rank and
> object class excluded) and can have additional properties specified.
> For example:
>
> Service A [ objectClass=X, service.id=1, name=Piet ]
> A serviceAdapter on A looks like:
> ServiceAdapter A [ objectClass=Y, service.id=2, name=Piet, system=X]
> It inherits the non-identifying service properties from A (name), and can
> have additional properties defined (system).
>
> Now I change the service properties for Service A. After this, it looks like:
> Service A [ objectClass=X, service.id=1, name=Sint ]
>
> But after this change, the service properties modification is not propagated
> to the ServiceAdapter, which is currently unaffected:
> ServiceAdapter A [ objectClass=Y, service.id=2, name=Piet, system=X]
> It is desirable to propagate the changed properties of "A" to the
> "ServiceAdapter A", so it then becomes:
> ServiceAdapter A [ objectClass=Y, service.id=2, name=Sint, system=X]
> It is then the responsibility of clients depending on the service adapter to
> listen to service properties change events (using the ServiceDependency
> "change" callback).
--
This message was sent by Atlassian JIRA
(v6.1#6144)