Class LoomCachingProvider

java.lang.Object
com.loomcache.server.jcache.LoomCachingProvider
All Implemented Interfaces:
Closeable, AutoCloseable, javax.cache.spi.CachingProvider

public final class LoomCachingProvider extends Object implements javax.cache.spi.CachingProvider
JSR-107 CachingProvider implementation and SPI entry point for LoomCache JCache managers.

Provides discovery and lifecycle management for LoomJCacheManager instances. Each unique URI + ClassLoader pair identifies a separate cache manager; the default URI is loomcache://default.

Registered via META-INF/services/javax.cache.spi.CachingProvider (JSR-107 discovery) and META-INF/services/com.loomcache.server.jcache.LoomCachingProvider (legacy/native discovery).

Thread Safety

All operations are thread-safe via ConcurrentHashMap.
Since:
2.0
  • Field Details

    • DEFAULT_URI

      public static final URI DEFAULT_URI
      Default URI for the cache manager when none is specified.
  • Constructor Details

    • LoomCachingProvider

      public LoomCachingProvider()
      Public no-arg constructor required by the ServiceLoader contract. Equivalent to new LoomCachingProvider(null). Caches created through this instance run in legacy local-mode, which is rejected when loomcache.profile=production.
    • LoomCachingProvider

      public LoomCachingProvider(@Nullable DataStructureRegistry registry)
      Construct a provider that hands out distributed (Raft-replicated) caches.

      When registry is non-null, any cache created through the returned provider defaults to distributed mode: its state is stored in a DistributedMap owned by the registry, which is Raft-replicated and snapshot-persisted together with every other distributed structure on the node. Passing null is equivalent to the no-arg constructor and yields local-mode caches. Local-mode caches are rejected in the production profile because standard JSR-107 usage would otherwise create non-distributed caches.

      Parameters:
      registry - the registry used to resolve backing DistributedMap instances (may be null to keep legacy in-process semantics)
    • LoomCachingProvider

      public LoomCachingProvider(@Nullable DataStructureRegistry registry, String host, int port)
      Construct a provider whose distributed caches route through the cluster protocol exposed by the given node endpoint.

      This legacy/test path opens a raw Socket from inside the server process and is rejected under loomcache.profile=production; the node-owned production provider must use the in-process registry constructor.

  • Method Details

    • getCacheManager

      public LoomJCacheManager getCacheManager(URI uri)
      Get or create a cache manager for the specified URI (native API).
    • hasCacheManager

      public boolean hasCacheManager(URI uri)
      Check if a cache manager exists for the given URI.
    • releaseCacheManager

      public void releaseCacheManager(URI uri)
      Close and remove the cache manager for the given URI.
    • getCacheManager

      public javax.cache.CacheManager getCacheManager(@Nullable URI uri, @Nullable ClassLoader classLoader, @Nullable Properties properties)
      Specified by:
      getCacheManager in interface javax.cache.spi.CachingProvider
    • getCacheManager

      public javax.cache.CacheManager getCacheManager(@Nullable URI uri, @Nullable ClassLoader classLoader)
      Specified by:
      getCacheManager in interface javax.cache.spi.CachingProvider
    • getCacheManager

      public LoomJCacheManager getCacheManager()
      Specified by:
      getCacheManager in interface javax.cache.spi.CachingProvider
    • getDefaultClassLoader

      public ClassLoader getDefaultClassLoader()
      Specified by:
      getDefaultClassLoader in interface javax.cache.spi.CachingProvider
    • getDefaultURI

      public URI getDefaultURI()
      Specified by:
      getDefaultURI in interface javax.cache.spi.CachingProvider
    • getDefaultProperties

      public Properties getDefaultProperties()
      Specified by:
      getDefaultProperties in interface javax.cache.spi.CachingProvider
    • close

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

      public void close(@Nullable ClassLoader classLoader)
      Specified by:
      close in interface javax.cache.spi.CachingProvider
    • close

      public void close(@Nullable URI uri, @Nullable ClassLoader classLoader)
      Specified by:
      close in interface javax.cache.spi.CachingProvider
    • isSupported

      public boolean isSupported(javax.cache.configuration.OptionalFeature feature)
      Specified by:
      isSupported in interface javax.cache.spi.CachingProvider