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

Stefan Bischof commented on FELIX-5844:
---------------------------------------

Hi,

you're right, setting the objectClass to null isn't the right way.

What i tried to do is to get the same result as

ServiceRegistry.getServiceReferences(null, "(osgi.jaxrs.resource=true)")

by using a @Reference annotated method.

I want to get these JAY-RS recource services

 
{code:java}
As JAX-RS resources have no common interface type they are instead registered 
with the osgi.jaxrs.resource service property with a value of "true". This 
property serves as a marker to the JAX-RS whiteboard runtime, indicating that 
this OSGi service should be hosted as a JAX-RS Whiteboard resource.
(OSGi Spec 151)¶    {code}
 

any idea?

 
 

> 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="(&amp;(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)

Reply via email to