Interface ContainerContext

All Known Implementing Classes:
DefaultCacheServer.SimpleContext

public interface ContainerContext
ContainerContext represents various aspects of the container infrastructure that could be used by Coherence applications working in the context of the ContainerAdapter.
Since:
Coherence 12.2.1
Author:
gg 2014.06.04
  • Method Details

    • getDomainPartition

      String getDomainPartition()
      Obtain the Domain Partition name associated with this ContainerContext.

      Note, that to get the name of the GLOBAL DomainPartition, the caller should do the following:

          getGlobalContext().getDomainPartition();
       

      Returns:
      the Domain Partition name or null if the container does not support Multi-Tenancy or this feature is turned off
    • isGlobalDomainPartition

      boolean isGlobalDomainPartition()
      Check whether or not the DomainPartition associated with this context is GLOBAL.

      Note, that this call is basically equivalent to the following:

          equals(getGlobalContext());
       

      Returns:
      true if the DomainPartition associated with this context is GLOBAL
    • getGlobalContext

      ContainerContext getGlobalContext()
      Obtain the ContainerContext associated with GLOBAL Domain Partition.

      Important note: since the ContainerContext object could use the context as a part of the event dispatcher or listener identity, it's imperative for the container to maintain no more than one instance of the global context.

      Returns:
      the ContainerContext associated with the GLOBAL Domain Partition.
    • getCurrentThreadContext

      ContainerContext getCurrentThreadContext()
      Obtain the ContainerContext associated with the current thread. Note, that the returned context could only be one of
      • null, if the current thread is not associated with any context;
      • the GLOBAL context;
      • this ContainerContext;
      • another instance of ContainerContext representing the same Domain Partition as this context.
      Note2: since the ContainerContext object could use the context as a part of the event dispatcher or listener identity, it's imperative for the container to maintain no more than one instance of the context per distinct Domain Partition per application.
      Returns:
      the ContainerContext associated with the current thread or null if the thread has no association
    • setCurrentThreadContext

      void setCurrentThreadContext()
      Set the execution context for the calling thread to be associated with this ContainerContext's Domain Partition.

      Note, that to set the execution context as GLOBAL, the caller should do the following:

          getGlobalContext().setCurrentThreadContext();
       

    • resetCurrentThreadContext

      void resetCurrentThreadContext()
      Reset the execution context for the calling thread to be associated with this ContainerContext's Domain Partition. This method should only be called if the thread context was changed using setCurrentThreadContext().
    • runInDomainPartitionContext

      <V> V runInDomainPartitionContext(Callable<V> action)
      Call the specified action in the context of the associated Domain Partition.

      Note, that to call the action in the GLOBAL context, the caller should do the following:

          getGlobalContext().runInDomainPartitionContext(action);
       

      Type Parameters:
      V - the result type of the action
      Parameters:
      action - the action to call
      Returns:
      the result of the Callable action
    • runInDomainPartitionContext

      default void runInDomainPartitionContext(Runnable action)
      Run the specified action in the context of the associated Domain Partition.

      Note, that to run the action in the GLOBAL context, the caller should do the following:

          getGlobalContext().runInDomainPartitionContext(action);
       

      Parameters:
      action - the action to run
    • isCacheShared

      boolean isCacheShared(String sCache)
      Check whether or not the cache with the specified name should be shared across various Domain Partitions.
      Parameters:
      sCache - the cache name
      Returns:
      true iff the specified cache should be shared
    • getCacheAttribute

      Object getCacheAttribute(String sCache, String sAttribute)
      Obtain a value for a configuration attribute for a given cache.
      Parameters:
      sCache - the cache name
      sAttribute - the attribute name
      Returns:
      the specified attribute value or null, if the default value should be used
    • getSharedCaches

      Set<String> getSharedCaches()
      Get a set of names for all shared caches. Those names will be used to start corresponding cache services during application activation.
      Returns:
      the set of shared cache names