Class BundleHookBundleTracker<T>
- java.lang.Object
-
- org.osgi.util.tracker.BundleTracker
-
- org.apache.aries.util.tracker.hook.BundleHookBundleTracker<T>
-
- All Implemented Interfaces:
org.osgi.util.tracker.BundleTrackerCustomizer
public class BundleHookBundleTracker<T> extends org.osgi.util.tracker.BundleTrackerThe Tracked and AbstractTracked inner classes are copied from felix framework 4.0.1.
-
-
Constructor Summary
Constructors Constructor Description BundleHookBundleTracker(org.osgi.framework.BundleContext context, int stateMask, org.osgi.util.tracker.BundleTrackerCustomizer customizer)Create aBundleTrackerfor bundles whose state is present in the specified state mask.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.ObjectaddingBundle(org.osgi.framework.Bundle bundle, org.osgi.framework.BundleEvent event)Default implementation of theBundleTrackerCustomizer.addingBundlemethod.voidclose()Close thisBundleTracker.org.osgi.framework.Bundle[]getBundles()Return an array ofBundles for all bundles being tracked by thisBundleTracker.TgetObject(org.osgi.framework.Bundle bundle)Returns the customized object for the specifiedBundleif the specified bundle is being tracked by thisBundleTracker.java.util.Map<org.osgi.framework.Bundle,T>getTracked()Return aMapwith theBundles and customized objects for all bundles being tracked by thisBundleTracker.intgetTrackingCount()Returns the tracking count for thisBundleTracker.booleanisEmpty()Return if thisBundleTrackeris empty.voidmodifiedBundle(org.osgi.framework.Bundle bundle, org.osgi.framework.BundleEvent event, java.lang.Object object)Default implementation of theBundleTrackerCustomizer.modifiedBundlemethod.voidopen()Open thisBundleTrackerand begin tracking bundles.voidremove(org.osgi.framework.Bundle bundle)Remove a bundle from thisBundleTracker.voidremovedBundle(org.osgi.framework.Bundle bundle, org.osgi.framework.BundleEvent event, java.lang.Object object)Default implementation of theBundleTrackerCustomizer.removedBundlemethod.intsize()Return the number of bundles being tracked by thisBundleTracker.
-
-
-
Constructor Detail
-
BundleHookBundleTracker
public BundleHookBundleTracker(org.osgi.framework.BundleContext context, int stateMask, org.osgi.util.tracker.BundleTrackerCustomizer customizer)Create aBundleTrackerfor bundles whose state is present in the specified state mask.Bundles whose state is present on the specified state mask will be tracked by this
BundleTracker.- Parameters:
context- TheBundleContextagainst which the tracking is done.stateMask- The bit mask of theORing of the bundle states to be tracked.customizer- The customizer object to call when bundles are added, modified, or removed in thisBundleTracker. If customizer isnull, then thisBundleTrackerwill be used as theBundleTrackerCustomizerand thisBundleTrackerwill call theBundleTrackerCustomizermethods on itself.- See Also:
Bundle.getState()
-
-
Method Detail
-
open
public void open()
Open thisBundleTrackerand begin tracking bundles.Bundle which match the state criteria specified when this
BundleTrackerwas created are now tracked by thisBundleTracker.- Overrides:
openin classorg.osgi.util.tracker.BundleTracker- Throws:
java.lang.IllegalStateException- If theBundleContextwith which thisBundleTrackerwas created is no longer valid.java.lang.SecurityException- If the caller and this class do not have the appropriateAdminPermission[context bundle,LISTENER], and the Java Runtime Environment supports permissions.
-
close
public void close()
Close thisBundleTracker.This method should be called when this
BundleTrackershould end the tracking of bundles.This implementation calls
getBundles()to get the list of tracked bundles to remove.- Overrides:
closein classorg.osgi.util.tracker.BundleTracker
-
addingBundle
public java.lang.Object addingBundle(org.osgi.framework.Bundle bundle, org.osgi.framework.BundleEvent event)Default implementation of theBundleTrackerCustomizer.addingBundlemethod.This method is only called when this
BundleTrackerhas been constructed with anull BundleTrackerCustomizerargument.This implementation simply returns the specified
Bundle.This method can be overridden in a subclass to customize the object to be tracked for the bundle being added.
- Specified by:
addingBundlein interfaceorg.osgi.util.tracker.BundleTrackerCustomizer<T>- Overrides:
addingBundlein classorg.osgi.util.tracker.BundleTracker- Parameters:
bundle- TheBundlebeing added to thisBundleTrackerobject.event- The bundle event which caused this customizer method to be called ornullif there is no bundle event associated with the call to this method.- Returns:
- The specified bundle.
- See Also:
BundleTrackerCustomizer.addingBundle(Bundle, BundleEvent)
-
modifiedBundle
public void modifiedBundle(org.osgi.framework.Bundle bundle, org.osgi.framework.BundleEvent event, java.lang.Object object)Default implementation of theBundleTrackerCustomizer.modifiedBundlemethod.This method is only called when this
BundleTrackerhas been constructed with anull BundleTrackerCustomizerargument.This implementation does nothing.
- Specified by:
modifiedBundlein interfaceorg.osgi.util.tracker.BundleTrackerCustomizer<T>- Overrides:
modifiedBundlein classorg.osgi.util.tracker.BundleTracker- Parameters:
bundle- TheBundlewhose state has been modified.event- The bundle event which caused this customizer method to be called ornullif there is no bundle event associated with the call to this method.object- The customized object for the specified Bundle.- See Also:
BundleTrackerCustomizer.modifiedBundle(Bundle, BundleEvent, Object)
-
removedBundle
public void removedBundle(org.osgi.framework.Bundle bundle, org.osgi.framework.BundleEvent event, java.lang.Object object)Default implementation of theBundleTrackerCustomizer.removedBundlemethod.This method is only called when this
BundleTrackerhas been constructed with anull BundleTrackerCustomizerargument.This implementation does nothing.
- Specified by:
removedBundlein interfaceorg.osgi.util.tracker.BundleTrackerCustomizer<T>- Overrides:
removedBundlein classorg.osgi.util.tracker.BundleTracker- Parameters:
bundle- TheBundlebeing removed.event- The bundle event which caused this customizer method to be called ornullif there is no bundle event associated with the call to this method.object- The customized object for the specified bundle.- See Also:
BundleTrackerCustomizer.removedBundle(Bundle, BundleEvent, Object)
-
getBundles
public org.osgi.framework.Bundle[] getBundles()
Return an array ofBundles for all bundles being tracked by thisBundleTracker.- Overrides:
getBundlesin classorg.osgi.util.tracker.BundleTracker- Returns:
- An array of
Bundles ornullif no bundles are being tracked.
-
getObject
public T getObject(org.osgi.framework.Bundle bundle)
Returns the customized object for the specifiedBundleif the specified bundle is being tracked by thisBundleTracker.- Overrides:
getObjectin classorg.osgi.util.tracker.BundleTracker- Parameters:
bundle- TheBundlebeing tracked.- Returns:
- The customized object for the specified
Bundleornullif the specifiedBundleis not being tracked.
-
remove
public void remove(org.osgi.framework.Bundle bundle)
Remove a bundle from thisBundleTracker. The specified bundle will be removed from thisBundleTracker. If the specified bundle was being tracked then theBundleTrackerCustomizer.removedBundlemethod will be called for that bundle.- Overrides:
removein classorg.osgi.util.tracker.BundleTracker- Parameters:
bundle- TheBundleto be removed.
-
size
public int size()
Return the number of bundles being tracked by thisBundleTracker.- Overrides:
sizein classorg.osgi.util.tracker.BundleTracker- Returns:
- The number of bundles being tracked.
-
getTrackingCount
public int getTrackingCount()
Returns the tracking count for thisBundleTracker. The tracking count is initialized to 0 when thisBundleTrackeris opened. Every time a bundle is added, modified or removed from thisBundleTrackerthe tracking count is incremented.The tracking count can be used to determine if this
BundleTrackerhas added, modified or removed a bundle by comparing a tracking count value previously collected with the current tracking count value. If the value has not changed, then no bundle has been added, modified or removed from thisBundleTrackersince the previous tracking count was collected.- Overrides:
getTrackingCountin classorg.osgi.util.tracker.BundleTracker- Returns:
- The tracking count for this
BundleTrackeror -1 if thisBundleTrackeris not open.
-
getTracked
public java.util.Map<org.osgi.framework.Bundle,T> getTracked()
Return aMapwith theBundles and customized objects for all bundles being tracked by thisBundleTracker.- Overrides:
getTrackedin classorg.osgi.util.tracker.BundleTracker- Returns:
- A
Mapwith theBundles and customized objects for all services being tracked by thisBundleTracker. If no bundles are being tracked, then the returned map is empty. - Since:
- 1.5
-
isEmpty
public boolean isEmpty()
Return if thisBundleTrackeris empty.- Overrides:
isEmptyin classorg.osgi.util.tracker.BundleTracker- Returns:
trueif thisBundleTrackeris not tracking any bundles.- Since:
- 1.5
-
-