OPS4J Pax Swissbox :: Tracker 1.3.1-redhat-1

org.ops4j.pax.swissbox.tracker
Class ServiceCollection<T>

java.lang.Object
  extended by org.ops4j.pax.swissbox.lifecycle.AbstractLifecycle
      extended by org.ops4j.pax.swissbox.tracker.ServiceCollection<T>
All Implemented Interfaces:
Iterable<T>, org.ops4j.pax.swissbox.lifecycle.Lifecycle

public class ServiceCollection<T>
extends org.ops4j.pax.swissbox.lifecycle.AbstractLifecycle
implements Iterable<T>

A collection of tracked services.

Since:
October 14, 2007
Author:
Alin Dreghiciu

Constructor Summary
ServiceCollection(org.osgi.framework.BundleContext context, Class<T> serviceClass)
          Creates a new service tracker collection, using the specified service context and the default service collection listener.
ServiceCollection(org.osgi.framework.BundleContext context, Class<T> serviceClass, ServiceCollectionListener<T> collectionListener)
          Creates a new service tracker collection, using the specified service context and listener.
 
Method Summary
 Iterator<T> iterator()
          Returns an iterator over the tracked services at the call point in time.
protected  void onStart()
          Creates a service tracker and opens it.
protected  void onStop()
          Closes the service tracker and releases resources.
 
Methods inherited from class org.ops4j.pax.swissbox.lifecycle.AbstractLifecycle
isStarted, start, stop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ServiceCollection

public ServiceCollection(org.osgi.framework.BundleContext context,
                         Class<T> serviceClass)
Creates a new service tracker collection, using the specified service context and the default service collection listener.

Parameters:
context - bundle context
serviceClass - class of the services to be tracked

ServiceCollection

public ServiceCollection(org.osgi.framework.BundleContext context,
                         Class<T> serviceClass,
                         ServiceCollectionListener<T> collectionListener)
Creates a new service tracker collection, using the specified service context and listener. Listener can be null, case when the default service collection listener is used.

Parameters:
context - bundle context
serviceClass - class of the services to be tracked
collectionListener - service events listener
Method Detail

iterator

public Iterator<T> iterator()
Returns an iterator over the tracked services at the call point in time. Note that a susequent call can produce a different list of services as the services are dynamic. If there are no services available returns an empty iterator.

Specified by:
iterator in interface Iterable<T>
See Also:
Iterable.iterator()

onStart

protected void onStart()
Creates a service tracker and opens it.

Specified by:
onStart in class org.ops4j.pax.swissbox.lifecycle.AbstractLifecycle
See Also:
AbstractLifecycle.onStart()

onStop

protected void onStop()
Closes the service tracker and releases resources.

Specified by:
onStop in class org.ops4j.pax.swissbox.lifecycle.AbstractLifecycle
See Also:
AbstractLifecycle.onStop()

OPS4J Pax Swissbox :: Tracker 1.3.1-redhat-1

Copyright © 2006-2011 OPS4J - Open Participation Software for Java. All Rights Reserved.