Richard S. Hall | c88fca3 | 2006-10-18 22:01:22 +0000 | [diff] [blame] | 1 | /* |
Richard S. Hall | 53e70d3 | 2008-08-01 19:31:32 +0000 | [diff] [blame^] | 2 | * $Header: /cvshome/build/org.osgi.framework/src/org/osgi/framework/ServiceListener.java,v 1.15 2007/02/20 00:16:30 hargrave Exp $ |
Richard S. Hall | c88fca3 | 2006-10-18 22:01:22 +0000 | [diff] [blame] | 3 | * |
Richard S. Hall | 53e70d3 | 2008-08-01 19:31:32 +0000 | [diff] [blame^] | 4 | * Copyright (c) OSGi Alliance (2000, 2007). All Rights Reserved. |
Richard S. Hall | c88fca3 | 2006-10-18 22:01:22 +0000 | [diff] [blame] | 5 | * |
| 6 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | * you may not use this file except in compliance with the License. |
| 8 | * You may obtain a copy of the License at |
| 9 | * |
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | * |
| 12 | * Unless required by applicable law or agreed to in writing, software |
| 13 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | * See the License for the specific language governing permissions and |
| 16 | * limitations under the License. |
| 17 | */ |
| 18 | |
| 19 | package org.osgi.framework; |
| 20 | |
| 21 | import java.util.EventListener; |
| 22 | |
| 23 | /** |
Richard S. Hall | 53e70d3 | 2008-08-01 19:31:32 +0000 | [diff] [blame^] | 24 | * A <code>ServiceEvent</code> listener. <code>ServiceListener</code> is a |
| 25 | * listener interface that may be implemented by a bundle developer. When a |
| 26 | * <code>ServiceEvent</code> is fired, it is synchronously delivered to a |
| 27 | * <code>ServiceListener</code>. The Framework may deliver |
| 28 | * <code>ServiceEvent</code> objects to a <code>ServiceListener</code> out |
| 29 | * of order and may concurrently call and/or reenter a |
| 30 | * <code>ServiceListener</code>. |
Richard S. Hall | c88fca3 | 2006-10-18 22:01:22 +0000 | [diff] [blame] | 31 | * |
| 32 | * <p> |
Richard S. Hall | c88fca3 | 2006-10-18 22:01:22 +0000 | [diff] [blame] | 33 | * A <code>ServiceListener</code> object is registered with the Framework |
| 34 | * using the <code>BundleContext.addServiceListener</code> method. |
| 35 | * <code>ServiceListener</code> objects are called with a |
| 36 | * <code>ServiceEvent</code> object when a service is registered, modified, or |
| 37 | * is in the process of unregistering. |
| 38 | * |
| 39 | * <p> |
| 40 | * <code>ServiceEvent</code> object delivery to <code>ServiceListener</code> |
| 41 | * objects is filtered by the filter specified when the listener was registered. |
| 42 | * If the Java Runtime Environment supports permissions, then additional |
| 43 | * filtering is done. <code>ServiceEvent</code> objects are only delivered to |
| 44 | * the listener if the bundle which defines the listener object's class has the |
| 45 | * appropriate <code>ServicePermission</code> to get the service using at |
Richard S. Hall | 53e70d3 | 2008-08-01 19:31:32 +0000 | [diff] [blame^] | 46 | * least one of the named classes under which the service was registered. |
Richard S. Hall | c88fca3 | 2006-10-18 22:01:22 +0000 | [diff] [blame] | 47 | * |
| 48 | * <p> |
| 49 | * <code>ServiceEvent</code> object delivery to <code>ServiceListener</code> |
| 50 | * objects is further filtered according to package sources as defined in |
| 51 | * {@link ServiceReference#isAssignableTo(Bundle, String)}. |
| 52 | * |
Richard S. Hall | c88fca3 | 2006-10-18 22:01:22 +0000 | [diff] [blame] | 53 | * @see ServiceEvent |
| 54 | * @see ServicePermission |
Richard S. Hall | 53e70d3 | 2008-08-01 19:31:32 +0000 | [diff] [blame^] | 55 | * @ThreadSafe |
| 56 | * @version $Revision: 1.15 $ |
Richard S. Hall | c88fca3 | 2006-10-18 22:01:22 +0000 | [diff] [blame] | 57 | */ |
| 58 | |
| 59 | public interface ServiceListener extends EventListener { |
| 60 | /** |
| 61 | * Receives notification that a service has had a lifecycle change. |
| 62 | * |
| 63 | * @param event The <code>ServiceEvent</code> object. |
| 64 | */ |
| 65 | public void serviceChanged(ServiceEvent event); |
| 66 | } |