Class DefaultFhirRegistry

java.lang.Object
org.openehealth.ipf.commons.ihe.fhir.DefaultFhirRegistry
All Implemented Interfaces:
FhirRegistry

public class DefaultFhirRegistry extends Object implements FhirRegistry
Default implementation of FhirRegistry. Instances are thread-safe; registration of resource providers and servlets is serialized.
Since:
3.2
Author:
Christian Ohr
  • Constructor Details

    • DefaultFhirRegistry

      public DefaultFhirRegistry()
      Creates a new registry. Use this for a registry that is shared between a FHIR servlet and FHIR endpoints by explicit configuration rather than by servlet name, see getFhirRegistry(String).
      Since:
      6.1
  • Method Details

    • getFhirRegistry

      public static FhirRegistry getFhirRegistry(String name)
      Lookup or create a new FHIR registry if none exists with the given (servlet) name
    • removeFhirRegistry

      public static FhirRegistry removeFhirRegistry(String name)
      Removes the FHIR registry with the given (servlet) name. Note that FHIR servlets do not remove their registry when being destroyed, because the registry keeps track of the resource providers of the FHIR consumers, which may outlive the servlet. Call this only if neither servlets nor consumers use the registry anymore, e.g. in tests.
    • resolveProvider

      public FhirProvider resolveProvider(FhirProvider candidate)
      Description copied from interface: FhirRegistry
      Returns the resource provider instance to be used for the servlet(s) of this registry. All endpoints that resolve a provider of the same class get the same instance, so that e.g. a SharedFhirProvider is shared between endpoints of the same servlet, but not between different servlets.

      The default implementation returns the candidate itself.

      Specified by:
      resolveProvider in interface FhirRegistry
      Parameters:
      candidate - new resource provider instance, used if this registry does not yet know an instance of the same class
      Returns:
      the resource provider instance to be connected and registered
    • register

      public void register(Object resourceProvider)
      Description copied from interface: FhirRegistry
      Registers the FHIR resource provider.
      Specified by:
      register in interface FhirRegistry
      Parameters:
      resourceProvider - resource provider
    • unregister

      public void unregister(Object resourceProvider)
      Description copied from interface: FhirRegistry
      Unregisters the FHIR resource provider.
      Specified by:
      unregister in interface FhirRegistry
      Parameters:
      resourceProvider - resource provider
    • register

      public void register(RestfulServer servlet)
      Description copied from interface: FhirRegistry
      Registers the FHIR servlet, usually during its init phase.
      Specified by:
      register in interface FhirRegistry
      Parameters:
      servlet - FHIR servlet
      Throws:
      IllegalStateException - if a different servlet with the same name is already registered
    • unregister

      public void unregister(RestfulServer servlet)
      Description copied from interface: FhirRegistry
      Unregisters the FHIR servlet, usually during its destroy phase
      Specified by:
      unregister in interface FhirRegistry
      Parameters:
      servlet - FHIR servlet
    • hasServlet

      public boolean hasServlet(String servletName)
      Description copied from interface: FhirRegistry
      Returns true if there is already a registered FHIR servlet with the provided name
      Specified by:
      hasServlet in interface FhirRegistry
      Parameters:
      servletName - name of the servlet
      Returns:
      true if there is already a registered FHIR servlet with this name