Make use of Lombok
[nonrtric.git] / policy-agent / src / main / java / org / oransc / policyagent / repository / Services.java
index 5b5b4a8..369b258 100644 (file)
@@ -23,6 +23,7 @@ package org.oransc.policyagent.repository;
 import java.util.HashMap;
 import java.util.Map;
 
+import org.oransc.policyagent.exceptions.ServiceException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -34,4 +35,33 @@ public class Services {
     public Services() {
     }
 
+    public synchronized Service getService(String name) throws ServiceException {
+        Service s = services.get(name);
+        if (s == null) {
+            throw new ServiceException("Could not find service: " + name);
+        }
+        return s;
+    }
+
+    public synchronized Service get(String name) {
+        return services.get(name);
+    }
+
+    public synchronized void put(Service service) {
+        logger.debug("Put service: " + service.getName());
+        services.put(service.getName(), service);
+    }
+
+    public synchronized Iterable<Service> getAll() {
+        return services.values();
+    }
+
+    public synchronized void remove(String name) {
+        services.remove(name);
+    }
+
+    public synchronized int size() {
+        return services.size();
+    }
+
 }