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 String
GLOBAL
The name of the GLOBAL Domain Partition.static ContainerContext
GLOBAL_CONTEXT
The GLOBAL context.static String
SHARED
The 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 String
evaluateAttribute(String sCache, String sAttribute)
Get the value for a given macro attribute for a given cache mapping.Object
getCacheAttribute(String sCache, String sAttribute)
Obtain a value for a configuration attribute for a given cache.ContainerContext
getCurrentThreadContext()
Obtain the ContainerContext associated with the current thread.String
getDomainPartition()
Obtain the Domain Partition name associated with this ContainerContext.ContainerContext
getGlobalContext()
Obtain the ContainerContext associated with GLOBAL Domain Partition.Set<String>
getSharedCaches()
Get a set of names for all shared caches.boolean
isCacheShared(String sCache)
Check whether or not the cache with the specified name should be shared across various Domain Partitions.boolean
isGlobalDomainPartition()
Check whether or not the DomainPartition associated with this context is GLOBAL.void
resetCurrentThreadContext()
Reset the execution context for the calling thread to be associated with this ContainerContext's Domain Partition.<V> V
runInDomainPartitionContext(Callable<V> action)
Call the specified action in the context of the associated Domain Partition.void
setCurrentThreadContext()
Set the execution context for the calling thread to be associated with this ContainerContext's Domain Partition.String
toString()
-
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:ContainerContext
Obtain 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:
getDomainPartition
in 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:ContainerContext
Check 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:
isGlobalDomainPartition
in interfaceContainerContext
- Returns:
true
if the DomainPartition associated with this context is GLOBAL
-
getGlobalContext
public ContainerContext getGlobalContext()
Description copied from interface:ContainerContext
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.
- Specified by:
getGlobalContext
in interfaceContainerContext
- Returns:
- the ContainerContext associated with the GLOBAL Domain Partition.
-
getCurrentThreadContext
public ContainerContext getCurrentThreadContext()
Description copied from interface:ContainerContext
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.
- Specified by:
getCurrentThreadContext
in 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:ContainerContext
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 usingContainerContext.setCurrentThreadContext()
.- Specified by:
resetCurrentThreadContext
in interfaceContainerContext
-
setCurrentThreadContext
public void setCurrentThreadContext()
Description copied from interface:ContainerContext
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();
- Specified by:
setCurrentThreadContext
in interfaceContainerContext
-
runInDomainPartitionContext
public <V> V runInDomainPartitionContext(Callable<V> action)
Description copied from interface:ContainerContext
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);
- Specified by:
runInDomainPartitionContext
in 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:ContainerContext
Check whether or not the cache with the specified name should be shared across various Domain Partitions.- Specified by:
isCacheShared
in 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:ContainerContext
Obtain a value for a configuration attribute for a given cache.- Specified by:
getCacheAttribute
in 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:ContainerContext
Get a set of names for all shared caches. Those names will be used to start corresponding cache services duringapplication activation
.- Specified by:
getSharedCaches
in interfaceContainerContext
- Returns:
- the set of shared cache names
-
-