Yes, I would still suggest using a ServiceTracker for short lived uses. Just remember to close the tracker (best in a finally block) so the tracker's ServiceListener is not left registered.
It is always important to close trackers before they go out of scope. BJ Hargrave Senior Technical Staff Member, IBM OSGi Fellow and CTO of the OSGi Alliance [EMAIL PROTECTED] Office: +1 386 848 1781 Mobile: +1 386 848 3788 ----- Original Message ----- From: "Steven E. Harris" [EMAIL PROTECTED] Sent: 05/08/2007 10:57 AM To: OSGi Developer Mail List <[email protected]> Subject: Re: [osgi-dev] Expecting NullPointerExceptions from ServiceReferences -- style tips BJ Hargrave <[EMAIL PROTECTED]> writes: > First best practice is to use ServiceTracker instead of using the > service API directly. I had thought of that, as I use ServiceTrackers elsewhere, but what I omitted from this example is that the filter passed to getServiceReferences() is created on the fly with each pass through this function. I'm looking for a "snapshot" query, not a long-lived collection of matching references. Would you still recommend use of a ServiceTracker for a case like this? > 3) No Great, I'll revise that. Thanks for your feedback. -- Steven E. Harris _______________________________________________ OSGi Developer Mail List [email protected] http://www2.osgi.org/mailman/listinfo/osgi-dev _______________________________________________ OSGi Developer Mail List [email protected] http://www2.osgi.org/mailman/listinfo/osgi-dev
