org.apache.derby.iapi.services.context
Class ContextService
- java.lang.Object
-
- org.apache.derby.iapi.services.context.ContextService
-
public final class ContextService extends java.lang.ObjectA set of static methods to supply easier access to contexts.
-
-
Constructor Summary
Constructors Constructor and Description ContextService()Create a new ContextService for a Derby system.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description static ContextgetContext(java.lang.String contextId)Find the context with the given name in the context service factory loaded for the system.static ContextgetContextOrNull(java.lang.String contextId)Find the context with the given name in the context service factory loaded for the system.ContextManagergetCurrentContextManager()Get current Context Manager linked to the current Thread.static ContextServicegetFactory()ContextManagernewContextManager()It's up to the caller to track this context manager and set it in the context manager list using setCurrentContextManager.voidnotifyAllActiveThreads(Context c)voidresetCurrentContextManager(ContextManager cm)Break the link between the current Thread and the passed in ContextManager.voidsetCurrentContextManager(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 voidstop()So it can be given to us and taken away...
-
-
-
Constructor Detail
-
ContextService
public ContextService()
Create a new ContextService for a Derby system. Only a single system is active at any time.
-
-
Method Detail
-
stop
public static void stop()
So it can be given to us and taken away...
-
getFactory
public static ContextService getFactory()
-
getContext
public static Context getContext(java.lang.String contextId)
Find the context with the given name in the context service factory loaded for the system.- Returns:
- The requested context, null if it doesn't exist.
-
getContextOrNull
public static Context getContextOrNull(java.lang.String contextId)
Find the context with the given name in the context service factory loaded for the system. This version will not do any debug checking, but return null quietly if it runs into any problems.- Returns:
- The requested context, null if it doesn't exist.
-
getCurrentContextManager
public ContextManager getCurrentContextManager()
Get current Context Manager linked to the current Thread. See setCurrentContextManager for details. Note that this call can be expensive and is only intended to be used in "stateless" situations. Ideally code has a reference to the correct ContextManager from another Object, such as a pushed Context.- Returns:
- ContextManager current Context Manager
-
resetCurrentContextManager
public void resetCurrentContextManager(ContextManager cm)
Break the link between the current Thread and the passed in ContextManager. Called in a pair with setCurrentContextManager, see that method for details.
-
setCurrentContextManager
public 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. ContextManagers are tied to a Thread while the thread is executing Derby code. For example on most JDBC method calls the ContextManager backing the Connection object is tied to the current Thread at the start of the method and reset at the end of the method. Once the Thread has completed its Derby work the method resetCurrentContextManager must be called with the same ContextManager to break the link. Note that a subsquent use of the ContextManager may be on a separate Thread, the Thread is only linked to the ContextManager between the setCurrentContextManager and resetCurrentContextManager calls.
ContextService supports nesting of calls by a single Thread, either with the same ContextManager or a different ContextManager.- The same ContextManager would be pushed during a nested JDBC call in a procedure or function.
- A different ContextManager would be pushed during a call on a different embedded JDBC Connection in a procedure or function.
-
newContextManager
public ContextManager newContextManager()
It's up to the caller to track this context manager and set it in the context manager list using setCurrentContextManager. We don't keep track of it due to this call being made.
-
notifyAllActiveThreads
public void notifyAllActiveThreads(Context c)
-
-
DataMelt 3.0 © DataMelt by jWork.ORG