01: /*
02: * Copyright 2001-2006 C:1 Financial Services GmbH
03: *
04: * This software is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU Lesser General Public
06: * License Version 2.1, as published by the Free Software Foundation.
07: *
08: * This software is distributed in the hope that it will be useful,
09: * but WITHOUT ANY WARRANTY; without even the implied warranty of
10: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11: * Lesser General Public License for more details.
12: *
13: * You should have received a copy of the GNU Lesser General Public
14: * License along with this library; if not, write to the Free Software
15: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
16: */
17:
18: package de.finix.contelligent.components.config;
19:
20: import java.util.HashMap;
21: import java.util.Map;
22:
23: import de.finix.contelligent.CallData;
24: import de.finix.contelligent.Component;
25: import de.finix.contelligent.ModificationVetoException;
26: import de.finix.contelligent.ObservingContainer;
27: import de.finix.contelligent.Type;
28: import de.finix.contelligent.components.Folder;
29: import de.finix.contelligent.event.ComponentEvent;
30: import de.finix.contelligent.event.EventQueue;
31:
32: public class ConfigurationFolder extends Folder implements
33: ObservingContainer {
34:
35: public boolean subcomponentAdded(CallData callData,
36: Component subcomponent) throws ModificationVetoException {
37: fireEvent(ComponentEvent.CONFIG_ADDED, subcomponent, callData);
38: return false;
39: }
40:
41: public boolean subcomponentRemoved(CallData callData,
42: Component subcomponent) throws ModificationVetoException {
43: fireEvent(ComponentEvent.CONFIG_REMOVED, subcomponent, callData);
44: return false;
45: }
46:
47: public boolean subcomponentChanged(CallData callData,
48: Component subcomponent) throws ModificationVetoException {
49: fireEvent(ComponentEvent.CONFIG_CHANGED, subcomponent, callData);
50: return false;
51: }
52:
53: private void fireEvent(ComponentEvent.EventType eventType,
54: Component subcomponent, CallData callData) {
55: Map info = new HashMap();
56: Type componentType = subcomponent.getComponentContext()
57: .getType();
58: if (subcomponent instanceof Configuration) {
59: info.put("domain", ((Configuration) subcomponent)
60: .getDomain());
61: info.put("type", componentType);
62: }
63: EventQueue.getInstance().addEvent(
64: new ComponentEvent(eventType, subcomponent
65: .getComponentContext().getPath(), callData
66: .getActualManager().getName(), info));
67: }
68: }
|