[
https://issues.apache.org/jira/browse/FELIX-5844?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16466441#comment-16466441
]
Carsten Ziegeler commented on FELIX-5844:
-----------------------------------------
The reference annotation or DS in general does not support this. DS supports
the most common use cases but not all possible ones in order to make DS easier
to use. For references in DS you must specify the service interface.
You can use a service tracker for this.
In general such questions are best asked on the OSGi dev list:
https://mail.osgi.org/mailman/listinfo/osgi-dev
> TargetFilter adds
> ------------------
>
> Key: FELIX-5844
> URL: https://issues.apache.org/jira/browse/FELIX-5844
> Project: Felix
> Issue Type: Bug
> Components: Declarative Services (SCR)
> Affects Versions: scr-2.1.0
> Reporter: Stefan Bischof
> Priority: Major
>
> I tryed to get all Services only by filtering the componentpropertys with the
> @Reference Annotation using the target
> But DependencyManager.setTargetFilter(String target, int minimumCardinality)
> add a additional classfilter using the interface
>
> Or is there any other way to get all Services by using the @Referenc
> annotation?
> MyClass.java
> {code:java}
> public static final String resourceFilter = "(&(objectClass=null)(" +
> JaxrsWhiteboardConstants.JAX_RS_RESOURCE
> + "=true))";
> @Reference(cardinality = ReferenceCardinality.MULTIPLE, policy =
> ReferencePolicy.DYNAMIC, target = resourceFilter)
> public void addResource(Object resource) {
> System.out.println("Add R " + resource);
> }
> {code}
>
> bundle.jar/OSGI-INF/org.bipolis.MyClass.xml
> {code:java}
> <?xml version="1.0" encoding="UTF-8"?>
> <scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.3.0"
> name="org.bipolis.MyClass" immediate="true" activate="activate">
> <implementation class="org.bipolis.MyClass"/>
> <reference name="Resource" cardinality="0..n" policy="dynamic"
> interface="java.lang.Object"
> target="(&(objectClass=null)(osgi.jaxrs.resource=true))"
> bind="addResource" unbind="removeResource"/>
> </scr:component> {code}
>
> DependencyManager.setTargetFilter -
> {code:java}
> line 2095:
> final StringBuilder classFilterSB = new StringBuilder();
> classFilterSB.append(OBJECTCLASS_CLAUSE);
> classFilterSB.append(m_dependencyMetadata.getInterface());
> classFilterSB.append(')');
> final String classFilterString = classFilterSB.toString();
>
> line 2126:
> initialReferenceFilterSB.append(classFilterString);
> {code}
> ServiceRegistry.getServiceReferences(String, SimpleFilter) line: 254
> uses correctly the empty classname;
> {code:java}
> className :null
> filter SimpleFilter
> :(&(objectClass=java.lang.Object)(&(objectClass=null)(osgi.jaxrs.resource=true))){code}
>
>
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)