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
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
-
Method Summary
Modifier and TypeMethodDescriptionprotected FhirContext
protected 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, javax.servlet.http.HttpServletRequest httpServletRequest, javax.servlet.http.HttpServletResponse httpServletResponse, RequestDetails requestDetails) Submits a transaction request bundle, expecting a corresponding response bundleboolean
boolean
void
setConsumer
(RequestConsumer consumer) Adds a request consumer for this resource providervoid
unsetConsumer
(RequestConsumer consumer) Removes the request consumer.Methods inherited from class org.openehealth.ipf.commons.ihe.fhir.FhirProvider
enrichParameters
-
Constructor Details
-
SharedFhirProvider
public SharedFhirProvider()
-
-
Method Details
-
getFhirContext
- Specified by:
getFhirContext
in classFhirProvider
- Returns:
- FhirContext
-
getRequestConsumer
Description copied from class:FhirProvider
Returns the first consumer that is able to handle the provided payload- Specified by:
getRequestConsumer
in classFhirProvider
- Parameters:
requestDetails
- FHIR request- Returns:
- consumer or
Optional.empty()
-
requiresRegistration
public boolean requiresRegistration()- Overrides:
requiresRegistration
in classFhirProvider
- Returns:
- true if the first consumer has been added, false otherwise
- See Also:
-
requiresDeregistration
public boolean requiresDeregistration()- Overrides:
requiresDeregistration
in 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, 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 bundlehttpServletRequest
- servlet requesthttpServletResponse
- servlet response- Returns:
- result of processing
-
setConsumer
Adds a request consumer for this resource provider- Specified by:
setConsumer
in 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:
unsetConsumer
in classFhirProvider
- Parameters:
consumer
- request consumer
-