Class SharedFhirProvider

java.lang.Object
org.openehealth.ipf.commons.ihe.fhir.FhirProvider
org.openehealth.ipf.commons.ihe.fhir.SharedFhirProvider
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
BatchTransactionResourceProvider, BatchTransactionResourceProvider

public abstract class SharedFhirProvider extends FhirProvider
Shared Resource provider, primarily (but not exclusively) meant for batch/transaction requests. Use this resource provider if you have several consumers that share the same FHIR interface. The request is dispatched to the first consumer that returns true on RequestConsumer.test(RequestDetails).

Components/Endpoints that use this resource provider must reference a (shared) singleton instance of a concrete implementation of this class.

Request consumers must share the same FhirContext instance.

Author:
Christian Ohr
See Also:
  • Constructor Details

    • SharedFhirProvider

      public SharedFhirProvider()
  • Method Details

    • getFhirContext

      protected FhirContext getFhirContext()
      Specified by:
      getFhirContext in class FhirProvider
      Returns:
      FhirContext
    • getRequestConsumer

      protected Optional<RequestConsumer> getRequestConsumer(RequestDetails requestDetails)
      Description copied from class: FhirProvider
      Returns the first consumer that is able to handle the provided payload
      Specified by:
      getRequestConsumer in class FhirProvider
      Parameters:
      requestDetails - FHIR request
      Returns:
      consumer or Optional.empty()
    • requiresRegistration

      public boolean requiresRegistration()
      Overrides:
      requiresRegistration in class FhirProvider
      Returns:
      true if the first consumer has been added, false otherwise
      See Also:
    • requiresDeregistration

      public boolean requiresDeregistration()
      Overrides:
      requiresDeregistration in class FhirProvider
      Returns:
      false if the last consumer has been removed, false otherwise
      See Also:
    • requestTransaction

      protected final <T extends IBaseBundle> T requestTransaction(Object payload, Class<T> bundleClass, javax.servlet.http.HttpServletRequest httpServletRequest, javax.servlet.http.HttpServletResponse httpServletResponse, RequestDetails requestDetails)
      Submits a transaction request bundle, expecting a corresponding response bundle
      Parameters:
      payload - transaction bundle
      httpServletRequest - servlet request
      httpServletResponse - servlet response
      Returns:
      result of processing
    • setConsumer

      public void setConsumer(RequestConsumer consumer)
      Adds a request consumer for this resource provider
      Specified by:
      setConsumer in class FhirProvider
      Parameters:
      consumer - request consumer
      Throws:
      IllegalStateException - if the consumer is already present or if the FhirContext is different compared to the FhirContext of the other consumers.
    • unsetConsumer

      public void unsetConsumer(RequestConsumer consumer)
      Removes the request consumer. If the consumer was not registered, this method does nothing.
      Specified by:
      unsetConsumer in class FhirProvider
      Parameters:
      consumer - request consumer