KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > osgi > service > event > EventHandler


1 /*
2  * $Header: /cvshome/build/org.osgi.service.event/src/org/osgi/service/event/EventHandler.java,v 1.10 2006/07/11 16:43:59 hargrave Exp $
3  *
4  * Copyright (c) OSGi Alliance (2005, 2006). All Rights Reserved.
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.service.event;
20
21 /**
22  * Listener for Events.
23  *
24  * <p>
25  * <code>EventHandler</code> objects are registered with the Framework service
26  * registry and are notified with an <code>Event</code> object when an
27  * event is sent or posted.
28  * <p>
29  * <code>EventHandler</code> objects can inspect the received
30  * <code>Event</code> object to determine its topic and properties.
31  *
32  * <p>
33  * <code>EventHandler</code> objects must be registered with a service
34  * property {@link EventConstants#EVENT_TOPIC} whose value is the list of
35  * topics in which the event handler is interesed.
36  * <p>
37  * For example:
38  *
39  * <pre>
40  * String[] topics = new String[] {EventConstants.EVENT_TOPIC, &quot;com/isv/*&quot;};
41  * Hashtable ht = new Hashtable();
42  * ht.put(EVENT_TOPIC, topics);
43  * context.registerService(EventHandler.class.getName(), this, ht);
44  * </pre>
45  * Event Handler services can also be registered with an {@link EventConstants#EVENT_FILTER}
46  * service propery to further filter the events. If the syntax of this filter is invalid,
47  * then the Event Handler must be ignored by the Event Admin service. The Event Admin
48  * service should log a warning.
49  * <p>
50  * Security Considerations. Bundles wishing to monitor <code>Event</code>
51  * objects will require <code>ServicePermission[EventHandler,REGISTER]</code>
52  * to register an <code>EventHandler</code> service. The bundle must also have
53  * <code>TopicPermission[topic,SUBSCRIBE]</code> for the topic specified in the
54  * event in order to receive the event.
55  *
56  * @see Event
57  *
58  * @version $Revision: 1.10 $
59  */

60 public interface EventHandler {
61     /**
62      * Called by the {@link EventAdmin} service to notify the listener of an event.
63      *
64      * @param event The event that occurred.
65      */

66     void handleEvent(Event event);
67 }
68
Popular Tags