|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.derby.iapi.services.context.ContextService
public final class ContextService
A set of static methods to supply easier access to contexts.
Field Summary | |
---|---|
private java.util.HashSet |
allContexts
Collection of all ContextManagers that are open in the complete Derby system. |
private HeaderPrintWriter |
errorStream
|
private static ContextService |
factory
|
private java.lang.ThreadLocal |
threadContextList
Maintains a list of all the contexts that this thread has created and/or used. |
Constructor Summary | |
---|---|
ContextService()
Create a new ContextService for a Derby system. |
Method Summary | |
---|---|
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... |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static ContextService factory
private HeaderPrintWriter errorStream
private java.lang.ThreadLocal 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 allContexts
newContextManager()
,
SystemContext.cleanupOnError(Throwable)
Constructor Detail |
---|
public ContextService()
Method Detail |
---|
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)
|
Built on Thu 2010-12-23 20:49:13+0000, from revision ??? | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |