Class AbstractDelegatingEmbeddedCacheManager

    • Constructor Detail

      • AbstractDelegatingEmbeddedCacheManager

        public AbstractDelegatingEmbeddedCacheManager​(EmbeddedCacheManager cm)
    • Method Detail

      • defineConfiguration

        public Configuration defineConfiguration​(String cacheName,
                                                 String templateCacheName,
                                                 Configuration configurationOverride)
        Description copied from interface: EmbeddedCacheManager
        Defines a named cache's configuration using by first reading the template configuration and then applying the override afterwards to generate a configuration.

        The other way to define named cache's configuration is declaratively, in the XML file passed in to the cache manager.

        If templateName is null or there isn't any named cache with that name, this methods works exactly like EmbeddedCacheManager.defineConfiguration(String, Configuration).

        If this cache was already configured either declaratively or programmatically this method will throw a CacheConfigurationException.

        Specified by:
        defineConfiguration in interface EmbeddedCacheManager
        Parameters:
        cacheName - name of cache whose configuration is being defined
        templateCacheName - name of cache to use as a template before overrides are applied to it
        configurationOverride - configuration overrides to use
        Returns:
        a cloned configuration instance
      • undefineConfiguration

        public void undefineConfiguration​(String configurationName)
        Description copied from interface: EmbeddedCacheManager
        Removes a configuration from the set of defined configurations. If the configuration is currently in use by one of the caches, an IllegalStateException is thrown. If the named configuration does not exist, nothing happens
        Specified by:
        undefineConfiguration in interface EmbeddedCacheManager
        Parameters:
        configurationName - the named configuration
      • getAddress

        public Address getAddress()
        Description copied from interface: EmbeddedCacheManager
        Warning: the address may be null before the first clustered cache starts and after all the clustered caches have been stopped.
        Specified by:
        getAddress in interface EmbeddedCacheManager
        Returns:
        the address of the local node, or null if not connected
      • isCoordinator

        public boolean isCoordinator()
        Specified by:
        isCoordinator in interface EmbeddedCacheManager
        Returns:
        whether the local node is the cluster's coordinator, or null if not connected
      • getCacheNames

        public Set<String> getCacheNames()
        Description copied from interface: org.infinispan.commons.api.BasicCacheContainer
        This method returns a collection of caches names which contains the caches that have been defined via XML or programmatically, and the caches that have been created at runtime via this cache manager instance. If no named caches are registered or no caches have been created, this method returns an empty set. The list of caches does not include internal-only caches InternalCacheRegistry
        Specified by:
        getCacheNames in interface org.infinispan.commons.api.BasicCacheContainer
        Returns:
        an immutable set of caches registered or created with this cache manager.
      • getCacheConfigurationNames

        public Set<String> getCacheConfigurationNames()
        Description copied from interface: EmbeddedCacheManager
        This method returns a collection of cache configuration names which contains the cache configurations that have been defined via XML or programmatically, and the cache configurations that have been defined at runtime via this cache manager instance. If no cache configurations are registered or no caches have been created, this method returns an empty set. The default cache is never included in this set of cache names, as well a caches for internal-only use InternalCacheRegistry
        Specified by:
        getCacheConfigurationNames in interface EmbeddedCacheManager
        Returns:
        an immutable set of non-default named caches registered or created with this cache manager.
      • isRunning

        public boolean isRunning​(String cacheName)
        Description copied from interface: EmbeddedCacheManager
        Tests whether a named cache is running.
        Specified by:
        isRunning in interface EmbeddedCacheManager
        Parameters:
        cacheName - name of cache to test.
        Returns:
        true if the named cache exists and is running; false otherwise.
      • isDefaultRunning

        public boolean isDefaultRunning()
        Description copied from interface: EmbeddedCacheManager
        Tests whether the default cache is running.
        Specified by:
        isDefaultRunning in interface EmbeddedCacheManager
        Returns:
        true if the default cache is running; false otherwise.
      • cacheExists

        public boolean cacheExists​(String cacheName)
        Description copied from interface: EmbeddedCacheManager
        A cache is considered to exist if it has been created and started via one of the CacheContainer.getCache() methods and has not yet been removed via EmbeddedCacheManager.removeCache(String).

        In environments when caches are continuously created and removed, this method offers the possibility to find out whether a cache has either, not been started, or if it was started, whether it's been removed already or not.
        Specified by:
        cacheExists in interface EmbeddedCacheManager
        Returns:
        true if the cache with the given name has not yet been started, or if it was started, whether it's been removed or not.
      • getCache

        public <K,​V> Cache<K,​V> getCache​(String cacheName,
                                                     boolean createIfAbsent)
        Description copied from interface: EmbeddedCacheManager
        Retrieves a named cache from the system in the same way that CacheContainer.getCache(String) does except that if offers the possibility for the named cache not to be retrieved if it has not yet been started, or if it's been removed after being started. If a non-template configuration exists with the same name, it will be used to configure the cache.
        Specified by:
        getCache in interface EmbeddedCacheManager
        Parameters:
        cacheName - name of cache to retrieve
        createIfAbsent - if false, the named cache will not be retrieved if it hasn't been retrieved previously or if it's been removed. If true, this methods works just like CacheContainer.getCache(String)
        Returns:
        null if no named cache exists as per rules set above, otherwise returns a cache instance identified by cacheName
      • getCache

        public <K,​V> Cache<K,​V> getCache​(String cacheName,
                                                     String configurationName)
        Description copied from interface: EmbeddedCacheManager
        Retrieves a named cache from the system in the same way that CacheContainer.getCache(String) does except that if offers the possibility to specify a specific configuration template. Multiple caches can be created using the same configuration.
        Specified by:
        getCache in interface EmbeddedCacheManager
        Parameters:
        cacheName - name of cache to retrieve
        configurationName - name of the configuration template to use
        Returns:
        null if no configuration exists as per rules set above, otherwise returns a cache instance identified by cacheName
      • getCache

        public <K,​V> Cache<K,​V> getCache​(String cacheName,
                                                     String configurationTemplate,
                                                     boolean createIfAbsent)
        Description copied from interface: EmbeddedCacheManager
        Retrieves a named cache from the system in the same way that CacheContainer.getCache(String) does except that if offers the possibility to specify a specific configuration template. Multiple caches can be created using the same configuration. Tihs method also offers the possibility for the named cache not to be retrieved if it has not yet been started, or if it's been removed after being started.
        Specified by:
        getCache in interface EmbeddedCacheManager
        Parameters:
        cacheName - name of cache to retrieve
        configurationTemplate - name of the configuration template to use
        createIfAbsent - if false, the named cache will not be retrieved if it hasn't been retrieved previously or if it's been removed. If true, this methods works just like EmbeddedCacheManager.getCache(String, String)
        Returns:
        null if no configuration exists as per rules set above, otherwise returns a cache instance identified by cacheName
      • startCaches

        public EmbeddedCacheManager startCaches​(String... cacheNames)
        Description copied from interface: EmbeddedCacheManager
        Starts a set of caches in parallel. Infinispan supports both symmetric and asymmetric clusters; that is, multiple nodes having the same or different sets of caches running, respectively. Calling this method on application/application server startup with all your cache names will ensure that the cluster is symmetric.
        Specified by:
        startCaches in interface EmbeddedCacheManager
        Parameters:
        cacheNames - the names of the caches to start
      • removeCache

        public void removeCache​(String cacheName)
        Description copied from interface: EmbeddedCacheManager
        Removes a cache with the given name from the system. This is a cluster wide operation that results not only in stopping the cache with the given name in all nodes in the cluster, but also deletes its contents both in memory and in any backing cache store.
        Specified by:
        removeCache in interface EmbeddedCacheManager
        Parameters:
        cacheName - name of cache to remove
      • getCache

        public <K,​V> Cache<K,​V> getCache()
        Description copied from interface: CacheContainer
        This method overrides the underlying CacheContainer.getCache(), to return a Cache instead of a BasicCache
        Specified by:
        getCache in interface org.infinispan.commons.api.BasicCacheContainer
        Specified by:
        getCache in interface CacheContainer
        Returns:
        the default cache.
      • getCache

        public <K,​V> Cache<K,​V> getCache​(String cacheName)
        Description copied from interface: CacheContainer
        This method overrides the underlying CacheContainer.getCache(String), to return a Cache instead of a BasicCache
        Specified by:
        getCache in interface org.infinispan.commons.api.BasicCacheContainer
        Specified by:
        getCache in interface CacheContainer
        Parameters:
        cacheName - name of cache to retrieve
        Returns:
        a cache instance identified by cacheName
      • start

        public void start()
        Description copied from interface: org.infinispan.commons.api.Lifecycle
        Invoked on component start
        Specified by:
        start in interface org.infinispan.commons.api.Lifecycle
      • stop

        public void stop()
        Description copied from interface: org.infinispan.commons.api.Lifecycle
        Invoked on component stop
        Specified by:
        stop in interface org.infinispan.commons.api.Lifecycle
      • addCacheDependency

        public void addCacheDependency​(String from,
                                       String to)
        Description copied from interface: EmbeddedCacheManager
        Add a dependency between two caches. The cache manager will make sure that a cache is stopped before any of its dependencies
        Specified by:
        addCacheDependency in interface EmbeddedCacheManager
        Parameters:
        from - cache name
        to - cache name
      • addListener

        public void addListener​(Object listener)
        Description copied from interface: Listenable
        Adds a listener to the component. Typically, listeners would need to be annotated with Listener and further to that, contain methods annotated appropriately, otherwise the listener will not be registered.

        See the Listener annotation for more information.

        Specified by:
        addListener in interface Listenable
        Parameters:
        listener - must not be null.
      • removeListener

        public void removeListener​(Object listener)
        Description copied from interface: Listenable
        Removes a listener from the component.
        Specified by:
        removeListener in interface Listenable
        Parameters:
        listener - listener to remove. Must not be null.
      • getListeners

        public Set<Object> getListeners()
        Specified by:
        getListeners in interface Listenable
        Returns:
        a set of all listeners registered on this component.