1 29 30 package nextapp.echo2.webrender; 31 32 import java.util.HashMap ; 33 import java.util.Map ; 34 35 39 public class ServiceRegistry { 40 41 42 private final Map serviceMap = new HashMap (); 43 44 47 public ServiceRegistry() { 48 super(); 49 } 50 51 56 public synchronized void add(Service service) { 57 if (serviceMap.containsKey(service.getId()) && serviceMap.get(service.getId()) != service) { 58 throw new IllegalArgumentException ("Identifier already in use by another service."); 59 } 60 serviceMap.put(service.getId(), service); 61 } 62 63 69 public Service get(String id) { 70 return (Service) serviceMap.get(id); 71 } 72 73 78 public synchronized void remove(Service service) { 79 serviceMap.remove(service.getId()); 80 } 81 } 82 | Popular Tags |