* {@inheritDoc}
*/
@Override
protected ConversationImpl newInstance(CreationalContextImpl<ConversationImpl> creationalContext)
{
ConversationImpl conversation = null;
//Gets conversation service
ConversationService conversationService = webBeansContext.getService(ConversationService.class);
//Gets conversation id
String conversationId = conversationService.getConversationId();
//Gets session id that conversation is created
String sessionId = conversationService.getConversationSessionId();
//If conversation id is not null, this means that
//conversation is propogated
if (conversationId != null)
{
//Gets propogated conversation
conversation = webBeansContext.getConversationManager().getPropogatedConversation(conversationId, sessionId);
}
if (conversation == null)
{
if(sessionId != null)
{
conversation = new ConversationImpl(conversationService.getConversationSessionId(), webBeansContext);
}
else
{
//Used in Tests
conversation = new ConversationImpl(webBeansContext);
}
}
return conversation;