felix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Pierre De Rop (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (FELIX-5337) Filter-based dependencies working differently for annotations
Date Sat, 12 Nov 2016 23:13:59 GMT

    [ https://issues.apache.org/jira/browse/FELIX-5337?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15660449#comment-15660449

Pierre De Rop commented on FELIX-5337:

Ok; so the contract of the @ServiceDependency is the same as the "ServiceDependency.setService(Class
serviceType, String filter)" method in the DM API. So, the serviceType is inferred from the
bind method or from the class field.

Now, to allow to inject all services to a "bind(Object service)" callback, since we need to
internally use the  "ServiceDependency.setService(String filter)" method from the DM API,
I introduced a new "Any" marker interface in the ServiceDependency annotation, and you can
now set the "service" attribute to it. This will make sure that the service type won't be
inferred from the bind method parameters or from the field type:

void bindServices(Object allServices) {

Of course, you can specify a filter. In the following, all services having the foo=bar property
will be injected:

@ServiceDenpendency(service=Any.class, filter="(foo=bar)")
void bindServices(Object allServices) {

(committed patch in  revision 1769436). 

> Filter-based dependencies working differently for annotations
> -------------------------------------------------------------
>                 Key: FELIX-5337
>                 URL: https://issues.apache.org/jira/browse/FELIX-5337
>             Project: Felix
>          Issue Type: Bug
>    Affects Versions: dependencymanager-4.3.0
>            Reporter: J.W. Janssen
>            Assignee: Pierre De Rop
> I've got a "catch all" service dependency that simply wants to see *all* services being
registered. In the activator based implementation I simply express my dependency as {{createServiceDependency().setService("(objectClass=*)").setRequired(false).setCallbacks("addService",
"removeService")}} and I get all services I'm interested in (I mean: each and every registered
> However, if I rewrite my code to use annotations using {{@ServiceDependency(filter="(objectClass=*)",
required = false, removed = ...)}}, I suddenly do not see all services I expect: only services
that seem to be compatible with the class-space of the bundle my code lives in.

This message was sent by Atlassian JIRA

View raw message