-
1. Re: Weld conversation timeout listener
jmolly Aug 28, 2013 11:36 AM (in response to zpgutterman)Hi Zach
Did you find a solution for this?
I would like to handle this without waiting for user input (that causes a NonexistenConversationException)
Does anybody have a clue about this?
Regards
-
2. Re: Weld conversation timeout listener
luksa Aug 28, 2013 2:42 PM (in response to jmolly)CDI 1.1 does fire an event. See section of 6.7.4 of the CDI 1.1 spec: Contexts and Dependency Injection for the Java EE platform
-
3. Re: Re: Weld conversation timeout listener
jmolly Aug 29, 2013 7:26 AM (in response to luksa)Hi Marko
Thanks for the feedback
I have updated my glassfish 3.1.2 weld-osgi-bundle.jar to to 2.0.0 version (first version implementing CDI 1.1 I guess)
I'm now able to see @Destroyed and @Initialized annotations inside javax.enterprise.context, but saddly I can't make it work
I tried several method definitions as according to documentation ServletRequest, ConversationID and event Object can be used as payload.
public void conversationStarted(@Observes @Initialized(ConversationScoped.class) ServletRequest request){
log.info("Conversation initialized");
}
public void conversationStarted(@Observes @Initialized(ConversationScoped.class) String conversationId){
log.info("Conversation initialized");
}
public void conversationStarted(@Observes @Initialized(ConversationScoped.class) ServletRequest request){
log.info("Conversation initialized");
}
Sadly none of these work. Can you help me?
Thanks in advance
-
4. Re: Re: Re: Weld conversation timeout listener
jmolly Aug 29, 2013 9:53 AM (in response to jmolly)I've upgraded to Glassfish v4 and finally got it working, what is strange to me as it has bundled WELD 2.0.0 so maybe more jars need to be updated to work with CD1.1 in Glassfish 3.1.2?
Saddly it seems that the event it's triggered after user interaction so it's useless for my purposes.
I expected this to be triggered asynchronously so I can redirect to welcome screen for next user but how I said it's only fired after user interacts with the page. Is this the expected behavior or Am i missing something here?
For those facing same problem next methods worked for me.
public void conversationStarted(@Observes @Initialized(ConversationScoped.class) ServletRequest request){
log.info("Conversation initialized");
}
public void conversationStarted(@Observes @Destroyed(ConversationScoped.class) ServletRequest request){
String conversationId = request.getParameter("cid");
if (conversationId != null){
log.info("Long running conversation finished: "+conversationId);
}
}
Regards