TitleCacheSubscriber
Holds a cache for each entity type that indicates its title should be cached.
Uses the EntityTitleSubscriber to populate the cache, and listens on the org.apache.causeway.applib.CausewayModuleApplib.TitleUiEvent events to provide the cache values.
API
class TitleCacheSubscriber {
TitleCacheSubscriber(CaffeineCacheManager cacheManager, BookmarkService bookmarkService, SpecificationLoader specificationLoader, CausewayConfiguration causewayConfiguration)
void entityTitleIs(Bookmark bookmark, String title) (1)
void on(CausewayModuleApplib.TitleUiEvent<?> ev) (2)
Cache addCache(String cacheName, int expiryDurationInMinutes, int maxSizeInEntries)
}
1 | entityTitleIs(Bookmark, String)
Implementation of EntityTitleSubscriber , listens to any computed titles and puts them into the relevant cache. |
2 | on(CausewayModuleApplib_TitleUiEvent)
Listens on org.apache.causeway.applib.CausewayModuleApplib.TitleUiEvent s, and obtains a previously computed title for the bookmark, if any. |
Members
entityTitleIs(Bookmark, String)
Implementation of EntityTitleSubscriber , listens to any computed titles and puts them into the relevant cache.
Note that the cache is only lazily created when the first request to lookup an entry (in #on(CausewayModuleApplib.TitleUiEvent) ) is called, so there will always be at least one cache miss per logical type name). (An alternative design would have been to scan for all implementations of CachedWithCacheSettings during bootstrap).
on(CausewayModuleApplib_TitleUiEvent)
Listens on org.apache.causeway.applib.CausewayModuleApplib.TitleUiEvent s, and obtains a previously computed title for the bookmark, if any.
If there is not cache, then one is created. If possible, the configuration of that cache is obtained from the event itself (if the event class implements CachedWithCacheSettings ) otherwise using default settings obtained from org.apache.causeway.core.config.CausewayConfiguration.Extensions.Titlecache .