I would like to know if the context is included RequestScopedin the method or not.
Right now I'm doing this:
@Inject private BeanManager beanManager;
public boolean isRequestScopeActive() {
try {
if (beanManager.getContext(RequestScoped.class).isActive()) {
return true;
} else {
return false;
}
} catch (final ContextNotActiveException e) {
return false;
}
}
It seems to me that itβs a little hard to catch ContextNotActiveExceptionto find out if the area is active or not.
Do you have a better way to find out the state (active or not) of a context in CDI?
source
share