// Note that if the request being processed includes any code that uses FacesContext.responseWriter
// then that invokes the ConversationRequestParameterProvider. And that always writes out a contextId
// which in turn requires creating a ConversationManager. But there are value requests that run the
//
// Note that ConversationManager.getInstance requires the FrameworkAdapter to be initialized.
ConversationManager manager = ConversationManager.getInstance(false);
if (manager != null)
{
// Fetch a context for this request if one already exists, and lock it
// so that concurrent requests that affect this context block until
// this request is complete. Not doing so can cause races for resources
// within the current context, such as beans or PersistenceContexts.
//
// But if the request did not explicitly specify a contextId then we
// do NOT create a new context at this point. Doing so would create
// contexts for things like Weblet resource requests, and that context
// would then just hang around unused until it times out!
//
// Note that a request that does not explicitly specify a contextId
// might have one created for it later in the request, eg when an
// orchestra-scoped bean is accessed. However this is not a race
// condition because nothing else can refer to that newly created
// id until the response for this request has been sent back to the
// client browser.
context = manager.getCurrentRootConversationContext();
if (context != null)
{
try
{
if (log.isDebugEnabled())