Package ca.uhn.fhir.jpa.cache
Class ResourceChangeListenerCacheRefresherImpl
java.lang.Object
ca.uhn.fhir.jpa.cache.ResourceChangeListenerCacheRefresherImpl
- All Implemented Interfaces:
IResourceChangeListenerCacheRefresher,ca.uhn.fhir.jpa.model.sched.IHasScheduledJobs
@Service
public class ResourceChangeListenerCacheRefresherImpl
extends Object
implements IResourceChangeListenerCacheRefresher, ca.uhn.fhir.jpa.model.sched.IHasScheduledJobs
This service refreshes the
IResourceChangeListenerCache caches and notifies their listener when
those caches change.
Think of it like a Ferris Wheel that completes a full rotation once every 10 seconds.
Every time a chair passes the bottom it checks to see if it's time to refresh that seat. If so,
the Ferris Wheel stops, removes the riders, and loads a fresh cache for that chair, and calls the listener
if any entries in the new cache are different from the last time that cache was loaded.-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanRefresh the cache in this entry and notify the entry's listener if the cache changedIf the current time is past the next refresh time of the registered listener, then check if any of its resources have changed and notify the listener accordinglyvoidscheduleJobs(ca.uhn.fhir.jpa.model.sched.ISchedulerService theSchedulerService) voidsetResourceChangeListenerRegistry(ResourceChangeListenerRegistryImpl theResourceChangeListenerRegistry) voidsetResourceVersionSvc(IResourceVersionSvc theResourceVersionSvc) voidshutdown()voidstart()
-
Constructor Details
-
ResourceChangeListenerCacheRefresherImpl
-
-
Method Details
-
scheduleJobs
- Specified by:
scheduleJobsin interfaceca.uhn.fhir.jpa.model.sched.IHasScheduledJobs
-
refreshExpiredCachesAndNotifyListeners
Description copied from interface:IResourceChangeListenerCacheRefresherIf the current time is past the next refresh time of the registered listener, then check if any of its resources have changed and notify the listener accordingly- Specified by:
refreshExpiredCachesAndNotifyListenersin interfaceIResourceChangeListenerCacheRefresher- Returns:
- an aggregate of all changes sent to all listeners
-
forceRefreshAllCachesForUnitTest
-
setResourceChangeListenerRegistry
public void setResourceChangeListenerRegistry(ResourceChangeListenerRegistryImpl theResourceChangeListenerRegistry) -
setResourceVersionSvc
-
start
- Specified by:
startin interfaceIResourceChangeListenerCacheRefresher
-
shutdown
- Specified by:
shutdownin interfaceIResourceChangeListenerCacheRefresher
-
isStopping
-
refreshCacheAndNotifyListener
Description copied from interface:IResourceChangeListenerCacheRefresherRefresh the cache in this entry and notify the entry's listener if the cache changed- Specified by:
refreshCacheAndNotifyListenerin interfaceIResourceChangeListenerCacheRefresher- Parameters:
theCache- theIResourceChangeListenerCachewith the cache and the listener- Returns:
- the number of resources that have been created, updated and deleted since the last time the cache was refreshed
-