1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.asteriskjava.manager.internal;
18
19 import java.util.Map;
20
21 import org.asteriskjava.manager.event.ManagerEvent;
22
23
24 /***
25 * Transforms maps of attributes to instances of ManagerEvent.
26 *
27 * @see org.asteriskjava.manager.event.ManagerEvent
28 * @author srt
29 * @version $Id: EventBuilder.java 406 2006-05-26 16:00:22Z srt $
30 */
31 interface EventBuilder
32 {
33 /***
34 * Registers a new event class. The event this class is registered for is
35 * simply derived from the name of the class by stripping any package name
36 * (if present) and stripping the sufffix "Event". For example
37 * <code>org.asteriskjava.manager.event.JoinEvent</code> is registered for
38 * the event "Join".
39 * <p>
40 * The event class must be a concrete class with a default constructor
41 * (one that takes no arguments).
42 *
43 * @param clazz the event class to register, must extend {@link ManagerEvent}.
44 * @throws IllegalArgumentException if clazz is not a valid event class
45 */
46 void registerEventClass(Class clazz) throws IllegalArgumentException;
47
48 /***
49 * Builds the event based on the given map of attributes and the registered
50 * event classes.
51 *
52 * @param source source attribute for the event
53 * @param attributes map containing event attributes
54 * @return a concrete instance of ManagerEvent or <code>null</code> if no
55 * event class was registered for the event type.
56 */
57 ManagerEvent buildEvent(Object source, Map<String, String> attributes);
58 }