![JAR search and dependency download from the Maven repository](/logo.png)
net.anotheria.anodoc.util.context.ContextManager Maven / Gradle / Ivy
package net.anotheria.anodoc.util.context;
/**
* Context manager manages call contextes. It uses a CallContextFactory to create new contextes.
* Call setFactory prior to anything else.
*
* @author another
* @version $Id: $Id
*/
public class ContextManager {
/**
* The factory for context creation.
*/
private static CallContextFactory factory;
private static ThreadLocal callContext = new ThreadLocal(){
@Override
protected synchronized CallContext initialValue(){
return factory.createContext();
}
};
/**
* Returns the call context for this thread.
*
* @return a {@link net.anotheria.anodoc.util.context.CallContext} object.
*/
public static CallContext getCallContext(){
return callContext.get();
}
/**
* Setter for the field callContext
.
*
* @param value a {@link net.anotheria.anodoc.util.context.CallContext} object.
*/
public static void setCallContext(CallContext value){
callContext.set(value);
}
/**
* Returns the set factory.
*
* @return a {@link net.anotheria.anodoc.util.context.CallContextFactory} object.
*/
public static CallContextFactory getFactory() {
return factory;
}
/**
* Sets the factory.
*
* @param factory a {@link net.anotheria.anodoc.util.context.CallContextFactory} object.
*/
public static void setFactory(CallContextFactory factory) {
ContextManager.factory = factory;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy