[
https://issues.apache.org/jira/browse/FELIX-5844?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16464978#comment-16464978
]
David Jencks commented on FELIX-5844:
-------------------------------------
The behavior is per spec. Think of the object name as a declared property of
the service that happens to be one of the implemented interfaces (or classes).
Filtering on objectName=null is going to return no services since a service has
to have at least one objectName, and they can't be null.
What are you trying to do? Could you have all the jaxrs resources declare they
implement Object.class.getName()?
> 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)