public class ClientSession extends AbstractSession
Description: This session is brokered by the server session for use in three-tiered applications. It is used to store the context of the connection, i.e. the login to be used for this cleint. This allows each client connected to the server to contain its own user login.
Responsibilities:
This class is an implementation of Session.
Please refer to that class for a full API. The public interface should be used.
Server,
UnitOfWork,
Serialized Form| Modifier and Type | Field and Description |
|---|---|
protected ConnectionPolicy |
connectionPolicy |
protected boolean |
isActive |
protected ServerSession |
parent |
protected Sequencing |
sequencing |
protected Accessor |
writeConnection |
accessor, broker, commitManager, ejbqlPlaceHolderQueries, eventManager, exceptionHandler, externalTransactionController, identityMapAccessor, integrityChecker, isInProfile, lastDescriptorAccessed, logSessionString, name, numberOfActiveUnitsOfWork, platform, profiler, project, properties, queries, sessionLog, transactionMutex, wasJTSTransactionInternallyStarted| Modifier | Constructor and Description |
|---|---|
protected |
ClientSession(Project project) |
|
ClientSession(ServerSession parent,
ConnectionPolicy connectionPolicy)
INTERNAL:
Create and return a new client session.
|
| Modifier and Type | Method and Description |
|---|---|
void |
afterTransaction(boolean committed,
boolean isExternalTransaction)
INTERNAL:
Called after transaction is completed (committed or rolled back)
|
void |
basicBeginTransaction()
INTERNAL:
This is internal to the unit of work and should never be called otherwise.
|
void |
basicCommitTransaction()
INTERNAL:
This is internal to the unit of work and should not be called otherwise.
|
void |
basicRollbackTransaction()
INTERNAL:
This is internal to the unit of work and should not be called otherwise.
|
void |
connect()
INTERNAL:
Connect the session only (this must be the write connection as the read is shared).
|
boolean |
containsQuery(java.lang.String queryName)
INTERNAL:
Was PUBLIC: customer will be redirected to
Session. |
void |
disconnect()
INTERNAL:
Disconnect the accessor only (this must be the write connection as the read is shared).
|
protected void |
finalize()
INTERNAL:
Release in case not released.
|
Accessor |
getAccessor()
INTERNAL:
Return the read or write connection depending on the transaction state.
|
ConnectionPolicy |
getConnectionPolicy()
ADVANCED:
This method will return the connection policy that was used during the
acquisition of this client session.
|
java.util.Map |
getDescriptors()
INTERNAL:
Was PUBLIC: customer will be redirected to
Session. |
AbstractSession |
getExecutionSession(DatabaseQuery query)
INTERNAL:
Gets the session which this query will be executed on.
|
ServerSession |
getParent()
INTERNAL:
Return the parent.
|
AbstractSession |
getParentIdentityMapSession(DatabaseQuery query,
boolean canReturnSelf,
boolean terminalOnly)
INTERNAL:
Gets the next link in the chain of sessions followed by a query's check
early return, the chain of sessions with identity maps all the way up to
the root session.
|
DatabaseQuery |
getQuery(java.lang.String name)
INTERNAL:
Was PUBLIC: customer will be redirected to
Session. |
DatabaseQuery |
getQuery(java.lang.String name,
java.util.Vector args)
INTERNAL:
|
Sequencing |
getSequencing()
INTERNAL:
Return the Sequencing object used by the session.
|
ServerPlatform |
getServerPlatform()
INTERNAL:
Marked internal as this is not customer API but helper methods for
accessing the server platform from within TopLink's other sessions types
(ie not DatabaseSession)
|
java.lang.String |
getSessionTypeString()
INTERNAL:
Returns the type of session, its class.
|
Accessor |
getWriteConnection()
INTERNAL:
Return the connection to be used for database modification.
|
protected boolean |
hasWriteConnection()
INTERNAL:
Return if this session has been connected.
|
void |
initializeIdentityMapAccessor()
INTERNAL:
Set up the IdentityMapManager.
|
void |
initializeSequencing()
INTERNAL:
was ADVANCED:
Creates sequencing object for the session.
|
boolean |
isActive()
INTERNAL:
Was PUBLIC: customer will be redirected to
Session. |
boolean |
isClientSession()
INTERNAL:
Return if this session is a client session.
|
boolean |
isConnected()
INTERNAL:
Was PUBLIC: customer will be redirected to
Session. |
void |
release()
INTERNAL:
Was PUBLIC: customer will be redirected to
Session. |
protected void |
releaseWriteConnection()
INTERNAL:
This is internal to the unit of work and should not be called otherwise.
|
protected void |
setConnectionPolicy(ConnectionPolicy connectionPolicy)
INTERNAL:
Set the connection policy.
|
protected void |
setIsActive(boolean isActive)
INTERNAL:
Set if the client session is actvie (has not been released).
|
protected void |
setParent(ServerSession parent)
INTERNAL:
Set the parent.
|
void |
setWriteConnection(Accessor writeConnection)
INTERNAL:
Set the connection to be used for database modification.
|
java.lang.String |
toString()
INTERNAL:
Print the connection status with the session.
|
acquireNonSynchronizedUnitOfWork, acquireUnitOfWork, addAlias, addEjbqlPlaceHolderQuery, addQuery, addQuery, beginExternalTransaction, beginTransaction, clearIntegrityChecker, clearLastDescriptorAccessed, clearProfile, clone, commitExternalTransaction, commitTransaction, compareObjects, compareObjectsDontMatch, config, copyObject, copyObject, copyReadOnlyClasses, deleteAllObjects, deleteAllObjects, deleteObject, doesObjectExist, dontLogMessages, endOperationProfile, executeCall, executeNonSelectingCall, executeNonSelectingSQL, executeQuery, executeQuery, executeQuery, executeQuery, executeQuery, executeQuery, executeQuery, executeQuery, executeQuery, executeQuery, executeQuery, executeQuery, executeQuery, executeSelectingCall, executeSQL, fine, finer, finest, getAccessor, getAccessor, getActiveSession, getActiveUnitOfWork, getAliasDescriptors, getAllQueries, getBroker, getClassDescriptor, getClassDescriptor, getClassDescriptorForAlias, getCommitManager, getDatasourceLogin, getDatasourcePlatform, getDefaultReadOnlyClasses, getDescriptor, getDescriptor, getDescriptorForAlias, getEjbqlPlaceHolderQueries, getEventManager, getExceptionHandler, getExceptionHandlerClass, getExternalTransactionController, getIdentityMapAccessor, getIdentityMapAccessorInstance, getIntegrityChecker, getLog, getLogin, getLogLevel, getLogLevel, getLogSessionString, getName, getNextQueryId, getNextSequenceNumberValue, getNumberOfActiveUnitsOfWork, getParentIdentityMapSession, getPlatform, getPlatform, getProfiler, getProject, getProperties, getProperty, getQueries, getRootSession, getSessionForClass, getSessionLog, getTransactionMutex, handleException, handleSevere, hasBroker, hasDescriptor, hasExceptionHandler, hasExternalTransactionController, hasProperties, incrementProfile, info, insertObject, internalExecuteQuery, isBroker, isClassReadOnly, isClassReadOnly, isDatabaseSession, isDistributedSession, isInBroker, isInProfile, isInTransaction, isRemoteSession, isRemoteUnitOfWork, isServerSession, isSessionBroker, isUnitOfWork, keyFromObject, keyFromObject, log, log, log, log, log, log, log, log, log, log, logMessage, logThrowable, prepareDatabaseQuery, processEJBQLQueries, processEJBQLQueries, readAllObjects, readAllObjects, readAllObjects, readAllObjects, readObject, readObject, readObject, readObject, readObject, refreshAndLockObject, refreshAndLockObject, refreshObject, releaseUnitOfWork, removeProperty, removeQuery, removeQuery, rollbackExternalTransaction, rollbackTransaction, setAccessor, setBroker, setCommitManager, setDatasourceLogin, setEventManager, setExceptionHandler, setExternalTransactionController, setIntegrityChecker, setIsInProfile, setLog, setLogin, setLogin, setLogLevel, setName, setNumberOfActiveUnitsOfWork, setProfiler, setProject, setProperties, setProperty, setQueries, setSessionLog, setTransactionMutex, setWasJTSTransactionInternallyStarted, severe, shouldLog, shouldLogMessages, startOperationProfile, unwrapObject, updateObject, updateProfile, validateQuery, verifyDelete, warning, wasJTSTransactionInternallyStarted, wrapObject, writeAllObjects, writeAllObjectsWithChangeSet, writeObject, writesCompletedprotected ServerSession parent
protected ConnectionPolicy connectionPolicy
protected Accessor writeConnection
protected boolean isActive
protected Sequencing sequencing
public ClientSession(ServerSession parent, ConnectionPolicy connectionPolicy)
protected ClientSession(Project project)
public void afterTransaction(boolean committed,
boolean isExternalTransaction)
afterTransaction in class AbstractSessionpublic void basicBeginTransaction()
basicBeginTransaction in class AbstractSessionpublic void basicCommitTransaction()
basicCommitTransaction in class AbstractSessionpublic void basicRollbackTransaction()
basicRollbackTransaction in class AbstractSessionpublic void connect()
throws DatabaseException
DatabaseExceptionpublic boolean containsQuery(java.lang.String queryName)
Session.
Return true if the pre-defined query is defined on the session.containsQuery in interface SessioncontainsQuery in class AbstractSessionpublic void disconnect()
throws DatabaseException
DatabaseExceptionprotected void finalize()
throws DatabaseException
finalize in class java.lang.ObjectDatabaseExceptionpublic Accessor getAccessor()
getAccessor in class AbstractSessionpublic ConnectionPolicy getConnectionPolicy()
public java.util.Map getDescriptors()
Session.
Return all registered descriptors.
The clients session inherits its parent's descriptors.getDescriptors in interface SessiongetDescriptors in class AbstractSessionpublic AbstractSession getParentIdentityMapSession(DatabaseQuery query, boolean canReturnSelf, boolean terminalOnly)
Used for session broker which delegates to registered sessions, or UnitOfWork which checks parent identity map also.
getParentIdentityMapSession in class AbstractSessioncanReturnSelf - true when method calls itself. If the path
starting at this is acceptable. Sometimes true if want to
move to the first valid session, i.e. executing on ClientSession when really
should be on ServerSession.terminalOnly - return the session we will execute the call on, not
the next step towards it.public AbstractSession getExecutionSession(DatabaseQuery query)
Since the execution session also knows the correct datasource platform to execute on, it is often used in the mappings where the platform is needed for type conversion, or where calls are translated.
Is also the session with the accessor. Will return a ClientSession if it is in transaction and has a write connection.
getExecutionSession in class AbstractSessionquery - may store session name or reference class for brokers casepublic ServerSession getParent()
public DatabaseQuery getQuery(java.lang.String name)
Session.
Return the query from the session pre-defined queries with the given name.
This allows for common queries to be pre-defined, reused and executed by name.getQuery in interface SessiongetQuery in class AbstractSessionpublic DatabaseQuery getQuery(java.lang.String name, java.util.Vector args)
getQuery in interface SessiongetQuery in class AbstractSessionAbstractSession.getQuery(String)public void initializeSequencing()
public Sequencing getSequencing()
getSequencing in class AbstractSessionpublic ServerPlatform getServerPlatform()
getServerPlatform in class AbstractSessionpublic java.lang.String getSessionTypeString()
Override to hide from the user when they are using an internal subclass of a known class.
A user does not need to know that their UnitOfWork is a non-deferred UnitOfWork, or that their ClientSession is an IsolatedClientSession.
getSessionTypeString in class AbstractSessionpublic Accessor getWriteConnection()
protected boolean hasWriteConnection()
public void initializeIdentityMapAccessor()
initializeIdentityMapAccessor in class AbstractSessionpublic boolean isActive()
Session.
Return if the client session is actvie (has not been released).public boolean isClientSession()
isClientSession in interface SessionisClientSession in class AbstractSessionpublic boolean isConnected()
Session.
Return if this session has been connected to the database.isConnected in interface SessionisConnected in class AbstractSessionpublic void release()
throws DatabaseException
Session.
Release the client session.
This releases the client session back to it server.
Normally this will logout of the client session's connection,
and allow the client session to garbage collect.release in interface Sessionrelease in class AbstractSessionDatabaseExceptionprotected void releaseWriteConnection()
protected void setConnectionPolicy(ConnectionPolicy connectionPolicy)
protected void setIsActive(boolean isActive)
protected void setParent(ServerSession parent)
public void setWriteConnection(Accessor writeConnection)
public java.lang.String toString()
toString in class AbstractSession