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
ConstructorsConstructorDescriptionCreate 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 TypeMethodDescriptionvoidaddSessionFactory(String sessionFactoryName, SessionFactory sessionFactory) Add the suppliedSessionFactoryto the map ofsession factoriesmaintained by this object.Get theMapofsession factoriesmaintained by this object.getSessionFactory(String sessionFactoryName) Implementations must implement this method to retrieve theSessionFactoryidentified by the given name from their backing store.voidsetSessionFactories(Map<String, SessionFactory> sessionFactories) Set theMapofsession factories; the keys areStrings, the values are actualSessionFactoryinstances.
-
Constructor Details
-
MapSessionFactoryLookup
public MapSessionFactoryLookup()Create a new instance ofMapSessionFactoryLookup. -
MapSessionFactoryLookup
Create a new instance ofMapSessionFactoryLookup.- Parameters:
sessionFactories- theMapofsession factories. The keys areStrings, the values are actualSessionFactoryinstances.
-
MapSessionFactoryLookup
Create a new instance ofMapSessionFactoryLookup.- Parameters:
sessionFactoryName- the name under which the suppliedSessionFactoryis to be addedsessionFactory- theSessionFactoryto be added
-
-
Method Details
-
setSessionFactories
Set theMapofsession factories; the keys areStrings, the values are actualSessionFactoryinstances.If the supplied
Mapis null, then this method call effectively has no effect.- Parameters:
sessionFactories-Mapofsession factories.
-
getSessionFactories
- Returns:
Mapofsession factories.
-
addSessionFactory
Add the suppliedSessionFactoryto the map ofsession factoriesmaintained by this object.- Parameters:
sessionFactoryName- the name under which the suppliedSessionFactoryis to be addedsessionFactory- theSessionFactoryto be so added
-
getSessionFactory
public SessionFactory getSessionFactory(String sessionFactoryName) throws SessionFactoryLookupFailureException Description copied from interface:SessionFactoryLookupImplementations must implement this method to retrieve theSessionFactoryidentified by the given name from their backing store.- Specified by:
getSessionFactoryin interfaceSessionFactoryLookup- Parameters:
sessionFactoryName- the name of theSessionFactory.- Returns:
- the
SessionFactory(never null). - Throws:
SessionFactoryLookupFailureException- if the lookup failed.
-