Package com.tangosol.net
Class DefaultCacheServer.SimpleContext
- java.lang.Object
-
- com.tangosol.net.DefaultCacheServer.SimpleContext
-
- All Implemented Interfaces:
ContainerContext
- Enclosing class:
- DefaultCacheServer
public static class DefaultCacheServer.SimpleContext extends Object implements ContainerContext
Simple ContainerContext implementation.
-
-
Field Summary
Fields Modifier and Type Field Description static StringGLOBALThe name of the GLOBAL Domain Partition.static ContainerContextGLOBAL_CONTEXTThe GLOBAL context.static StringSHAREDThe cache mapping parameter defining a "shared" cache.
-
Constructor Summary
Constructors Constructor Description SimpleContext(String sTenant, ContainerAdapter adapter)Construct the SimpleContext for a given tenant.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected StringevaluateAttribute(String sCache, String sAttribute)Get the value for a given macro attribute for a given cache mapping.ObjectgetCacheAttribute(String sCache, String sAttribute)Obtain a value for a configuration attribute for a given cache.ContainerContextgetCurrentThreadContext()Obtain the ContainerContext associated with the current thread.StringgetDomainPartition()Obtain the Domain Partition name associated with this ContainerContext.ContainerContextgetGlobalContext()Obtain the ContainerContext associated with GLOBAL Domain Partition.Set<String>getSharedCaches()Get a set of names for all shared caches.booleanisCacheShared(String sCache)Check whether or not the cache with the specified name should be shared across various Domain Partitions.booleanisGlobalDomainPartition()Check whether or not the DomainPartition associated with this context is GLOBAL.voidresetCurrentThreadContext()Reset the execution context for the calling thread to be associated with this ContainerContext's Domain Partition.<V> VrunInDomainPartitionContext(Callable<V> action)Call the specified action in the context of the associated Domain Partition.voidsetCurrentThreadContext()Set the execution context for the calling thread to be associated with this ContainerContext's Domain Partition.StringtoString()-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.tangosol.application.ContainerContext
runInDomainPartitionContext
-
-
-
-
Field Detail
-
GLOBAL
public static final String GLOBAL
The name of the GLOBAL Domain Partition.- See Also:
- Constant Field Values
-
SHARED
public static final String SHARED
The cache mapping parameter defining a "shared" cache.- See Also:
- Constant Field Values
-
GLOBAL_CONTEXT
public static final ContainerContext GLOBAL_CONTEXT
The GLOBAL context.
-
-
Constructor Detail
-
SimpleContext
public SimpleContext(String sTenant, ContainerAdapter adapter)
Construct the SimpleContext for a given tenant.- Parameters:
sTenant- the tenant nameadapter- the corresponding ContainerAdapter
-
-
Method Detail
-
getDomainPartition
public String getDomainPartition()
Description copied from interface:ContainerContextObtain the Domain Partition name associated with this ContainerContext.Note, that to get the name of the the GLOBAL DomainPartition, the caller should do the following:
getGlobalContext().getDomainPartition();- Specified by:
getDomainPartitionin interfaceContainerContext- Returns:
- the Domain Partition name or null if the container does not support Multi-Tenancy or this feature is turned off
-
isGlobalDomainPartition
public boolean isGlobalDomainPartition()
Description copied from interface:ContainerContextCheck whether or not the DomainPartition associated with this context is GLOBAL.Note, that this call is basically equivalent to the following:
equals(getGlobalContext());- Specified by:
isGlobalDomainPartitionin interfaceContainerContext- Returns:
trueif the DomainPartition associated with this context is GLOBAL
-
getGlobalContext
public ContainerContext getGlobalContext()
Description copied from interface:ContainerContextObtain 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.
- Specified by:
getGlobalContextin interfaceContainerContext- Returns:
- the ContainerContext associated with the GLOBAL Domain Partition.
-
getCurrentThreadContext
public ContainerContext getCurrentThreadContext()
Description copied from interface:ContainerContextObtain 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.
- Specified by:
getCurrentThreadContextin interfaceContainerContext- Returns:
- the ContainerContext associated with the current thread or null if the thread has no association
-
resetCurrentThreadContext
public void resetCurrentThreadContext()
Description copied from interface:ContainerContextReset 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 usingContainerContext.setCurrentThreadContext().- Specified by:
resetCurrentThreadContextin interfaceContainerContext
-
setCurrentThreadContext
public void setCurrentThreadContext()
Description copied from interface:ContainerContextSet 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();- Specified by:
setCurrentThreadContextin interfaceContainerContext
-
runInDomainPartitionContext
public <V> V runInDomainPartitionContext(Callable<V> action)
Description copied from interface:ContainerContextCall 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);- Specified by:
runInDomainPartitionContextin interfaceContainerContext- Type Parameters:
V- the result type of the action- Parameters:
action- the action to call- Returns:
- the result of the Callable action
-
isCacheShared
public boolean isCacheShared(String sCache)
Description copied from interface:ContainerContextCheck whether or not the cache with the specified name should be shared across various Domain Partitions.- Specified by:
isCacheSharedin interfaceContainerContext- Parameters:
sCache- the cache name- Returns:
- true iff the specified cache should be shared
-
getCacheAttribute
public Object getCacheAttribute(String sCache, String sAttribute)
Description copied from interface:ContainerContextObtain a value for a configuration attribute for a given cache.- Specified by:
getCacheAttributein interfaceContainerContext- Parameters:
sCache- the cache namesAttribute- the attribute name- Returns:
- the specified attribute value or null, if the default value should be used
-
getSharedCaches
public Set<String> getSharedCaches()
Description copied from interface:ContainerContextGet a set of names for all shared caches. Those names will be used to start corresponding cache services duringapplication activation.- Specified by:
getSharedCachesin interfaceContainerContext- Returns:
- the set of shared cache names
-
-