The first implementation of the context manager assumes there is only one thread to worry about and that the user(s) of the class only create one instance of ContextManager.
| Modifier and Type | Class and Description |
|---|---|
| private static class | ContextManager.
The CtxStack implement a stack on top of an ArrayList (to avoid the inherent overhead associated with java.util.Stack which is built on top of java.util.Vector, which is fully synchronized). |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv int | activeCount
Count of the number of setCurrentContextManager calls by a single thread, for nesting situations with a single active Contextmanager. |
| pack-priv Thread | activeThread
The thread that owns this ContextManager, set by ContextService.setCurrentContextManager and reset by resetCurrentContextManager. |
| private final HashMap | ctxTable
HashMap that holds the Context objects. |
| private HeaderPrintWriter | |
| private ErrorStringBuilder | |
| private int | |
| private LocaleFinder | |
| private final ArrayList | holder
List of all Contexts |
| private int | |
| private Locale | |
| pack-priv final ContextService | |
| private boolean | |
| private String |
| Access | Constructor and Description |
|---|---|
| pack-priv | ContextManager(ContextService
the ContextService owning this ContextManager csf, HeaderPrintWriter error stream for reporting errors stream)Constructs a new instance. |
| Modifier and Type | Method and Description |
|---|---|
| private void | |
| public boolean | Returns: true if the context manager is shutdown, false otherwise.the error we want to clean up error, boolean true if extended diagnostics should be considered,
false not interested of extended diagnostic information diagActive)clean up error and print it to derby.log. |
| private void | flushErrorString()
Flush the built up error string to whereever it is supposed to go, and reset the error string |
| public Context | Returns: The Context object with the corresponding contextId, or null if not founda String identifying the type of Context contextId)Obtain the last pushed Context object of the type indicated by the contextId argument. |
| public final List | Returns: an unmodifiable "view" of the ArrayList backing the stackthe type of Context stack to return. contextId)Return an unmodifiable list reference to the ArrayList backing CtxStack object for this type of Contexts. |
| public int | Returns: int vendorcode/severity for the Throwable error - error/exception to extract vendorcode/severity. For error that we can not get severity, NO_APPLICABLE_SEVERITY will return.- Throwable error error)return the severity of the exception. |
| public Locale | |
| pack-priv final boolean | |
| public void | |
| pack-priv void | |
| public void | |
| private boolean | |
| pack-priv synchronized boolean | |
| public void | |
| public void |
| activeCount | back to summary |
|---|---|
| pack-priv int activeCount Count of the number of setCurrentContextManager calls by a single thread, for nesting situations with a single active Contextmanager. If nesting is occuring with multiple different ContextManagers then this value is set to -1 and nesting is represented by entries in a stack in the ThreadLocal variable, threadContextList.
| |
| activeThread | back to summary |
|---|---|
| pack-priv Thread activeThread The thread that owns this ContextManager, set by
ContextService.setCurrentContextManager and reset
by resetCurrentContextManager. Only a single
thread can be active in a ContextManager at any time,
and the thread only "owns" the ContextManager while
it is executing code within Derby. In the JDBC case
setCurrentContextManager is called at the start of
a JBDC method and resetCurrentContextManager on completion.
Nesting within the same thread is supported, such as server-side
JDBC calls in a Java routine or procedure. In that case
the activeCount will represent the level of nesting, in
some situations.
| |
| ctxTable | back to summary |
|---|---|
| private final HashMap<String, ContextManager. HashMap that holds the Context objects. The Contexts are stored with a String key.
| |
| errorStream | back to summary |
|---|---|
| private HeaderPrintWriter errorStream | |
| errorStringBuilder | back to summary |
|---|---|
| private ErrorStringBuilder errorStringBuilder | |
| extDiagSeverityLevel | back to summary |
|---|---|
| private int extDiagSeverityLevel | |
| finder | back to summary |
|---|---|
| private LocaleFinder finder | |
| holder | back to summary |
|---|---|
| private final ArrayList<Context> holder List of all Contexts | |
| logSeverityLevel | back to summary |
|---|---|
| private int logSeverityLevel | |
| messageLocale | back to summary |
|---|---|
| private Locale messageLocale | |
| owningCsf | back to summary |
|---|---|
| pack-priv final ContextService owningCsf | |
| shutdown | back to summary |
|---|---|
| private boolean shutdown | |
| threadDump | back to summary |
|---|---|
| private String threadDump | |
| ContextManager | back to summary |
|---|---|
| pack-priv ContextManager(ContextService csf, HeaderPrintWriter stream) Constructs a new instance. No CtxStacks are inserted into the hashMap as they will be allocated on demand.
| |
| checkInterrupt | back to summary |
|---|---|
| private void checkInterrupt() Check to see if we have been interrupted. If we have then a ShutdownException will be thrown. This will be either the one passed to interrupt or a generic one if some outside source interrupted the thread. | |
| cleanupOnError | back to summary |
|---|---|
| public boolean cleanupOnError(Throwable error, boolean diagActive) clean up error and print it to derby.log. Extended diagnosis including thread dump to derby.log and javaDump if available, will print if the database is active and severity is greater than or equals to SESSTION_SEVERITY or as configured by derby.stream.error.extendedDiagSeverityLevel property
| |
| flushErrorString | back to summary |
|---|---|
| private void flushErrorString() Flush the built up error string to whereever it is supposed to go, and reset the error string | |
| getContext | back to summary |
|---|---|
| public Context getContext(String contextId) Obtain the last pushed Context object of the type indicated by the contextId argument. | |
| getContextStack | back to summary |
|---|---|
| public final List Return an unmodifiable list reference to the ArrayList backing CtxStack object for this type of Contexts. This method allows fast traversal of all Contexts on that stack. The first element in the List corresponds to the bottom of the stack. The assumption is that the Stack will not be modified while it is being traversed.
| |
| getErrorSeverity | back to summary |
|---|---|
| public int getErrorSeverity(Throwable error) return the severity of the exception. Currently, this method does not determine a severity that is not StandardException or SQLException.
| |
| getMessageLocale | back to summary |
|---|---|
| public Locale getMessageLocale() | |
| isEmpty | back to summary |
|---|---|
| pack-priv final boolean isEmpty() Is the ContextManager empty containing no Contexts. | |
| popContext | back to summary |
|---|---|
| public void popContext() Remove the last pushed Context object, regardless of type. If there are no Context objects, no action is taken. | |
| popContext | back to summary |
|---|---|
| pack-priv void popContext(Context theContext) Removes the specified Context object. If the specified Context object does not exist, the call will fail.
| |
| pushContext | back to summary |
|---|---|
| public void pushContext(Context newContext) Add a Context object to the ContextManager. The object is added both to the holder list and to a stack for the specific type of Context.
| |
| reportError | back to summary |
|---|---|
| private boolean reportError(Throwable t) | |
| setInterrupted | back to summary |
|---|---|
| pack-priv synchronized boolean setInterrupted(Context c) | |
| setLocaleFinder | back to summary |
|---|---|
| public void setLocaleFinder(LocaleFinder finder) Set the locale for this context.
| |
| setMessageLocale | back to summary |
|---|---|
| public void setMessageLocale(String localeID) throws StandardException | |
| Modifier and Type | Field and Description |
|---|---|
| private final ArrayList | stack_
Internal list with all the elements of the stack. |
| private Context | |
| private final List | view_
Read-only view of the internal list. |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv List | |
| pack-priv boolean | |
| pack-priv void | |
| pack-priv void | |
| pack-priv void | |
| pack-priv Context |
| stack_ | back to summary |
|---|---|
| private final ArrayList<Context> stack_ Internal list with all the elements of the stack. | |
| top_ | back to summary |
|---|---|
| private Context top_ | |
| view_ | back to summary |
|---|---|
| private final List<Context> view_ Read-only view of the internal list. | |
| CtxStack | back to summary |
|---|---|
| private CtxStack() | |
| getUnmodifiableList | back to summary |
|---|---|
| pack-priv List | |
| isEmpty | back to summary |
|---|---|
| pack-priv boolean isEmpty() | |
| pop | back to summary |
|---|---|
| pack-priv void pop() | |
| push | back to summary |
|---|---|
| pack-priv void push(Context context) | |
| remove | back to summary |
|---|---|
| pack-priv void remove(Context context) | |
| top | back to summary |
|---|---|
| pack-priv Context top() | |