Class AbstractAsynchronouslyRefreshedCache<T>

    • Constructor Detail

      • AbstractAsynchronouslyRefreshedCache

        public AbstractAsynchronouslyRefreshedCache()
    • Method Detail

      • register

        public void register​(RefreshableCacheListener listener)
        Description copied from interface: RefreshableCache
        Register to be informed when the cache is updated in the background. Note: it is up to the implementation to provide any transactional wrapping. Transactional wrapping is not required to invalidate a shared cache entry directly via a transactional cache
        Specified by:
        register in interface RefreshableCache<T>
        Parameters:
        listener - RefreshableCacheListener
      • setThreadPoolExecutor

        public void setThreadPoolExecutor​(ThreadPoolExecutor threadPoolExecutor)
        Parameters:
        threadPoolExecutor - the threadPoolExecutor to set
      • init

        public void init()
      • get

        public T get​(String key)
        Description copied from interface: RefreshableCache
        Get the cache. If there is no cache value this call will block. If the underlying cache is being refreshed, the old cache value will be returned until the refresh is complete.
        Specified by:
        get in interface RefreshableCache<T>
        Returns:
        T
      • forceInChangesForThisUncommittedTransaction

        public void forceInChangesForThisUncommittedTransaction​(String key)
        Use the current thread to build and put a new version of the cache entry before returning.
        Parameters:
        key - the cache key
      • waitForBuild

        protected void waitForBuild​(org.alfresco.util.cache.AbstractAsynchronouslyRefreshedCache.Refresh refresh)
      • setBeanName

        public void setBeanName​(String name)
        Specified by:
        setBeanName in interface org.springframework.beans.factory.BeanNameAware
      • buildCache

        protected abstract T buildCache​(String key)
        Build the cache entry for the specific key. This method is called in a thread-safe manner i.e. it is only ever called by a single thread.
        Parameters:
        key -
        Returns:
        new Cache instance
      • afterPropertiesSet

        public void afterPropertiesSet()
                                throws Exception
        Specified by:
        afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
        Throws:
        Exception
      • beforeCommit

        public void beforeCommit​(boolean readOnly)
        Description copied from interface: TransactionListener
        Called before a transaction is committed.

        All transaction resources are still available.

        Specified by:
        beforeCommit in interface TransactionListener
        Parameters:
        readOnly - true if the transaction is read-only
      • afterCommit

        public void afterCommit()
        Description copied from interface: TransactionListener
        Invoked after transaction commit.

        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.

        Specified by:
        afterCommit in interface TransactionListener
      • afterRollback

        public void afterRollback()
        Description copied from interface: TransactionListener
        Invoked after transaction rollback.

        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.

        Specified by:
        afterRollback in interface TransactionListener