> From: Raymond Auge <[email protected]>
> 
> Does anyone see why this would not be working?
> 
> 
> @Reference(

I'll assume this is the OSGi annotation.

>     cardinality = ReferenceCardinality.MULTIPLE,
>     name = "MBean",
>     policy = ReferencePolicy.DYNAMIC,
>     policyOption = ReferencePolicyOption.GREEDY,
>     target = "(&(jmx.objectname=*)(objectClass=*MBean)(!
> (objectClass=javax.management.DynamicMBean)))"
> )
> protected void addMBean(ServiceReference<?> serviceReference) { .. }

> The XML generated is:
> 
> <reference 
>     name="MBean" 
>     cardinality="0..n" 
>     policy="dynamic" 
>     interface="org.osgi.framework.ServiceReference" 

The generated XML shows that the assumed serivce type is ServiceReference. 
You probably need to set the service element in the annotation to set the 
actual type of the service. This will set the interface XML attribute 
properly. The interface attribute is the objectClass of the referenced 
service.

interface: "Fully qualified name of the class that is used by the 
component to access the service. The service provided to the component 
must be type compatible with this class. That is, the component must be 
able to cast the service object to this class. A service must be 
registered under this name to be considered for the set of target 
services.

The Reference annotation will use the type of the first argument of the 
anno-
tated method or the type of the annotated field to determine the service 
value."

>     target="(&amp;(jmx.objectname=*)(objectClass=*MBean)(!
> (objectClass=javax.management.DynamicMBean)))" 

Putting objectClass in the target does not override the objectClass stated 
by the interface attribute and can be in conflict.

>     bind="addMBean" 
>     unbind="removeMBean" 
>     policy-option="greedy"
> />
> 

> Shouldn't this work?

DS is not set up for this. It expects you to name a specific service type. 
Not any type whose registered service name ends with something.

> 
> -- 
> Raymond Augé (@rotty3000)
> Senior Software Architect Liferay, Inc. (@Liferay)
> Board Member & EEG Co-Chair, OSGi Alliance (@OSGiAlliance)
> _______________________________________________
> OSGi Developer Mail List
> [email protected]
> https://mail.osgi.org/mailman/listinfo/osgi-dev
_______________________________________________
OSGi Developer Mail List
[email protected]
https://mail.osgi.org/mailman/listinfo/osgi-dev

Reply via email to