Class LoomJCacheManager

java.lang.Object
com.loomcache.server.jcache.LoomJCacheManager
All Implemented Interfaces:
Closeable, AutoCloseable, javax.cache.CacheManager

public class LoomJCacheManager extends Object implements javax.cache.CacheManager
JCache-compatible (JSR-107) cache manager.

Implements CacheManager so users can obtain caches through the standard Caching.getCachingProvider().getCacheManager() flow. Native methods with compatible signatures are preserved for backwards compatibility.

Manages the lifecycle of cache instances: creation, retrieval, and destruction. Also provides cache enumeration and cleanup.

Thread-safe using ConcurrentHashMap. Once closed, all operations throw IllegalStateException.

  • Constructor Details

    • LoomJCacheManager

      public LoomJCacheManager()
      Create a new cache manager with the default URI.
    • LoomJCacheManager

      public LoomJCacheManager(URI uri)
      Create a new cache manager with the specified URI.
      Parameters:
      uri - the URI identifying this cache manager (must not be null)
    • LoomJCacheManager

      public LoomJCacheManager(URI uri, @Nullable javax.cache.spi.CachingProvider cachingProvider, @Nullable ClassLoader classLoader, @Nullable Properties properties)
      Full constructor used by LoomCachingProvider to wire in the owning provider, class loader, and properties per JSR-107 requirements.
    • LoomJCacheManager

      public LoomJCacheManager(URI uri, @Nullable javax.cache.spi.CachingProvider cachingProvider, @Nullable ClassLoader classLoader, @Nullable Properties properties, @Nullable DataStructureRegistry distributedRegistry)
      Full constructor including an optional DataStructureRegistry for distributed (Raft-replicated) JCache state (P1.4).

      When distributedRegistry is non-null, any cache created through this manager defaults to distributed mode so its state is Raft-replicated together with the rest of the node's data structures.

    • LoomJCacheManager

      public LoomJCacheManager(URI uri, @Nullable javax.cache.spi.CachingProvider cachingProvider, @Nullable ClassLoader classLoader, @Nullable Properties properties, @Nullable DataStructureRegistry distributedRegistry, @Nullable com.loomcache.server.jcache.LoomJCacheClusterClient distributedClusterClient)
  • Method Details

    • createCache

      public <K,V> LoomJCache<K,V> createCache(String name, LoomJCacheConfig<K,V> config)
      Create a cache with the given name and LoomCache-native configuration.
      Type Parameters:
      K - the key type
      V - the value type
      Parameters:
      name - the cache name (not null)
      config - the LoomCache-native configuration (not null)
      Returns:
      the created cache
      Throws:
      IllegalStateException - if manager is closed
      javax.cache.CacheException - if cache already exists
    • getCache

      public <K,V> @Nullable LoomJCache<K,V> getCache(String name)
      Native get-by-name returning our raw cache type (backwards compatible).
      Specified by:
      getCache in interface javax.cache.CacheManager
    • destroyCache

      public void destroyCache(String name)
      Destroy (remove and close) a cache by name.
      Specified by:
      destroyCache in interface javax.cache.CacheManager
    • getCachingProvider

      public javax.cache.spi.CachingProvider getCachingProvider()
      Specified by:
      getCachingProvider in interface javax.cache.CacheManager
    • getURI

      public URI getURI()
      Specified by:
      getURI in interface javax.cache.CacheManager
    • getClassLoader

      public ClassLoader getClassLoader()
      Specified by:
      getClassLoader in interface javax.cache.CacheManager
    • getProperties

      public Properties getProperties()
      Specified by:
      getProperties in interface javax.cache.CacheManager
    • createCache

      public <K, V, C extends javax.cache.configuration.Configuration<K,V>> javax.cache.Cache<K,V> createCache(String cacheName, C configuration) throws IllegalArgumentException
      Specified by:
      createCache in interface javax.cache.CacheManager
      Throws:
      IllegalArgumentException
    • getCache

      public <K,V> @Nullable javax.cache.Cache<K,V> getCache(String cacheName, Class<K> keyType, Class<V> valueType)
      Specified by:
      getCache in interface javax.cache.CacheManager
    • getCacheNames

      public Set<String> getCacheNames()
      Specified by:
      getCacheNames in interface javax.cache.CacheManager
    • cacheCount

      public int cacheCount()
      Get the number of caches managed.
    • enableManagement

      public void enableManagement(String cacheName, boolean enabled)
      Specified by:
      enableManagement in interface javax.cache.CacheManager
    • enableStatistics

      public void enableStatistics(String cacheName, boolean enabled)
      Specified by:
      enableStatistics in interface javax.cache.CacheManager
    • isClosed

      public boolean isClosed()
      Specified by:
      isClosed in interface javax.cache.CacheManager
    • unwrap

      public <T> T unwrap(Class<T> clazz)
      Specified by:
      unwrap in interface javax.cache.CacheManager
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface javax.cache.CacheManager
      Specified by:
      close in interface Closeable
    • isOpen

      public boolean isOpen()
      Check if the manager is open.