org.apache.felix.ipojo.handler.extender
Class BundleTracker

java.lang.Object
  extended by org.apache.felix.ipojo.handler.extender.BundleTracker
Direct Known Subclasses:
ExtenderManager

public abstract class BundleTracker
extends Object

This is a very simple bundle tracker utility class that tracks active bundles. The tracker must be given a bundle context upon creation, which it uses to listen for bundle events. The bundle tracker must be opened to track objects and closed when it is no longer needed. This class is abstract, which means in order to use it you must create a subclass of it. Subclasses must implement the addedBundle() and removedBundle() methods, which can be used to perform some custom action upon the activation or deactivation of bundles. Since this tracker is quite simple, its concurrency control approach is also simplistic. This means that subclasses should take great care to ensure that their addedBundle() and removedBundle() methods are very simple and do not do anything to change the state of any bundles.

Author:
Felix Project Team

Constructor Summary
BundleTracker(BundleContext context)
          Constructs a bundle tracker object that will use the specified bundle context.
 
Method Summary
protected abstract  void addedBundle(Bundle bundle)
          Subclasses must implement this method; it can be used to perform actions upon the activation of a bundle.
 void close()
          Call this method to stop the tracking of active bundles.
 Bundle[] getBundles()
          Returns the current set of active bundles.
 void open()
          Call this method to start the tracking of active bundles.
protected abstract  void removedBundle(Bundle bundle)
          Subclasses must implement this method; it can be used to perform actions upon the deactivation of a bundle.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BundleTracker

public BundleTracker(BundleContext context)
Constructs a bundle tracker object that will use the specified bundle context.

Parameters:
context - the bundle context to use to track bundles.
Method Detail

getBundles

public Bundle[] getBundles()
Returns the current set of active bundles.

Returns:
the current set of active bundles.

open

public void open()
Call this method to start the tracking of active bundles.


close

public void close()
Call this method to stop the tracking of active bundles.


addedBundle

protected abstract void addedBundle(Bundle bundle)
Subclasses must implement this method; it can be used to perform actions upon the activation of a bundle. Subclasses should keep this method implementation as simple as possible and should not cause the change in any bundle state to avoid concurrency issues.

Parameters:
bundle - the bundle being added to the active set.

removedBundle

protected abstract void removedBundle(Bundle bundle)
Subclasses must implement this method; it can be used to perform actions upon the deactivation of a bundle. Subclasses should keep this method implementation as simple as possible and should not cause the change in any bundle state to avoid concurrency issues.

Parameters:
bundle - the bundle being removed from the active set.


Copyright © 2006-2011 Apache Software Foundation. All Rights Reserved.