* When create is false, null is returned if no instance yet
* exists for the current user session.
*/
public static ConversationManager getInstance(boolean create)
{
FrameworkAdapter frameworkAdapter = FrameworkAdapter.getCurrentInstance();
if (frameworkAdapter == null)
{
if (!create)
{
// if we should not created one, it doesn't matter if there is no
// FrameworkAdapter available.
return null;
}
else
{
throw new IllegalStateException("FrameworkAdapter not found");
}
}
ConversationManager conversationManager = (ConversationManager) frameworkAdapter.getSessionAttribute(
CONVERSATION_MANAGER_KEY);
if (conversationManager == null && create)
{
// TODO: do not call new directly here, as it makes it impossible to configure
// an alternative ConversationManager instance. This is IOC and test unfriendly.