1 package org.objectweb.celtix.configuration.impl; 2 3 import java.util.ArrayList ; 4 import java.util.Collection ; 5 6 import org.objectweb.celtix.configuration.Configuration; 7 import org.objectweb.celtix.configuration.Configurator; 8 9 10 14 public class ConfiguratorImpl implements Configurator { 15 16 private final Configuration configuration; 17 private final Configurator hook; 18 private final Collection <Configurator> clients; 19 20 public ConfiguratorImpl(Configuration c, Configuration parent) { 21 configuration = c; 22 clients = new ArrayList <Configurator>(); 23 if (parent instanceof AbstractConfigurationImpl) { 24 hook = ((AbstractConfigurationImpl)parent).getConfigurator(); 25 hook.registerClient(this); 26 } else { 27 hook = null; 28 } 29 } 30 31 public Configuration getConfiguration() { 32 return configuration; 33 } 34 35 public Collection <Configurator> getClients() { 36 return clients; 37 } 38 39 public Configurator getHook() { 40 return hook; 41 } 42 43 public synchronized void registerClient(Configurator c) { 44 Object clientId = c.getConfiguration().getId(); 46 String clientNamepace = c.getConfiguration().getModel().getNamespaceURI(); 47 for (Configurator client : clients) { 48 if (clientId.equals(client.getConfiguration().getId()) 49 && clientNamepace.equals(client.getConfiguration().getModel().getNamespaceURI())) { 50 clients.remove(client); 51 break; 52 } 53 } 54 clients.add(c); 55 } 56 public void unregisterClient(Configurator c) { 57 clients.remove(c); 58 } 59 } 60 | Popular Tags |