Yes. Each time a bundle calls ServiceObjects.getService for a prototype 
scope service, it gets a new object. So you don't really need multiple 
trackers but the tracker design normally gets the service object once and 
tracks it. So this means that each tracker instance will track one service 
object for a service (if you customize the tracker to use ServiceObjects.)
-- 

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




From:   Raymond Auge <raymond.a...@liferay.com>
To:     OSGi Developer Mail List <osgi-dev@mail.osgi.org>
Date:   2014/10/17 16:12
Subject:        Re: [osgi-dev] prototype scope and service trackers
Sent by:        osgi-dev-boun...@mail.osgi.org



On Fri, Oct 17, 2014 at 4:01 PM, BJ Hargrave <hargr...@us.ibm.com> wrote:
More detail is needed. Where "within a ServiceTracker" are you putting 
this? If it is in addingService,

yes exactly!
 
then you will only ever get one service object per service, so the change 
doesn't really do anything. 

well it does in that you now naturally allow trackers to obtain prototype 
scoped objects
 
And you would also have to pair this with a change to removedService to 
release the service through the ServiceObjects object. 

Naturally!
 

If the point is that if multiple trackers for a service are opened within 
a bundle, then, yes, each such tracker could obtain a different service 
object for prototype scope services. 

Exactly what I was wondering, and why? Because in a case `similar` to DS 
where multiple components in a bundle all request the same service, they 
would each have their own tracker, if that service were of prototype 
scope, I'm guessing each would be getting their own instance.... If I've 
understood correctly.

- Ray
 
-- 

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




From:        Raymond Auge <raymond.a...@liferay.com> 
To:        OSGi Developer Mail List <osgi-dev@mail.osgi.org> 
Date:        2014/10/17 15:16 
Subject:        [osgi-dev] prototype scope and service trackers 
Sent by:        osgi-dev-boun...@mail.osgi.org 




Is it fair to say that, within a ServiceTracker I can safely replace: 

S s = bundle.getService(servlceReference); 

with 

ServiceObjects<S> so = bundle.getServiceObjects(serviceReference); 
S s = so.getService(); 


which would mean that only where a bundle implemented more than one such 
tracker could the bundle ever get more than one instance! Correct? 

-- 
Raymond Augé (@rotty3000) 
Senior Software Architect 
Liferay, Inc. (@Liferay) 
_______________________________________________
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é (@rotty3000)
Senior Software Architect
Liferay, Inc. (@Liferay)
_______________________________________________
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

Reply via email to