diff --git a/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/RestfulServer.java b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/RestfulServer.java index c3d439939a6..b8d702b8832 100644 --- a/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/RestfulServer.java +++ b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/RestfulServer.java @@ -1333,15 +1333,17 @@ public class RestfulServer extends HttpServlet implements IRestfulServer providers) { + public void registerProviders(Collection theProviders) { + Validate.noNullElements(theProviders, "theProviders must not contain any null elements"); + myProviderRegistrationMutex.lock(); try { if (!myStarted) { - for (Object provider : providers) { + for (Object provider : theProviders) { ourLog.info("Registration of provider [" + provider.getClass().getName() + "] will be delayed until FHIR server startup"); if (provider instanceof IResourceProvider) { myResourceProviders.add((IResourceProvider) provider); @@ -1354,19 +1356,21 @@ public class RestfulServer extends HttpServlet implements IRestfulServer providers, boolean inInit) { + protected void registerProviders(Collection theProviders, boolean inInit) { + Validate.noNullElements(theProviders, "theProviders must not contain any null elements"); + List newResourceProviders = new ArrayList<>(); List newPlainProviders = new ArrayList<>(); ProvidedResourceScanner providedResourceScanner = new ProvidedResourceScanner(getFhirContext()); - if (providers != null) { - for (Object provider : providers) { + if (theProviders != null) { + for (Object provider : theProviders) { if (provider instanceof IResourceProvider) { IResourceProvider rsrcProvider = (IResourceProvider) provider; Class resourceType = rsrcProvider.getResourceType(); @@ -1520,12 +1524,14 @@ public class RestfulServer extends HttpServlet implements IRestfulServer theProviders) { + Validate.noNullElements(theProviders, "theProviders must not contain any null elements"); + myPlainProviders.clear(); if (theProviders != null) { myPlainProviders.addAll(theProviders); @@ -1547,6 +1555,8 @@ public class RestfulServer extends HttpServlet implements IRestfulServer theResourceProviders) { + public void setResourceProviders(Collection theProviders) { + Validate.noNullElements(theProviders, "theProviders must not contain any null elements"); + myResourceProviders.clear(); - if (theResourceProviders != null) { - myResourceProviders.addAll(theResourceProviders); + if (theProviders != null) { + myResourceProviders.addAll(theProviders); } }