Pierre De Rop | 3a00a21 | 2015-03-01 09:27:46 +0000 | [diff] [blame] | 1 | package org.apache.felix.dm.tracker; |
| 2 | /* |
| 3 | * Copyright (c) OSGi Alliance (2007, 2008). All Rights Reserved. |
| 4 | * |
| 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | * you may not use this file except in compliance with the License. |
| 7 | * You may obtain a copy of the License at |
| 8 | * |
| 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | * |
| 11 | * Unless required by applicable law or agreed to in writing, software |
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | * See the License for the specific language governing permissions and |
| 15 | * limitations under the License. |
| 16 | */ |
| 17 | |
| 18 | import org.osgi.framework.Bundle; |
| 19 | import org.osgi.framework.BundleEvent; |
| 20 | |
| 21 | /** |
| 22 | * The <code>BundleTrackerCustomizer</code> interface allows a |
| 23 | * <code>BundleTracker</code> to customize the <code>Bundle</code>s that are |
| 24 | * tracked. A <code>BundleTrackerCustomizer</code> is called when a bundle is |
| 25 | * being added to a <code>BundleTracker</code>. The |
| 26 | * <code>BundleTrackerCustomizer</code> can then return an object for the |
| 27 | * tracked bundle. A <code>BundleTrackerCustomizer</code> is also called when a |
| 28 | * tracked bundle is modified or has been removed from a |
| 29 | * <code>BundleTracker</code>. |
| 30 | * |
| 31 | * <p> |
| 32 | * The methods in this interface may be called as the result of a |
| 33 | * <code>BundleEvent</code> being received by a <code>BundleTracker</code>. |
| 34 | * Since <code>BundleEvent</code>s are received synchronously by the |
| 35 | * <code>BundleTracker</code>, it is highly recommended that implementations of |
| 36 | * these methods do not alter bundle states while being synchronized on any |
| 37 | * object. |
| 38 | * |
| 39 | * <p> |
| 40 | * The <code>BundleTracker</code> class is thread-safe. It does not call a |
| 41 | * <code>BundleTrackerCustomizer</code> while holding any locks. |
| 42 | * <code>BundleTrackerCustomizer</code> implementations must also be |
| 43 | * thread-safe. |
| 44 | * |
| 45 | * @ThreadSafe |
| 46 | * @version $Revision: 5874 $ |
| 47 | * @since 1.4 |
| 48 | */ |
| 49 | public interface BundleTrackerCustomizer { |
| 50 | /** |
| 51 | * A bundle is being added to the <code>BundleTracker</code>. |
| 52 | * |
| 53 | * <p> |
| 54 | * This method is called before a bundle which matched the search parameters |
| 55 | * of the <code>BundleTracker</code> is added to the |
| 56 | * <code>BundleTracker</code>. This method should return the object to be |
| 57 | * tracked for the specified <code>Bundle</code>. The returned object is |
| 58 | * stored in the <code>BundleTracker</code> and is available from the |
| 59 | * {@link BundleTracker#getObject(Bundle) getObject} method. |
| 60 | * |
| 61 | * @param bundle The <code>Bundle</code> being added to the |
| 62 | * <code>BundleTracker</code>. |
| 63 | * @param event The bundle event which caused this customizer method to be |
| 64 | * called or <code>null</code> if there is no bundle event associated |
| 65 | * with the call to this method. |
| 66 | * @return The object to be tracked for the specified <code>Bundle</code> |
| 67 | * object or <code>null</code> if the specified <code>Bundle</code> |
| 68 | * object should not be tracked. |
| 69 | */ |
| 70 | public Object addingBundle(Bundle bundle, BundleEvent event); |
| 71 | |
| 72 | /** marrs: A bundle has been added to the BundleTracker. */ |
| 73 | public void addedBundle(Bundle bundle, BundleEvent event, Object object); |
| 74 | |
| 75 | /** |
| 76 | * A bundle tracked by the <code>BundleTracker</code> has been modified. |
| 77 | * |
| 78 | * <p> |
| 79 | * This method is called when a bundle being tracked by the |
| 80 | * <code>BundleTracker</code> has had its state modified. |
| 81 | * |
| 82 | * @param bundle The <code>Bundle</code> whose state has been modified. |
| 83 | * @param event The bundle event which caused this customizer method to be |
| 84 | * called or <code>null</code> if there is no bundle event associated |
| 85 | * with the call to this method. |
| 86 | * @param object The tracked object for the specified bundle. |
| 87 | */ |
| 88 | public void modifiedBundle(Bundle bundle, BundleEvent event, |
| 89 | Object object); |
| 90 | |
| 91 | /** |
| 92 | * A bundle tracked by the <code>BundleTracker</code> has been removed. |
| 93 | * |
| 94 | * <p> |
| 95 | * This method is called after a bundle is no longer being tracked by the |
| 96 | * <code>BundleTracker</code>. |
| 97 | * |
| 98 | * @param bundle The <code>Bundle</code> that has been removed. |
| 99 | * @param event The bundle event which caused this customizer method to be |
| 100 | * called or <code>null</code> if there is no bundle event associated |
| 101 | * with the call to this method. |
| 102 | * @param object The tracked object for the specified bundle. |
| 103 | */ |
| 104 | public void removedBundle(Bundle bundle, BundleEvent event, |
| 105 | Object object); |
| 106 | } |