EclipseLink 1.0_1.0M2 API Reference - Incubation

org.eclipse.persistence.sessions.server
Class ClientSession

java.lang.Object
  extended by AbstractSession
      extended by org.eclipse.persistence.sessions.server.ClientSession

public class ClientSession
extends AbstractSession

Purpose: Acts as a client to the server session.

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.

See Also:
Server, UnitOfWork

Field Summary
protected  ConnectionPolicy connectionPolicy
           
protected  boolean isActive
           
protected  ServerSession parent
           
protected  Sequencing sequencing
           
protected  Accessor writeConnection
           
 
Constructor Summary
protected ClientSession(Project project)
           
  ClientSession(ServerSession parent, ConnectionPolicy connectionPolicy)
          INTERNAL: Create and return a new client session.
 
Method Summary
 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(AbstractSession callingSession)
          INTERNAL: This is internal to the unit of work and should not be called otherwise.
 void basicRollbackTransaction(AbstractSession callingSession)
          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).
 Accessor getAccessor()
          INTERNAL: Return the read or write connection depending on the transaction state.
 CacheSynchronizationManager getCacheSynchronizationManager()
          INTERNAL: Was PUBLIC: customer will be redirected to Session.
 CommandManager getCommandManager()
          INTERNAL: Return the manager that allows this processor to receive or propagate commands from/to TopLink cluster
 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.
 java.lang.Object getProperty(java.lang.String name)
          Search for and return the user defined property from this client session, if it not found then search for the property from parent.
 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.
 boolean hasCacheSynchronizationManager()
          INTERNAL: Was PUBLIC: customer will be redirected to Session.
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.
 void releaseReadConnection(Accessor connection)
          INTERNAL:
protected  void releaseWriteConnection()
          INTERNAL: This is internal to the unit of work and should not be called otherwise.
 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.
 boolean shouldPropagateChanges()
          INTERNAL: Return whether changes should be propagated to TopLink cluster.
 java.lang.String toString()
          INTERNAL: Print the connection status with the session.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

parent

protected ServerSession parent

connectionPolicy

protected ConnectionPolicy connectionPolicy

writeConnection

protected Accessor writeConnection

isActive

protected boolean isActive

sequencing

protected Sequencing sequencing
Constructor Detail

ClientSession

public ClientSession(ServerSession parent,
                     ConnectionPolicy connectionPolicy)
INTERNAL: Create and return a new client session.


ClientSession

protected ClientSession(Project project)
Method Detail

afterTransaction

public void afterTransaction(boolean committed,
                             boolean isExternalTransaction)
INTERNAL: Called after transaction is completed (committed or rolled back)


basicBeginTransaction

public void basicBeginTransaction()
INTERNAL: This is internal to the unit of work and should never be called otherwise.


basicCommitTransaction

public void basicCommitTransaction(AbstractSession callingSession)
INTERNAL: This is internal to the unit of work and should not be called otherwise.


basicRollbackTransaction

public void basicRollbackTransaction(AbstractSession callingSession)
INTERNAL: This is internal to the unit of work and should not be called otherwise. The calling session is the session that requires rollback transaction.


connect

public void connect()
             throws DatabaseException
INTERNAL: Connect the session only (this must be the write connection as the read is shared).

Throws:
DatabaseException

containsQuery

public boolean containsQuery(java.lang.String queryName)
INTERNAL: Was PUBLIC: customer will be redirected to Session. Return true if the pre-defined query is defined on the session.


disconnect

public void disconnect()
                throws DatabaseException
INTERNAL: Disconnect the accessor only (this must be the write connection as the read is shared).

Throws:
DatabaseException

getAccessor

public Accessor getAccessor()
INTERNAL: Return the read or write connection depending on the transaction state.


getCacheSynchronizationManager

public CacheSynchronizationManager getCacheSynchronizationManager()
INTERNAL: Was PUBLIC: customer will be redirected to Session. Returns the Synchronization Policy for this session.


getConnectionPolicy

public ConnectionPolicy getConnectionPolicy()
ADVANCED: This method will return the connection policy that was used during the acquisition of this client session. The properties within the ConnectionPolicy may be used when acquiring an exclusive connection for an IsolatedSession.


