Class CacheContextFactory

java.lang.Object
com.j_spaces.core.cache.CacheContextFactory

public class CacheContextFactory extends Object
  • Constructor Details

    • CacheContextFactory

      public CacheContextFactory(CacheManager cacheManager, String fullSpaceName)
  • Method Details

    • getCacheContext

      public Context getCacheContext()
      returns a free Context from the pool. If none are available, one is allocated on demand. This call *MUST* be followed by a freeCacheContext() in a finally() block!
      Returns:
      a free Context object
    • viewCacheContext

      public Context viewCacheContext()
      returns the active Context of this thread or null if none
      Returns:
      an active Context object
    • freeCacheContext

      public void freeCacheContext(Context ctx)
      Free a Context acquired by getCacheContext(). If Context was taken from the pool, it will be returned to it. Otherwise, it was allocated on demand, and will be collected by the JVM GC. Make sure to call this method from within a finally block to release any acquired Contexts.
      Parameters:
      ctx - A Context object in use, and to be freed.
    • closeAllContexts

      public void closeAllContexts()
      close all contexts free and occupied, waits until all Contexts are returned.