001 /*
002 * Copyright (c) OSGi Alliance (2002, 2008). All Rights Reserved.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016 package org.osgi.service.wireadmin;
017
018 /**
019 * Listener for Wire Admin Events.
020 *
021 * <p>
022 * <code>WireAdminListener</code> objects are registered with the Framework
023 * service registry and are notified with a <code>WireAdminEvent</code> object
024 * when an event is broadcast.
025 * <p>
026 * <code>WireAdminListener</code> objects can inspect the received
027 * <code>WireAdminEvent</code> object to determine its type, the <code>Wire</code>
028 * object with which it is associated, and the Wire Admin service that
029 * broadcasts the event.
030 *
031 * <p>
032 * <code>WireAdminListener</code> objects must be registered with a service
033 * property {@link WireConstants#WIREADMIN_EVENTS} whose value is a bitwise OR
034 * of all the event types the listener is interested in receiving.
035 * <p>
036 * For example:
037 *
038 * <pre>
039 * Integer mask = new Integer(WIRE_TRACE | WIRE_CONNECTED | WIRE_DISCONNECTED);
040 * Hashtable ht = new Hashtable();
041 * ht.put(WIREADMIN_EVENTS, mask);
042 * context.registerService(WireAdminListener.class.getName(), this, ht);
043 * </pre>
044 *
045 * If a <code>WireAdminListener</code> object is registered without a service
046 * property {@link WireConstants#WIREADMIN_EVENTS}, then the
047 * <code>WireAdminListener</code> will receive no events.
048 *
049 * <p>
050 * Security Considerations. Bundles wishing to monitor <code>WireAdminEvent</code>
051 * objects will require <code>ServicePermission[WireAdminListener,REGISTER]</code>
052 * to register a <code>WireAdminListener</code> service. Since
053 * <code>WireAdminEvent</code> objects contain <code>Wire</code> objects, care must
054 * be taken in assigning permission to register a <code>WireAdminListener</code>
055 * service.
056 *
057 * @see WireAdminEvent
058 *
059 * @version $Revision: 5673 $
060 */
061 public interface WireAdminListener {
062 /**
063 * Receives notification of a broadcast <code>WireAdminEvent</code> object.
064 *
065 * The event object will be of an event type specified in this
066 * <code>WireAdminListener</code> service's
067 * {@link WireConstants#WIREADMIN_EVENTS} service property.
068 *
069 * @param event The <code>WireAdminEvent</code> object.
070 */
071 void wireAdminEvent(WireAdminEvent event);
072 }