Class MapSessionFactoryLookup
java.lang.Object
org.springframework.data.cassandra.core.cql.session.lookup.MapSessionFactoryLookup
- All Implemented Interfaces:
SessionFactoryLookup
Simple
SessionFactoryLookup
implementation that relies on a map for doing lookups.
Useful for testing environments or applications that need to match arbitrary String
names to target
SessionFactory
objects. This class is not thread-safe for modifications. Once initialized, it can be shared
amongst multiple threads and is thread-safe for reading.
- Since:
- 2.0
- Author:
- Mark Paluch
-
Constructor Summary
ConstructorDescriptionCreate a new instance ofMapSessionFactoryLookup
.MapSessionFactoryLookup
(String sessionFactoryName, SessionFactory sessionFactory) Create a new instance ofMapSessionFactoryLookup
.MapSessionFactoryLookup
(Map<String, SessionFactory> sessionFactories) Create a new instance ofMapSessionFactoryLookup
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addSessionFactory
(String sessionFactoryName, SessionFactory sessionFactory) Add the suppliedSessionFactory
to the map ofsession factories
maintained by this object.Get theMap
ofsession factories
maintained by this object.getSessionFactory
(String sessionFactoryName) Implementations must implement this method to retrieve theSessionFactory
identified by the given name from their backing store.void
setSessionFactories
(Map<String, SessionFactory> sessionFactories) Set theMap
ofsession factories
; the keys areStrings
, the values are actualSessionFactory
instances.
-
Constructor Details
-
MapSessionFactoryLookup
public MapSessionFactoryLookup()Create a new instance ofMapSessionFactoryLookup
. -
MapSessionFactoryLookup
Create a new instance ofMapSessionFactoryLookup
.- Parameters:
sessionFactories
- theMap
ofsession factories
. The keys areStrings
, the values are actualSessionFactory
instances.
-
MapSessionFactoryLookup
Create a new instance ofMapSessionFactoryLookup
.- Parameters:
sessionFactoryName
- the name under which the suppliedSessionFactory
is to be addedsessionFactory
- theSessionFactory
to be added
-
-
Method Details
-
setSessionFactories
Set theMap
ofsession factories
; the keys areStrings
, the values are actualSessionFactory
instances.If the supplied
Map
is null, then this method call effectively has no effect.- Parameters:
sessionFactories
-Map
ofsession factories
.
-
getSessionFactories
- Returns:
Map
ofsession factories
.
-
addSessionFactory
Add the suppliedSessionFactory
to the map ofsession factories
maintained by this object.- Parameters:
sessionFactoryName
- the name under which the suppliedSessionFactory
is to be addedsessionFactory
- theSessionFactory
to be so added
-
getSessionFactory
public SessionFactory getSessionFactory(String sessionFactoryName) throws SessionFactoryLookupFailureException Description copied from interface:SessionFactoryLookup
Implementations must implement this method to retrieve theSessionFactory
identified by the given name from their backing store.- Specified by:
getSessionFactory
in interfaceSessionFactoryLookup
- Parameters:
sessionFactoryName
- the name of theSessionFactory
.- Returns:
- the
SessionFactory
(never null). - Throws:
SessionFactoryLookupFailureException
- if the lookup failed.
-