Class CallContext

java.lang.Object
ru.curs.celesta.CallContext
All Implemented Interfaces:
AutoCloseable, ICallContext
Direct Known Subclasses:
SystemCallContext

public class CallContext extends Object implements ICallContext
Call context containing a DB connection carrying a transaction and a user identifier.
  • Field Details

    • MAX_DATA_ACCESSORS

      public static final int MAX_DATA_ACCESSORS
      Maximal number of accessors that can be opened within single context.
      See Also:
  • Constructor Details

    • CallContext

      public CallContext(String userId)
      Creates new not activated context.
      Parameters:
      userId - User identifier. Cannot be null or empty.
    • CallContext

      public CallContext(String userId, ICelesta celesta, String procName)
      Creates activated context.
      Parameters:
      userId - User identifier. Cannot be null or empty.
      celesta - Celesta instance.
      procName - Procedure which is being called in this context.
  • Method Details

    • activate

      public void activate(ICelesta celesta, String procName)
      Activates CallContext with 'live' Celesta and procName.
      Parameters:
      celesta - Celesta to use CallContext with.
      procName - Name of the called procedure (for logging/audit needs).
    • getConn

      public Connection getConn()
      Returns active database JDBC connection.
      Specified by:
      getConn in interface ICallContext
      Returns:
    • getUserId

      public String getUserId()
      Returns name of the current user.
      Returns:
    • commit

      public void commit()
      Commits the current transaction. Will cause error for not-activated or closed context.

      Wraps SQLException into CelestaException.

    • rollback

      public void rollback()
      Rollbacks the current transaction. Does nothing for not-activated context.

      Wraps SQLException into CelestaException.

    • getCelesta

      public ICelesta getCelesta()
      Returns Celesta instance.
      Returns:
      null for not activated context
    • getScore

      public Score getScore()
      Returns score of current Celesta instance.
      Specified by:
      getScore in interface ICallContext
      Returns:
    • setLastDataAccessor

      public void setLastDataAccessor(BasicDataAccessor dataAccessor)
      Set the last data accessor object.
      Parameters:
      dataAccessor - data accessor object
    • incDataAccessorsCount

      public void incDataAccessorsCount()
      Increments counter of open data accessor objects.
      Throws:
      CelestaException - if the maximal limit of data accessors is exceeded.
    • decDataAccessorsCount

      public void decDataAccessorsCount()
      Decrements counter of open data accessor objects.
    • getLastDataAccessor

      public BasicDataAccessor getLastDataAccessor()
      Returns the last data accessor object.
      Returns:
    • getDBPid

      public int getDBPid()
      Returns Process Id of current connection to the database.
      Returns:
    • getProcName

      public String getProcName()
      Returns procedure name that was initially called.
      Returns:
    • getStartTime

      public Date getStartTime()
      Returns the calendar date of CallContext activation.
      Returns:
    • getDurationNs

      public long getDurationNs()
      Returns number of nanoseconds since CallContext activation.
      Returns:
    • isClosed

      public boolean isClosed()
      If this context is closed.
      Specified by:
      isClosed in interface ICallContext
      Returns:
    • getPermissionManager

      public IPermissionManager getPermissionManager()
      Returns a IPermissionManager of current Celesta instance.
      Returns:
    • getLoggingManager

      public ILoggingManager getLoggingManager()
      Returns a ILoggingManager of current Celesta instance.
      Returns:
    • getDbAdaptor

      public DBAdaptor getDbAdaptor()
      Returns a DBAdaptor of current Celesta instance.
      Specified by:
      getDbAdaptor in interface ICallContext
      Returns:
    • close

      public final void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface ICallContext
    • getCopy

      public CallContext getCopy()
      Duplicates callcontext with another JDBC connection.
      Returns: