public interface Session extends AutoCloseable
NamedCaches, 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 Sessions. 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 Sessions are expected to maintain their own references to Sessions. Coherence provides no mechanism to identify and obtain previously created Sessions. Furthermore, applications are expected to correctly close Sessions when they are no longer required.
SessionProvider| Modifier and Type | Interface and Description |
|---|---|
static interface |
Session.Option
An immutable option for creating and configuring
Sessions. |
| Modifier and Type | Method and Description |
|---|---|
static Session |
create(Session.Option... options)
Create a
Session based on the current calling context and provided Session.Options, using the default (auto-detected) SessionProvider, |
<K,V> NamedCache<K,V> |
getCache(String sName, NamedCache.Option... options)
|
close<K,V> NamedCache<K,V> getCache(String sName, NamedCache.Option... options)
K - the type of keys for the NamedCacheV - the type of values for the NamedCachesName - the name of the NamedCacheoptions - the NamedCache.OptionsNamedCachestatic Session create(Session.Option... options) throws IllegalArgumentException, IllegalStateException
Session based on the current calling context and provided Session.Options, using the default (auto-detected) SessionProvider,options - the Session.Options for the SessionSessionIllegalArgumentException - when a Session or SessionProvider can't be acquired using the specified Session.OptionsIllegalStateException - when a SessionProvider can't be auto-detectedSessionProvider#createSession(Option...)