public class MapSessionFactoryLookup extends Object implements SessionFactoryLookup
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.
Constructor and Description |
---|
MapSessionFactoryLookup()
Create a new instance of
MapSessionFactoryLookup . |
MapSessionFactoryLookup(Map<String,SessionFactory> sessionFactories)
Create a new instance of
MapSessionFactoryLookup . |
MapSessionFactoryLookup(String sessionFactoryName,
SessionFactory sessionFactory)
Create a new instance of
MapSessionFactoryLookup . |
Modifier and Type | Method and Description |
---|---|
void |
addSessionFactory(String sessionFactoryName,
SessionFactory sessionFactory)
Add the supplied
SessionFactory to the map of session factories maintained by this
object. |
Map<String,SessionFactory> |
getSessionFactories()
Get the
Map of session factories maintained by this object. |
SessionFactory |
getSessionFactory(String sessionFactoryName)
Implementations must implement this method to retrieve the
SessionFactory identified by the given name from
their backing store. |
void |
setSessionFactories(Map<String,SessionFactory> sessionFactories)
Set the
Map of session factories ; the keys are Strings , the values
are actual SessionFactory instances. |
public MapSessionFactoryLookup()
MapSessionFactoryLookup
.public MapSessionFactoryLookup(Map<String,SessionFactory> sessionFactories)
MapSessionFactoryLookup
.sessionFactories
- the Map
of session factories
. The keys are Strings
, the values are actual SessionFactory
instances.public MapSessionFactoryLookup(String sessionFactoryName, SessionFactory sessionFactory)
MapSessionFactoryLookup
.sessionFactoryName
- the name under which the supplied SessionFactory
is to be addedsessionFactory
- the SessionFactory
to be addedpublic void setSessionFactories(@Nullable Map<String,SessionFactory> sessionFactories)
Map
of session factories
; the keys are Strings
, the values
are actual SessionFactory
instances.
If the supplied Map
is null, then this method call effectively has no effect.
sessionFactories
- Map
of session factories
.public Map<String,SessionFactory> getSessionFactories()
Map
of session factories
.public void addSessionFactory(String sessionFactoryName, SessionFactory sessionFactory)
SessionFactory
to the map of session factories
maintained by this
object.sessionFactoryName
- the name under which the supplied SessionFactory
is to be addedsessionFactory
- the SessionFactory
to be so addedpublic SessionFactory getSessionFactory(String sessionFactoryName) throws SessionFactoryLookupFailureException
SessionFactoryLookup
SessionFactory
identified by the given name from
their backing store.getSessionFactory
in interface SessionFactoryLookup
sessionFactoryName
- the name of the SessionFactory
.SessionFactory
(never null).SessionFactoryLookupFailureException
- if the lookup failed.Copyright © 2011–2021 Pivotal Software, Inc.. All rights reserved.