Change to JUnit5 and clean up pom
[nonrtric.git] / policy-agent / src / main / java / org / oransc / policyagent / repository / Services.java
index 5b5b4a8..789ea2e 100644 (file)
 
 package org.oransc.policyagent.repository;
 
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.Map;
 
+import org.oransc.policyagent.exceptions.ServiceException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -34,4 +36,24 @@ 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) {
+        services.put(service.getName(), service);
+    }
+
+    public synchronized Collection<Service> getAll() {
+        return services.values();
+    }
+
 }