Package ru.curs.celesta
Class CallContext
java.lang.Object
ru.curs.celesta.CallContext
- All Implemented Interfaces:
AutoCloseable,ICallContext
- Direct Known Subclasses:
SystemCallContext
Call context containing a DB connection carrying a transaction and a user identifier.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intMaximal number of accessors that can be opened within single context. -
Constructor Summary
ConstructorsConstructorDescriptionCallContext(String userId) Creates new not activated context.CallContext(String userId, ICelesta celesta, String procName) Creates activated context. -
Method Summary
Modifier and TypeMethodDescriptionvoidActivates CallContext with 'live' Celesta and procName.final voidclose()voidcommit()Commits the current transaction.voidDecrements counter of open data accessor objects.Returns Celesta instance.getConn()Returns active database JDBC connection.getCopy()Duplicates callcontext with another JDBC connection.Returns aDBAdaptorof current Celesta instance.intgetDBPid()Returns Process Id of current connection to the database.longReturns number of nanoseconds since CallContext activation.Returns the last data accessor object.Returns aILoggingManagerof current Celesta instance.Returns aIPermissionManagerof current Celesta instance.Returns procedure name that was initially called.getScore()Returns score of current Celesta instance.Returns the calendar date of CallContext activation.Returns name of the current user.voidIncrements counter of open data accessor objects.booleanisClosed()If this context is closed.voidrollback()Rollbacks the current transaction.voidsetLastDataAccessor(BasicDataAccessor dataAccessor) Set the last data accessor object.
-
Field Details
-
MAX_DATA_ACCESSORS
public static final int MAX_DATA_ACCESSORSMaximal number of accessors that can be opened within single context.- See Also:
-
-
Constructor Details
-
CallContext
Creates new not activated context.- Parameters:
userId- User identifier. Cannot be null or empty.
-
CallContext
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
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
Returns active database JDBC connection.- Specified by:
getConnin interfaceICallContext- Returns:
-
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
Returns Celesta instance.- Returns:
nullfor not activated context
-
getScore
Returns score of current Celesta instance.- Specified by:
getScorein interfaceICallContext- Returns:
-
setLastDataAccessor
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
Returns the last data accessor object.- Returns:
-
getDBPid
public int getDBPid()Returns Process Id of current connection to the database.- Returns:
-
getProcName
Returns procedure name that was initially called.- Returns:
-
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:
isClosedin interfaceICallContext- Returns:
-
getPermissionManager
Returns aIPermissionManagerof current Celesta instance.- Returns:
-
getLoggingManager
Returns aILoggingManagerof current Celesta instance.- Returns:
-
getDbAdaptor
Returns aDBAdaptorof current Celesta instance.- Specified by:
getDbAdaptorin interfaceICallContext- Returns:
-
close
public final void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceICallContext
-
getCopy
Duplicates callcontext with another JDBC connection.- Returns:
-