You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@felix.apache.org by "Stefan Bischof (JIRA)" <ji...@apache.org> on 2018/05/05 09:06:00 UTC
[jira] [Created] (FELIX-5844) TargetFilter adds
Stefan Bischof created FELIX-5844:
-------------------------------------
Summary: 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
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)