01: package com.teamkonzept.webman.mainint.events;
02:
03: import java.util.*;
04:
05: import com.teamkonzept.web.*;
06:
07: /**
08: Defaultimplementierung eines EventVerteilers, nur isHandler ist noch
09: abstrakt, verteilt die Events dynamisch und an alle, die sich interessieren
10: */
11: public abstract class DefaultEventDistributor implements TKEventHandler {
12: protected Vector handlerList = new Vector();
13:
14: public void handleEvent(TKEvent evt)
15: throws com.teamkonzept.lib.TKException {
16: for (int i = 0; i < handlerList.size(); i++) {
17: TKEventHandler handler = (TKEventHandler) handlerList
18: .elementAt(i);
19: if (handler.isHandler(evt))
20: handler.handleEvent(evt);
21: if (evt.isConsumed())
22: break;
23: }
24: }
25:
26: public abstract boolean isHandler(TKEvent evt);
27:
28: public void addEventHandler(TKEventHandler handler) {
29: handlerList.addElement(handler);
30: }
31:
32: public void removeEventHandler(TKEventHandler handler) {
33: handlerList.removeElement(handler);
34: }
35:
36: /** setzt die zu behandelnden Events*/
37: public void setHandleEvents(TKEvent[] events) {
38: }
39:
40: /** liefert die zu behandelnden Events zurueck */
41: public TKEvent[] getHandleEvents() {
42: return null;
43: }
44:
45: /**
46: * Creates an event object.
47: *
48: * @param http the responsible HTTP interface.
49: * @return an event object.
50: */
51: public TKEvent createEvent(TKHttpInterface http) {
52: return null;
53: }
54:
55: }
|