CompilerContext
, DatabaseContext
, ExecutionContext
, LanguageConnectionContext
, StatementContext
ClassFactoryContext
, CompilerContextImpl
, ContextImpl
, DatabaseContextImpl
, EmbedConnectionContext
, GenericExecutionContext
, GenericLanguageConnectionContext
, GenericStatementContext
, RAMTransactionContext
, ServiceBootContext
, StoreClassFactoryContext
, SystemContext
, XactContext
, XATransactionState
public interface Context
A basic context implementation is provided as an abstract class; this implementation satisfies the interface and should in general be used as the supertype of all context types. Otherwise, context classes must satisfy the semantics of the interface through their own distinct implementations.
Contexts assist in cleanup when errors are caught in the outer block.
Use of context cleanup is preferred over using try/catch blocks throughout the code.
Use of context pushing and popping is preferred over using many instance or local variables, even when try/catch is present. when the instance or local variables would be holding resources.
Usually Context's have a reference based equality, ie. they do not provide an implementation of equals(). Contexts may implement a value based equality but this usually means there is only one instance of the Context on the stack, This is because the popContext(Context) will remove the most recently pushed Context that matches via the equals method, not by a reference check. Implementing equals is useful for Contexts used in notifyAllThreads() that is not aimed at a single thread.
Modifier and Type | Method | Description |
---|---|---|
void |
cleanupOnError(java.lang.Throwable error) |
Contexts will be passed errors that are caught
by the outer system when they are serious enough
to require corrective action.
|
ContextManager |
getContextManager() |
Returns the context manager that has stored this
context in its stack.
|
java.lang.String |
getIdName() |
Returns the current id name associated
with this context.
|
boolean |
isLastHandler(int severity) |
Return whether or not this context is the "last" handler for a
the specified severity level.
|
void |
popMe() |
Pop myself of the context stack.
|
void |
pushMe() |
Push myself onto my context stack.
|
ContextManager getContextManager()
java.lang.String getIdName()
A default Id name should be defined in each specific context interface as a static final field with the name CONTEXT_ID. For example, see org.apache.derby.iapi.sql.compile.CompilerContext.CONTEXT_ID.
CompilerContext
void cleanupOnError(java.lang.Throwable error) throws StandardException
Contexts must release all their resources before removing themselves from their context manager.
The context manager will "unwind" the contexts during cleanup in the reverse order they were placed on its global stack.
If error is an instance of StandardException then an implementation of this method may throw a new exception if and only if the new exception is an instance of StandardException that is more severe than the original error or the new exception is a not an instance of StandardException (e.g java.lang.NullPointerException).
StandardException
- thrown if cleanup goes awryvoid pushMe()
void popMe()
boolean isLastHandler(int severity)
Apache Derby V10.14 Internals - Copyright © 2004,2018 The Apache Software Foundation. All Rights Reserved.