getDescriptors

public java.util.Map getDescriptors()
INTERNAL: Was PUBLIC: customer will be redirected to Session. Return all registered descriptors. The clients session inherits its parent's descriptors.


getParentIdentityMapSession

public 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.

Used for session broker which delegates to registered sessions, or UnitOfWork which checks parent identity map also.

Parameters:
canReturnSelf - 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.
Returns:
this if there is no next link in the chain

getProperty

public java.lang.Object getProperty(java.lang.String name)
Search for and return the user defined property from this client session, if it not found then search for the property from parent.


getExecutionSession

public AbstractSession getExecutionSession(DatabaseQuery query)
INTERNAL: Gets the session which this query will be executed on. Generally will be called immediately before the call is translated, which is immediately before session.executeCall.

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.

Parameters:
query - may store session name or reference class for brokers case
Returns:
a session with a live accessor

getParent

public ServerSession getParent()
INTERNAL: Return the parent. This is a server session.


getQuery

public DatabaseQuery getQuery(java.lang.String name)
INTERNAL: Was PUBLIC: customer will be redirected to 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

public DatabaseQuery getQuery(java.lang.String name,
                              java.util.Vector args)
INTERNAL:


initializeSequencing

public void initializeSequencing()
INTERNAL: was ADVANCED: Creates sequencing object for the session. Typically there is no need for the user to call this method - it is called from the constructor.


getSequencing

public Sequencing getSequencing()
INTERNAL: Return the Sequencing object used by the session. Lazy init sequencing to defer from client session creation to improve creation performance.


getServerPlatform

public 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)


getSessionTypeString

public java.lang.String getSessionTypeString()
INTERNAL: Returns the type of session, its class.

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.


getWriteConnection

public Accessor getWriteConnection()
INTERNAL: Return the connection to be used for database modification.


hasCacheSynchronizationManager

public boolean hasCacheSynchronizationManager()
INTERNAL: Was PUBLIC: customer will be redirected to Session. Return true if a cache synchronisation manager exists.


hasWriteConnection

protected boolean hasWriteConnection()
INTERNAL: Return if this session has been connected.


initializeIdentityMapAccessor

public void initializeIdentityMapAccessor()
INTERNAL: Set up the IdentityMapManager. This method allows subclasses of Session to override the default IdentityMapManager functionality.


isActive

public boolean isActive()
INTERNAL: Was PUBLIC: customer will be redirected to Session. Return if the client session is actvie (has not been released).


isClientSession

public boolean isClientSession()
INTERNAL: Return if this session is a client session.


isConnected

public boolean isConnected()
INTERNAL: Was PUBLIC: customer will be redirected to Session. Return if this session has been connected to the database.


release

public void release()
             throws DatabaseException
INTERNAL: Was PUBLIC: customer will be redirected to 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.

Throws:
DatabaseException

releaseWriteConnection

protected void releaseWriteConnection()
INTERNAL: This is internal to the unit of work and should not be called otherwise.


setConnectionPolicy

public void setConnectionPolicy(ConnectionPolicy connectionPolicy)
INTERNAL: Set the connection policy.


setIsActive

protected void setIsActive(boolean isActive)
INTERNAL: Set if the client session is actvie (has not been released).


setParent

protected void setParent(ServerSession parent)
INTERNAL: Set the parent. This is a server session.


setWriteConnection

public void setWriteConnection(Accessor writeConnection)
INTERNAL: Set the connection to be used for database modification.


toString

public java.lang.String toString()
INTERNAL: Print the connection status with the session.


getCommandManager

public CommandManager getCommandManager()
INTERNAL: Return the manager that allows this processor to receive or propagate commands from/to TopLink cluster

Returns:
a remote command manager
See Also:
#CommandManager

shouldPropagateChanges

public boolean shouldPropagateChanges()
INTERNAL: Return whether changes should be propagated to TopLink cluster. This is one of the required cache synchronization setting


releaseReadConnection

public void releaseReadConnection(Accessor connection)
INTERNAL:


EclipseLink 1.0_1.0M2 API Reference - Incubation