HHH-13916 : Add a unique Session "token"

This commit is contained in:
Gail Badner 2020-04-09 14:09:15 -07:00 committed by Steve Ebersole
parent 7bca059f94
commit 903bb292e7
2 changed files with 18 additions and 0 deletions

View File

@ -118,6 +118,15 @@ default SharedSessionContractImplementor getSession() {
return this; return this;
} }
/**
* A "token" that is unique to this Session.
*
* @return The token
*/
default Object getSessionToken() {
return this;
}
/** /**
* Checks whether the session is closed. Provided separately from * Checks whether the session is closed. Provided separately from
* {@link #isOpen()} as this method does not attempt any JTA synchronization * {@link #isOpen()} as this method does not attempt any JTA synchronization

View File

@ -105,6 +105,7 @@ public abstract class AbstractSharedSessionContract implements SharedSessionCont
private final String tenantIdentifier; private final String tenantIdentifier;
protected transient FastSessionServices fastSessionServices; protected transient FastSessionServices fastSessionServices;
private UUID sessionIdentifier; private UUID sessionIdentifier;
private Object sessionToken;
private transient JdbcConnectionAccess jdbcConnectionAccess; private transient JdbcConnectionAccess jdbcConnectionAccess;
private transient JdbcSessionContext jdbcSessionContext; private transient JdbcSessionContext jdbcSessionContext;
@ -277,6 +278,14 @@ public UUID getSessionIdentifier() {
return sessionIdentifier; return sessionIdentifier;
} }
@Override
public Object getSessionToken() {
if ( sessionToken == null ) {
sessionToken = new Object();
}
return sessionToken;
}
@Override @Override
public String getTenantIdentifier() { public String getTenantIdentifier() {
return tenantIdentifier; return tenantIdentifier;