Package ca.uhn.fhir.jpa.cache
Interface IResourceChangeListenerRegistry
- All Known Implementing Classes:
ResourceChangeListenerRegistryImpl
public interface IResourceChangeListenerRegistry
This component holds an in-memory list of all registered
IResourceChangeListener
instances along
with their caches and other details needed to maintain those caches. Register an IResourceChangeListener
instance
with this service to be notified when resources you care about are changed. This service quickly notifies listeners
of changes that happened on the local process and also eventually notifies listeners of changes that were made by
remote processes.-
Method Summary
Modifier and TypeMethodDescriptionvoid
boolean
contains
(IResourceChangeListenerCache theCache) registerResourceResourceChangeListener
(String theResourceName, SearchParameterMap theSearchParameterMap, IResourceChangeListener theResourceChangeListener, long theRemoteRefreshIntervalMs) Register a listener in order to be notified whenever a resource matching the provided SearchParameterMap changes in any way.void
requestRefreshIfWatching
(org.hl7.fhir.instance.model.api.IBaseResource theResource) Called by theResourceChangeListenerRegistryInterceptor
when a resource is changed to invalidate matching caches so their listeners are notified the next time the caches are refreshed.void
unregisterResourceResourceChangeListener
(IResourceChangeListener theResourceChangeListener) Unregister a listener from this servicevoid
unregisterResourceResourceChangeListener
(IResourceChangeListenerCache theResourceChangeListenerCache) Unregister a listener from this service using its cache handle
-
Method Details
-
registerResourceResourceChangeListener
IResourceChangeListenerCache registerResourceResourceChangeListener(String theResourceName, SearchParameterMap theSearchParameterMap, IResourceChangeListener theResourceChangeListener, long theRemoteRefreshIntervalMs) Register a listener in order to be notified whenever a resource matching the provided SearchParameterMap changes in any way. If the change happened on the same jvm process where this registry resides, then the listener will be called withinResourceChangeListenerCacheRefresherImpl.LOCAL_REFRESH_INTERVAL_MS
of the change happening. If the change happened on a different jvm process, then the listener will be called within the time specified in theRemoteRefreshIntervalMs parameter.- Parameters:
theResourceName
- the type of the resource the listener should be notified about (e.g. "Subscription" or "SearchParameter")theSearchParameterMap
- the listener will only be notified of changes to resources that match this maptheResourceChangeListener
- the listener that will be called whenever resource changes are detectedtheRemoteRefreshIntervalMs
- the number of milliseconds between checking the database for changed resources that match the search parameter map- Returns:
- RegisteredResourceChangeListener a handle to the created cache that can be used to manually refresh the cache if required
- Throws:
DataFormatException
- if theResourceName is not a valid resource type in the FhirContextIllegalArgumentException
- if theSearchParamMap cannot be evaluated in-memory
-
unregisterResourceResourceChangeListener
Unregister a listener from this service- Parameters:
theResourceChangeListener
-
-
unregisterResourceResourceChangeListener
void unregisterResourceResourceChangeListener(IResourceChangeListenerCache theResourceChangeListenerCache) Unregister a listener from this service using its cache handle- Parameters:
theResourceChangeListenerCache
-
-
clearListenersForUnitTest
void clearListenersForUnitTest() -
contains
- Parameters:
theCache
-- Returns:
- true if theCache is registered
-
requestRefreshIfWatching
Called by theResourceChangeListenerRegistryInterceptor
when a resource is changed to invalidate matching caches so their listeners are notified the next time the caches are refreshed.- Parameters:
theResource
- the resource that changed that might trigger a refresh
-
getWatchedResourceNames
- Returns:
- a set of resource names watched by the registered listeners
-