public interface Session extends AutoCloseable
NamedCache
s, from a deployed module.
Resources provided by a Session
are scoped to the Session
.
When a Session
is closed, all resources are closed.
Once closed, references to resources are no longer valid. Any
attempt to use a closed Session
or closed resource may throw an
IllegalStateException.
The effect of closing a resource is specific to the type of resource.
For example, resources provided by a Session
may represent
shared (ie: clustered) data-structures and services. In such circumstances,
closing these resources only closes the Session
-based representation,
not the underlying shared infrastructure, which may remain active for other
Session
s. Future requests of a Session
for previously closed
resources of this kind will likely yield a new reference to logically the
same underlying resource. To destroy such resources, instead of close,
resource-specific methods should be used.
Applications making use of Session
s are expected to maintain their
own references to Session
s. Coherence provides no mechanism to
identify and obtain previously created Session
s. Furthermore,
applications are expected to correctly close Session
s when they are
no longer required.
SessionProvider
Modifier and Type | Interface and Description |
---|---|
static interface |
Session.Option
An immutable option for creating and configuring
Session s. |
Modifier and Type | Method and Description |
---|---|
static Session |
create(Session.Option... options)
Create a
Session based on the current calling
context and provided Session.Option s, using the default (auto-detected)
SessionProvider , |
<K,V> NamedCache<K,V> |
getCache(String sName,
NamedCache.Option... options)
|
<V> NamedTopic<V> |
getTopic(String sName,
NamedCollection.Option... options)
Acquire a
NamedTopic using the
specified ValueTypeAssertion . |
close
<K,V> NamedCache<K,V> getCache(String sName, NamedCache.Option... options)
K
- the type of keys for the NamedCache
V
- the type of values for the NamedCache
sName
- the name of the NamedCache
options
- the NamedCache.Option
sNamedCache
<V> NamedTopic<V> getTopic(String sName, NamedCollection.Option... options)
NamedTopic
using the
specified ValueTypeAssertion
.V
- the type of elements for the NamedTopic
sName
- the name of the NamedTopic
NamedCache
static Session create(Session.Option... options) throws IllegalArgumentException, IllegalStateException
Session
based on the current calling
context and provided Session.Option
s, using the default (auto-detected)
SessionProvider
,options
- the Session.Option
s for the Session
Session
IllegalArgumentException
- when a Session
or SessionProvider
can't be
acquired using the specified Session.Option
sIllegalStateException
- when a SessionProvider
can't be auto-detectedSessionProvider#createSession(Option...)