public interface ContextControl
startContext(Class)
and stopContext(Class)
only affect
the current Thread. When leaving a Thread each started context needs to get
stopped as well (best practice is to do that in a finally block.
If a container supports controlling the Session Context then each Thread will
get a new 'dummy' storage assigned. It is not intended to 'attach' to a real
Session but to allow the re-use of existing beans.
Many containers make heavy use of ThreadLocals. Thus it might be necessary to
call
contextControl.startContext(ApplicationScoped.class);to 'attach' or 'activate' the ApplicationContext within your current Thread.
Modifier and Type | Method and Description |
---|---|
void |
startContext(Class<? extends Annotation> scopeClass)
Start the specified scope.
|
void |
startContexts()
This will start all container built-in Contexts
|
void |
stopContext(Class<? extends Annotation> scopeClass)
Stop the specified scope.
|
void |
stopContexts()
Stop all container built-in Contexts and destroy all beans properly
|
void startContexts()
void stopContexts()
void startContext(Class<? extends Annotation> scopeClass)
scopeClass
- e.g. RequestScoped.classvoid stopContext(Class<? extends Annotation> scopeClass)
scopeClass
- e.g. RequestScoped.classCopyright © 2016 The Apache Software Foundation. All rights reserved.