public final class ContextService
extends java.lang.Object
Modifier and Type | Class | Description |
---|---|---|
private static class |
ContextService.ContextManagerStack |
Specialized stack class that contains context managers.
|
Modifier and Type | Field | Description |
---|---|---|
private java.util.HashSet<ContextManager> |
allContexts |
Collection of all ContextManagers that are open
in the complete Derby system.
|
private HeaderPrintWriter |
errorStream |
|
private static ContextService |
factory |
|
private java.lang.ThreadLocal<java.lang.Object> |
threadContextList |
Maintains a list of all the contexts that this thread has created
and/or used.
|
Constructor | Description |
---|---|
ContextService() |
Create a new ContextService for a Derby system.
|
Modifier and Type | Method | Description |
---|---|---|
private boolean |
addToThreadList(java.lang.Thread me,
ContextManager associateCM) |
The current thread (passed in a me) is setting associateCM
to be its current context manager.
|
static Context |
getContext(java.lang.String contextId) |
Find the context with the given name in the context service factory
loaded for the system.
|
static Context |
getContextOrNull(java.lang.String contextId) |
Find the context with the given name in the context service factory
loaded for the system.
|
ContextManager |
getCurrentContextManager() |
Get current Context Manager linked to the current Thread.
|
static ContextService |
getFactory() |
|
ContextManager |
newContextManager() |
It's up to the caller to track this context manager and set it
in the context manager list using setCurrentContextManager.
|
void |
notifyAllActiveThreads(Context c) |
|
(package private) void |
removeContext(ContextManager cm) |
Remove a ContextManager from the list of all active
contexts managers.
|
void |
resetCurrentContextManager(ContextManager cm) |
Break the link between the current Thread and the passed
in ContextManager.
|
void |
setCurrentContextManager(ContextManager cm) |
Link the current thread to the passed in Contextmanager
so that a subsequent call to getCurrentContextManager by
the current Thread will return cm.
|
static void |
stop() |
So it can be given to us and taken away...
|
private static ContextService factory
private HeaderPrintWriter errorStream
private java.lang.ThreadLocal<java.lang.Object> threadContextList
There are two cases we are trying to optimise.
threadContextList.get() == cm // while in JDBC engine code cm.activeThread == Thread.currentThread(); cm.activeCount = 1;
// thread executing request threadContextList.get() == cm // while in JDBC engine code cm.activeThread == Thread.currentThread(); cm.activeCount = 1; // other threads that have recently executed // the same connection can have threadContextList.get() == cm cm.activeThread != Thread.currentThread();
threadContextList.get() == cm // Within server-side JDBC code in a // function called from another function/procedure // called from an applications's statement // (three levels of nesting) cm.activeThread == Thread.currentThread(); cm.activeCount = 3;
threadContextList.get() == stack {cm2,cm,cm} cm.activeThread == Thread.currentThread(); cm.activeCount = -1; // nesting in stack cm2.activeThread == Thread.currentThread(); cm2.activeCount = -1; // nesting in stack
threadContextList.get() == stack {cm3,cm2,cm,cm2,cm,cm} cm.activeThread == Thread.currentThread(); cm.activeCount = -1; // nesting in stack cm2.activeThread == Thread.currentThread(); cm2.activeCount = -1; // nesting in stack cm3.activeThread == Thread.currentThread(); cm3.activeCount = -1; // nesting in stack
private java.util.HashSet<ContextManager> allContexts
public ContextService()
public static void stop()
public static ContextService getFactory()
public static Context getContext(java.lang.String contextId)
public static Context getContextOrNull(java.lang.String contextId)
public ContextManager getCurrentContextManager()
public void resetCurrentContextManager(ContextManager cm)
private boolean addToThreadList(java.lang.Thread me, ContextManager associateCM)
ContextManager.activeCount
,
ContextManager.activeThread
public void setCurrentContextManager(ContextManager cm)
public ContextManager newContextManager()
public void notifyAllActiveThreads(Context c)
void removeContext(ContextManager cm)
Apache Derby V10.14 Internals - Copyright © 2004,2018 The Apache Software Foundation. All Rights Reserved.