You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@felix.apache.org by "Pierre De Rop (JIRA)" <ji...@apache.org> on 2016/08/26 23:08:20 UTC

[jira] [Comment Edited] (FELIX-5337) Filter-based dependencies working differently for annotations

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

Pierre De Rop edited comment on FELIX-5337 at 8/26/16 11:07 PM:
----------------------------------------------------------------

thanks for reporting.

I have reproduced the issue in https://github.com/pderop/dm.felix5337

In the project above, the two service.v1 and service.v2  bundles provides two versions of the same service.
Now, the catchall.withapi bundle uses the DM api and is able to lookup all services, including service.v1, and service.v2.

the catchall.withapi does this:

{code}
		dm.add(createComponent()
				.setImplementation(CatchAll.class)
				.add(createServiceDependency().setService("(objectClass=*)").setRequired(false).setCallbacks("addService", null)));
{code}

this is working fine. But the catchall.withannotation bundle does not work. It only catches one service, not all the others.
It does this:

{code}
	@ServiceDependency(filter="(objectClass=*)", required = false) 
	void addService(Object service, Map<String, String> properties) {
		System.out.println("Got service " + service + " with properties: " + properties);
	}
{code}

After investigating, it turns out that the issue is the following: the runtime infers the service type using the signature of the addService method. So, it internally uses the DM api and does this:

{code}
setService(Object.class, "(objectClass=*)")
{code}

and this does not work: we don't catch all services, only one.

So, to summarize, the following works (and this is what catchall.withapi does):

{code}
createServiceDependency().setService("(objectClass=*)").setRequired(false).setCallbacks(...)
{code}

but the following does not work (this is what the runtime internally does):

{code}
createServiceDependency().setService(Object.class, "(objectClass=*)").setRequired(false).setCallbacks(...)
{code}

I will continue to investigate this WE.


was (Author: pderop):
thanks for reporting.

I have reproduce the issue in https://github.com/pderop/dm.felix5337

In the project above, the two service.v1 and service.v2  bundles provides two versions of the same service.
Now, the catchall.withapi bundle uses the DM api and is able to lookup all services, including service.v1, and service.v2.

the catchall.withapi does this:

{code}
		dm.add(createComponent()
				.setImplementation(CatchAll.class)
				.add(createServiceDependency().setService("(objectClass=*)").setRequired(false).setCallbacks("addService", null)));
{code}

this is working fine. But the catchall.withannotation bundle does not work. It only catches one service, not all the others.
It does this:

{code}
	@ServiceDependency(filter="(objectClass=*)", required = false) 
	void addService(Object service, Map<String, String> properties) {
		System.out.println("Got service " + service + " with properties: " + properties);
	}
{code}

After investigating, it turns out that the issue is the following: the runtime infers the service type using the signature of the addService method. So, it internally uses the DM api and does this:

{code}
setService(Object.class, "(objectClass=*)")
{code}

and this does not work: we don't catch all services, only one.

So, to summarize, the following works (and this is what catchall.withapi does):

{code}
createServiceDependency().setService("(objectClass=*)").setRequired(false).setCallbacks(...)
{code}

but the following does not work (this is what the runtime internally does):

{code}
createServiceDependency().setService(Object.class, "(objectClass=*)").setRequired(false).setCallbacks(...)
{code}

I will continue to investigate this WE.

> 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 service).
> 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
(v6.3.4#6332)