1 4 package com.tc.config.schema.listen; 5 6 import org.apache.xmlbeans.XmlObject; 7 8 import com.tc.util.Assert; 9 10 import java.util.HashSet ; 11 import java.util.Iterator ; 12 import java.util.Set ; 13 14 17 public class ConfigurationChangeListenerSet implements ConfigurationChangeListener { 18 19 private final HashSet changeListeners; 21 22 public ConfigurationChangeListenerSet() { 23 this.changeListeners = new HashSet (); 24 } 25 26 public synchronized void addListener(ConfigurationChangeListener listener) { 27 Assert.assertNotNull(listener); 28 this.changeListeners.add(listener); 29 } 30 31 public synchronized void removeListener(ConfigurationChangeListener listener) { 32 Assert.assertNotNull(listener); 33 this.changeListeners.remove(listener); 34 } 35 36 public void configurationChanged(XmlObject oldConfig, XmlObject newConfig) { 37 Set dup; 38 39 synchronized (this) { 40 dup = (Set ) this.changeListeners.clone(); 41 } 42 43 Iterator iter = dup.iterator(); 44 while (iter.hasNext()) { 45 ((ConfigurationChangeListener) iter.next()).configurationChanged(oldConfig, newConfig); 46 } 47 } 48 49 } 50 | Popular Tags |