How to retrieve all existing long-running conversations in Weld?

我的未来我决定 提交于 2019-12-11 11:26:03

问题


I'm writing application in JBoss 7.1.1.Final, Weld, Seam 3. I have following bean:

@ConversationScoped
public class ConversationBean implements Serializable {

   @Inject
   Conversation conversation;

   private Article article;
...
}

Now, the user might create multiple conversations, each conversation will be associated with the instance of ConversationBean. I need to be able to get all those instances that are associated with long-running conversation.

The reason why I need an access to them is that if a user opens one Article multiple times (thus he will create multiple conversations with the same article). If he changes the Article in one conversation, I want to be able to refresh the Articles in the other conversations.

Is there some standard way to do this?

Edit: "article" instance is looked up by entityManager and is managed within conversation. Entity manager is retrieved using Seam Managed Persistence Context.


回答1:


Per session there's only ever one conversation going on. Injection Conversation will give you the one long-running conversation (or temporary conversation if it hasn't been promoted) going on).




回答2:


I seem to understand you'd like to have a workspace switcher a-la Seam 2. You can do that with Java EE 6 and Weld. Have a look at this article:

http://lucasterdev.altervista.org/wordpress/2012/01/09/workspace-management-with-cdi/




回答3:


see http://docs.jboss.org/weld/reference/latest/en-US/html/contexts.html

@Inject @Http private HttpConversationContext conversationContext;

[...]    

     conversationContext.getConversations()


来源:https://stackoverflow.com/questions/11891035/how-to-retrieve-all-existing-long-running-conversations-in-weld

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!