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
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected FhirContextprotected Optional<RequestConsumer> getRequestConsumer(RequestDetails requestDetails) Returns the first consumer that is able to handle the provided payloadprotected final <T extends IBaseBundle>
TrequestTransaction(Object payload, Class<T> bundleClass, jakarta.servlet.http.HttpServletRequest httpServletRequest, jakarta.servlet.http.HttpServletResponse httpServletResponse, RequestDetails requestDetails) Submits a transaction request bundle, expecting a corresponding response bundlebooleanbooleanvoidsetConsumer(RequestConsumer consumer) Adds a request consumer for this resource providervoidunsetConsumer(RequestConsumer consumer) Removes the request consumer.Methods inherited from class org.openehealth.ipf.commons.ihe.fhir.FhirProvider
enrichParameters, processOutHeaders
-
Constructor Details
-
SharedFhirProvider
public SharedFhirProvider()
-
-
Method Details
-
getFhirContext
- Specified by:
getFhirContextin classFhirProvider- Returns:
- FhirContext
-
getRequestConsumer
Description copied from class:FhirProviderReturns the first consumer that is able to handle the provided payload- Specified by:
getRequestConsumerin classFhirProvider- Parameters:
requestDetails- FHIR request- Returns:
- consumer or
Optional.empty()
-
requiresRegistration
public boolean requiresRegistration()- Overrides:
requiresRegistrationin classFhirProvider- Returns:
- true if the first consumer has been added, false otherwise
- See Also:
-
requiresDeregistration
public boolean requiresDeregistration()- Overrides:
requiresDeregistrationin classFhirProvider- 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, jakarta.servlet.http.HttpServletRequest httpServletRequest, jakarta.servlet.http.HttpServletResponse httpServletResponse, RequestDetails requestDetails) Submits a transaction request bundle, expecting a corresponding response bundle- Parameters:
payload- transaction bundlehttpServletRequest- servlet requesthttpServletResponse- servlet response- Returns:
- result of processing
-
setConsumer
Adds a request consumer for this resource provider- Specified by:
setConsumerin classFhirProvider- 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
Removes the request consumer. If the consumer was not registered, this method does nothing.- Specified by:
unsetConsumerin classFhirProvider- Parameters:
consumer- request consumer
-