[osgi-dev] DS bind with ServiceReference

2015-03-30 Thread Raymond Auge
Does anyone see why this would not be working?


@Reference(
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

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

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


Shouldn't this work?

-- 
*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
https://mail.osgi.org/mailman/listinfo/osgi-dev

Re: [osgi-dev] DS bind with ServiceReference

2015-03-30 Thread BJ Hargrave
 From: Raymond Auge raymond.a...@liferay.com

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

DS can handle any type a service is registered under including 
java.lang.Object. But it does require you tell DS the service type (either 
in the interface element if you write the XML or in the service element of 
the Reference annotation which can be inferred from the first argument of 
the annotated bind method) and for the service to be registered under that 
type.

What DS cannot handle is a reference to a service with an unspecified 
name. You seem to want to bind to any service whose name endsWith MBean 
(except for DynamicMBean). And DS is not designed to do that. That is 
better for a ServiceTracker.

 ok! not a problem.

 - Ray
 
 On Mon, Mar 30, 2015 at 2:11 PM, BJ Hargrave hargr...@us.ibm.com 
wrote:
  From: Raymond Auge 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. 
 
-- 

BJ Hargrave
Senior Technical Staff Member, IBM
OSGi Fellow and CTO of the OSGi Alliance
hargr...@us.ibm.com

office: +1 386 848 1781
mobile: +1 386 848 3788
___
OSGi Developer Mail List
osgi-dev@mail.osgi.org
https://mail.osgi.org/mailman/listinfo/osgi-dev

Re: [osgi-dev] DS bind with ServiceReference

2015-03-30 Thread BJ Hargrave
 From: Raymond Auge raymond.a...@liferay.com

 On Mon, Mar 30, 2015 at 2:41 PM, BJ Hargrave hargr...@us.ibm.com 
wrote:
  From: Raymond Auge raymond.a...@liferay.com 
 
  K, so it can't handled Object (or the anything case)? 
 
 DS can handle any type a service is registered under including 
 java.lang.Object. But it does require you tell DS the service type 
 (either in the interface element if you write the XML or in the 
 service element of the Reference annotation which can be inferred 
 from the first argument of the annotated bind method) and for the 
 service to be registered under that type. 
 
 What DS cannot handle is a reference to a service with an 
 unspecified name. You seem to want to bind to any service whose name
 endsWith MBean (except for DynamicMBean). And DS is not designed to 
 do that. That is better for a ServiceTracker.
 
 It was my _hope_ that most things you could do with a service 
 tracker you could do with a DS's bind method.

You can do most things. Probably 80-90% of the things most people want to 
do with services. But we know DS does not cover 100% of the use cases. And 
what you want to do falls outside what DS was designed to do.

 ultimately doesn't a DS component use a service tracker?

I don't think any DS impl uses a service tracker internally. And even if 
it does, that service tracker would be parameterized by the component 
description which requires the interface XML attribute specify the 
objectClass of the referenced service. 

 Anyway.. not arguing.. moving on...

:-)

-- 

BJ Hargrave
Senior Technical Staff Member, IBM
OSGi Fellow and CTO of the OSGi Alliance
hargr...@us.ibm.com

office: +1 386 848 1781
mobile: +1 386 848 3788
___
OSGi Developer Mail List
osgi-dev@mail.osgi.org
https://mail.osgi.org/mailman/listinfo/osgi-dev

Re: [osgi-dev] DS bind with ServiceReference

2015-03-30 Thread Raymond Auge
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 wrote:

  From: Raymond Auge 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
  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




-- 
*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
https://mail.osgi.org/mailman/listinfo/osgi-dev

Re: [osgi-dev] DS bind with ServiceReference

2015-03-30 Thread Raymond Auge
On Mon, Mar 30, 2015 at 2:41 PM, BJ Hargrave hargr...@us.ibm.com wrote:

  From: Raymond Auge raymond.a...@liferay.com

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

 DS can handle any type a service is registered under including
 java.lang.Object. But it does require you tell DS the service type (either
 in the interface element if you write the XML or in the service element of
 the Reference annotation which can be inferred from the first argument of
 the annotated bind method) and for the service to be registered under that
 type.

 What DS cannot handle is a reference to a service with an unspecified
 name. You seem to want to bind to any service whose name endsWith MBean
 (except for DynamicMBean). And DS is not designed to do that. That is
 better for a ServiceTracker.


It was my _hope_ that most things you could do with a service tracker you
could do with a DS's bind method.

ultimately doesn't a DS component use a service tracker?

Anyway.. not arguing.. moving on...

Thx everyone,
- Ray



  ok! not a problem.

  - Ray
 
  On Mon, Mar 30, 2015 at 2:11 PM, BJ Hargrave hargr...@us.ibm.com
 wrote:
   From: Raymond Auge 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.
 
 --

  *BJ Hargrave*
 Senior Technical Staff Member, IBM
 OSGi Fellow and CTO of the *OSGi Alliance* http://www.osgi.org/
 *hargr...@us.ibm.com* hargr...@us.ibm.com

 office: +1 386 848 1781
 mobile: +1 386 848 3788


 ___
 OSGi Developer Mail List
 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
https://mail.osgi.org/mailman/listinfo/osgi-dev

Re: [osgi-dev] DS bind with ServiceReference

2015-03-30 Thread BJ Hargrave
 From: Raymond Auge 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
 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

Re: [osgi-dev] DS bind with ServiceReference

2015-03-30 Thread Neil Bartlett
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 
ServiceReferenceServiceReference?… the mind boggles!) but there you are.

Neil


 On 30 Mar 2015, at 19:15, Raymond Auge 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 
  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 
 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
 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