Package com.tangosol.net
Class CoherenceSession
- java.lang.Object
-
- com.tangosol.net.CoherenceSession
-
- All Implemented Interfaces:
Session
,AutoCloseable
public class CoherenceSession extends Object implements Session
An implementation of aSession
allowing applications to use the new operator to create aSession
via the defaultSessionProvider
.- Author:
- bo 2015.09.27
- See Also:
Session
,SessionProvider
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.tangosol.net.Session
Session.Option
-
-
Constructor Summary
Constructors Constructor Description CoherenceSession()
Constructs aCoherenceSession
using the default session configuration.CoherenceSession(Session.Option... options)
Deprecated.since 20.12 useCoherenceSession(SessionConfiguration, Coherence.Mode, Iterable)
CoherenceSession(SessionConfiguration configuration, Coherence.Mode mode, Iterable<? extends EventInterceptor<?>> interceptors)
Constructs aCoherenceSession
based on the specifiedSessionConfiguration
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
activate()
Activate thisSession
.void
close()
<K,V>
NamedCache<K,V>getCache(String sName, NamedMap.Option... options)
InterceptorRegistry
getInterceptorRegistry()
Return theInterceptorRegistry
for this session.<K,V>
NamedMap<K,V>getMap(String sName, NamedMap.Option... options)
String
getName()
Return the name of this session, if available.ResourceRegistry
getResourceRegistry()
Return theResourceRegistry
for this session.String
getScopeName()
Return the scope name of this cache factory, if available.Service
getService(String sServiceName)
Returns a service for the given name ornull
if no service exists in this session with the specified name.<V> NamedTopic<V>
getTopic(String sName, NamedCollection.Option... options)
Acquire aNamedTopic
using the specifiedValueTypeAssertion
.boolean
isActive()
Returntrue
if thisSession
is active and has not been closed.boolean
isCacheActive(String sCacheName, ClassLoader loader)
Validate whether a cache with the given name is active in the context of the givenClassLoader
.boolean
isMapActive(String sMapName, ClassLoader loader)
Validate whether a map with the given name is active in the context of the givenClassLoader
.boolean
isTopicActive(String sTopicName, ClassLoader loader)
Validate whether a topic with the given name is active in the context of the givenClassLoader
.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.tangosol.net.Session
createPublisher, createPublisher, createSubscriber, createSubscriber, getTopic
-
-
-
-
Constructor Detail
-
CoherenceSession
public CoherenceSession()
Constructs aCoherenceSession
using the default session configuration.- Throws:
IllegalStateException
- if a session could not be created- See Also:
SessionConfiguration.defaultSession()
-
CoherenceSession
public CoherenceSession(SessionConfiguration configuration, Coherence.Mode mode, Iterable<? extends EventInterceptor<?>> interceptors)
Constructs aCoherenceSession
based on the specifiedSessionConfiguration
.- Parameters:
configuration
- theSessionConfiguration
s for theCoherenceSession
mode
- the mode Coherence is running ininterceptors
- optionalinterceptors
to add to the session in addition to any in the configuration- Throws:
IllegalStateException
- if a session could not be created
-
CoherenceSession
@Deprecated public CoherenceSession(Session.Option... options)
Deprecated.since 20.12 useCoherenceSession(SessionConfiguration, Coherence.Mode, Iterable)
Constructs aCoherenceSession
based on the specifiedSession.Option
s using the defaultSessionProvider
.- Parameters:
options
- theSession.Option
s for theCoherenceSession
- Throws:
IllegalStateException
- if a session could not be created
-
-
Method Detail
-
getMap
public <K,V> NamedMap<K,V> getMap(String sName, NamedMap.Option... options)
Description copied from interface:Session
-
getCache
public <K,V> NamedCache<K,V> getCache(String sName, NamedMap.Option... options)
Description copied from interface:Session
- Specified by:
getCache
in interfaceSession
- Type Parameters:
K
- the type of keys for theNamedCache
V
- the type of values for theNamedCache
- Parameters:
sName
- the name of theNamedCache
options
- theNamedMap.Option
s- Returns:
- a
NamedCache
-
getTopic
public <V> NamedTopic<V> getTopic(String sName, NamedCollection.Option... options)
Description copied from interface:Session
Acquire aNamedTopic
using the specifiedValueTypeAssertion
.- Specified by:
getTopic
in interfaceSession
- Type Parameters:
V
- the type of elements for theNamedTopic
- Parameters:
sName
- the name of theNamedTopic
- Returns:
- a
NamedCache
-
close
public void close() throws Exception
- Specified by:
close
in interfaceAutoCloseable
- Throws:
Exception
-
getResourceRegistry
public ResourceRegistry getResourceRegistry()
Description copied from interface:Session
Return theResourceRegistry
for this session.- Specified by:
getResourceRegistry
in interfaceSession
- Returns:
- the ResourceRegistry for this session
-
getInterceptorRegistry
public InterceptorRegistry getInterceptorRegistry()
Description copied from interface:Session
Return theInterceptorRegistry
for this session.EventInterceptor
s registered with this session will be scoped to services and caches created by this session.- Specified by:
getInterceptorRegistry
in interfaceSession
- Returns:
- the
InterceptorRegistry
for this session
-
getName
public String getName()
Description copied from interface:Session
Return the name of this session, if available.
-
getScopeName
public String getScopeName()
Description copied from interface:Session
Return the scope name of this cache factory, if available.- Specified by:
getScopeName
in interfaceSession
- Returns:
- the scope name of this cache factory, if available;
null
otherwise
-
isCacheActive
public boolean isCacheActive(String sCacheName, ClassLoader loader)
Description copied from interface:Session
Validate whether a cache with the given name is active in the context of the givenClassLoader
. The ClassLoader should be the same as provided to a previous call toSession.getCache(String, NamedCache.Option...)
.- Specified by:
isCacheActive
in interfaceSession
- Parameters:
sCacheName
- the cache nameloader
- the ClassLoader used to originally obtain the cache- Returns:
- true if cache is active in context of the provided ClassLoader
-
isMapActive
public boolean isMapActive(String sMapName, ClassLoader loader)
Description copied from interface:Session
Validate whether a map with the given name is active in the context of the givenClassLoader
. The ClassLoader should be the same as provided to a previous call toSession.getMap(String, NamedMap.Option...)
.- Specified by:
isMapActive
in interfaceSession
- Parameters:
sMapName
- the map nameloader
- the ClassLoader used to originally obtain the map- Returns:
- true if map is active in context of the provided ClassLoader
-
isTopicActive
public boolean isTopicActive(String sTopicName, ClassLoader loader)
Description copied from interface:Session
Validate whether a topic with the given name is active in the context of the givenClassLoader
. The ClassLoader should be the same as provided to a previous call toSession.getTopic(String, NamedTopic.Option...)
.- Specified by:
isTopicActive
in interfaceSession
- Parameters:
sTopicName
- the cache nameloader
- the ClassLoader used to originally obtain the topic- Returns:
- true if topic is active in context of the provided ClassLoader
-
activate
public void activate()
Description copied from interface:Session
-
isActive
public boolean isActive()
Description copied from interface:Session
Returntrue
if thisSession
is active and has not been closed.
-
getService
public Service getService(String sServiceName)
Description copied from interface:Session
Returns a service for the given name ornull
if no service exists in this session with the specified name.- Specified by:
getService
in interfaceSession
- Parameters:
sServiceName
- the service name- Returns:
- the requested Service or
null
if no service exists in this session with the specified name
-
-