public abstract class AbstractAsynchronouslyRefreshedCache<T> extends Object implements AsynchronouslyRefreshedCache<T>, RefreshableCacheListener, Callable<Void>, org.springframework.beans.factory.BeanNameAware, org.springframework.beans.factory.InitializingBean, TransactionListener
Modifier and Type | Field and Description |
---|---|
protected HashMap<String,T> |
live |
protected ReentrantReadWriteLock |
liveLock |
Constructor and Description |
---|
AbstractAsynchronouslyRefreshedCache() |
Modifier and Type | Method and Description |
---|---|
void |
afterCommit()
Invoked after transaction commit.
|
void |
afterPropertiesSet() |
void |
afterRollback()
Invoked after transaction rollback.
|
void |
beforeCommit(boolean readOnly)
Called before a transaction is committed.
|
void |
beforeCompletion()
Invoked before transaction commit/rollback.
|
void |
broadcastEvent(RefreshableCacheEvent event) |
protected abstract T |
buildCache(String key)
Build the cache entry for the specific key.
|
Void |
call() |
void |
forceInChangesForThisUncommittedTransaction(String key)
Use the current thread to build and put a new version of the cache entry before returning.
|
T |
get(String key)
Get the cache.
|
String |
getCacheId()
Get the cache id
|
void |
init() |
boolean |
isUpToDate(String key)
Determine if the cache is up to date
|
void |
onRefreshableCacheEvent(RefreshableCacheEvent refreshableCacheEvent)
Callback made when a cache refresh occurs
|
void |
refresh(String key)
Refresh the cache asynchronously.
|
void |
register(RefreshableCacheListener listener)
Register to be informed when the cache is updated in the background.
|
void |
setBeanName(String name) |
void |
setRegistry(AsynchronouslyRefreshedCacheRegistry registry) |
void |
setThreadPoolExecutor(ThreadPoolExecutor threadPoolExecutor) |
String |
toString() |
protected void |
waitForBuild(org.alfresco.util.cache.AbstractAsynchronouslyRefreshedCache.Refresh refresh) |
protected final ReentrantReadWriteLock liveLock
public AbstractAsynchronouslyRefreshedCache()
public void register(RefreshableCacheListener listener)
RefreshableCache
register
in interface RefreshableCache<T>
listener
- RefreshableCacheListenerpublic void setThreadPoolExecutor(ThreadPoolExecutor threadPoolExecutor)
threadPoolExecutor
- the threadPoolExecutor to setpublic void setRegistry(AsynchronouslyRefreshedCacheRegistry registry)
registry
- the registry to setpublic void init()
public T get(String key)
RefreshableCache
get
in interface RefreshableCache<T>
public void forceInChangesForThisUncommittedTransaction(String key)
key
- the cache keyprotected void waitForBuild(org.alfresco.util.cache.AbstractAsynchronouslyRefreshedCache.Refresh refresh)
public void refresh(String key)
RefreshableCache
refresh
in interface RefreshableCache<T>
public void onRefreshableCacheEvent(RefreshableCacheEvent refreshableCacheEvent)
RefreshableCacheListener
onRefreshableCacheEvent
in interface RefreshableCacheListener
refreshableCacheEvent
- the cache eventpublic boolean isUpToDate(String key)
AsynchronouslyRefreshedCache
isUpToDate
in interface AsynchronouslyRefreshedCache<T>
key
- tennant idpublic void setBeanName(String name)
setBeanName
in interface org.springframework.beans.factory.BeanNameAware
public String getCacheId()
AsynchronouslyRefreshedCache
getCacheId
in interface AsynchronouslyRefreshedCache<T>
getCacheId
in interface RefreshableCacheListener
protected abstract T buildCache(String key)
key
- public void afterPropertiesSet() throws Exception
afterPropertiesSet
in interface org.springframework.beans.factory.InitializingBean
Exception
public void broadcastEvent(RefreshableCacheEvent event)
public void beforeCommit(boolean readOnly)
TransactionListener
All transaction resources are still available.
beforeCommit
in interface TransactionListener
readOnly
- true if the transaction is read-onlypublic void beforeCompletion()
TransactionListener
TransactionListener.beforeCommit(boolean)
even if TransactionListener.beforeCommit(boolean)
failed.
All transaction resources are still available.
beforeCompletion
in interface TransactionListener
public void afterCommit()
TransactionListener
Any exceptions generated here will only be logged and will have no effect on the state of the transaction.
Although all transaction resources are still available, this method should be used only for cleaning up resources after a commit has occured.
afterCommit
in interface TransactionListener
public void afterRollback()
TransactionListener
Any exceptions generated here will only be logged and will have no effect on the state of the transaction.
Although all transaction resources are still available, this method should be used only for cleaning up resources after a rollback has occured.
afterRollback
in interface TransactionListener
Copyright © 2005–2018 Alfresco Software. All rights reserved.