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
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 onRequestConsumer.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:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description SharedFhirProvider()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected FhirContext
getFhirContext()
protected Optional<RequestConsumer>
getRequestConsumer(RequestDetails requestDetails)
Returns the first consumer that is able to handle the provided paylaodprotected <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
requiresDeregistration()
boolean
requiresRegistration()
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
-
-
-
-
Method Detail
-
getFhirContext
protected FhirContext getFhirContext()
- Specified by:
getFhirContext
in classFhirProvider
- 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 paylaod- 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:
FhirRegistry.register(Object)
-
requiresDeregistration
public boolean requiresDeregistration()
- Overrides:
requiresDeregistration
in classFhirProvider
- Returns:
- false if the last consumer has been removed, false otherwise
- See Also:
FhirRegistry.unregister(Object)
-
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
public void setConsumer(RequestConsumer consumer)
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
public void unsetConsumer(RequestConsumer consumer)
Removes the request consumer. If the consumer was not registered, this method does nothing.- Specified by:
unsetConsumer
in classFhirProvider
- Parameters:
consumer
- request consumer
-
-