On 30/03/15 20:31, Neil Bartlett wrote:
When you use the ServiceReference style of bind, bnd can’t rely on the
signature of the bind method to ascertain the service type you want.
Hence you have to add an extra hint by using the ‘service’ attribute.

It’s probably a bit dim for bnd to assume that we are binding to
services of type ServiceReference (which would presumably be passed as
type ServiceReference<ServiceReference<?>>… the mind boggles!) but there
you are.


Then file an issue on bnd to issue a warning when you try to use SR without setting the attribute... :-)

Neil


On 30 Mar 2015, at 19:15, Raymond Auge <raymond.a...@liferay.com
<mailto:raymond.a...@liferay.com>> wrote:

K, so it can't handled Object (or the anything case)?

ok! not a problem.

- Ray

On Mon, Mar 30, 2015 at 2:11 PM, BJ Hargrave <hargr...@us.ibm.com
<mailto:hargr...@us.ibm.com>> wrote:

    > From: Raymond Auge <raymond.a...@liferay.com
    <mailto:raymond.a...@liferay.com>>
    >
    > 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
    > osgi-dev@mail.osgi.org <mailto:osgi-dev@mail.osgi.org>
    > https://mail.osgi.org/mailman/listinfo/osgi-dev
    _______________________________________________
    OSGi Developer Mail List
    osgi-dev@mail.osgi.org <mailto:osgi-dev@mail.osgi.org>
    https://mail.osgi.org/mailman/listinfo/osgi-dev




--
*Raymond Augé*
<http://www.liferay.com/web/raymond.auge/profile> (@rotty3000)
Senior Software Architect *Liferay, Inc.*
<http://www.liferay.com/> (@Liferay)
Board Member & EEG Co-Chair, OSGi Alliance <http://osgi.org/>
(@OSGiAlliance)
_______________________________________________
OSGi Developer Mail List
osgi-dev@mail.osgi.org <mailto:osgi-dev@mail.osgi.org>
https://mail.osgi.org/mailman/listinfo/osgi-dev



_______________________________________________
OSGi Developer Mail List
osgi-dev@mail.osgi.org
https://mail.osgi.org/mailman/listinfo/osgi-dev


--
Ferry Huberts
_______________________________________________
OSGi Developer Mail List
osgi-dev@mail.osgi.org
https://mail.osgi.org/mailman/listinfo/osgi-dev

Reply via email to