public class SessionFactory
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static interface |
SessionFactory.PersistenceConsumer<T>
Functional Interface that is able to throw PersistenceException.
|
static class |
SessionFactory.SessionCloseThread
A thread used to manage SessionFactory reclaimable sessions and
close any sessions that have exceeded their lifespan.
|
| Modifier and Type | Field and Description |
|---|---|
private static boolean |
enabled
If the session reclaiming is enabled/disabled.
|
private static CentralLogger |
LOG
Logger.
|
private Session |
reclaimable
The session that can be reclaimed.
|
private java.lang.Long |
timestamp
Timestamp representing when each of the reclaimable sessions was added.
|
| Constructor and Description |
|---|
SessionFactory()
Constructor that registers the SessionFactory in a Daemon Thread
that manages session closing.
|
| Modifier and Type | Method and Description |
|---|---|
Session |
create(Database database,
DmoVersioning dmoVersion,
SessionFactory.PersistenceConsumer<Session> initialize,
java.lang.String tenantId)
Reclaims a session if one is available or create a new one
with the given parameters.
|
void |
expire()
Method used to close a session that can't be reclaimed.
|
boolean |
isEnabled()
Return a boolean value that tells if the session reclaiming is enabled/disabled.
|
void |
markReclaimable(Session session)
Mark a session as being reclaimable.
|
private static final CentralLogger LOG
private static boolean enabled
private Session reclaimable
private java.lang.Long timestamp
public SessionFactory()
public boolean isEnabled()
true if session reclaiming is enabled, false otherwise.public Session create(Database database, DmoVersioning dmoVersion, SessionFactory.PersistenceConsumer<Session> initialize, java.lang.String tenantId) throws PersistenceException
database - The database used for creating the sessiondmoVersion - The DMO version trackerinitialize - Initialization lambda used to associate records
with a new session when it is created and not
reclaimed.tenantId - The id of the tenant for which the session is created.PersistenceException - If there is an error getting a JDBC connection from the data source.public void markReclaimable(Session session)
session - The session that is marked as reclaimable.public void expire()