-
1. Re: Events from ContextualHttpServletRequest
pmuir Mar 14, 2008 10:20 AM (in response to nickarls)Should work, post your code.
Can you debug through the Seam source to see what is going on?
-
2. Re: Events from ContextualHttpServletRequest
nickarls Mar 14, 2008 11:11 AM (in response to nickarls)protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { new ContextualHttpServletRequest(request) { public void process() throws Exception { String msg = ServletContexts.getInstance().getRequest().getParameter("msg"); Events.instance().raiseEvent("incoming_message", msg); } }.run(); }
I'm trying to send messages through the servlet. The listener is an ICEFaces onDemandRenderer that pushes popups to the clients
I'll try hooking up the source if you can't see any obvious errors...
-
3. Re: Events from ContextualHttpServletRequest
nickarls Mar 14, 2008 11:17 AM (in response to nickarls)No, wait. There is something fishy here. If they would be global then apps that use events for execution flow would get all messed up. But e.g. seam postInitialize is global? Confused...
-
4. Re: Events from ContextualHttpServletRequest
nickarls Mar 14, 2008 11:38 AM (in response to nickarls)Aah. OK. If the observer is in application scope it works fine.
Now the problem remains of distributing the event to the clients.
Are there any constructs for this or do I just have to do an own observer pattern for the clients against the application scoped component?
-
5. Re: Events from ContextualHttpServletRequest
nickarls Mar 14, 2008 12:10 PM (in response to nickarls)But if I make a
public interface MessageListener { public void message(String message); }
and add a data structure and subscribe/unsubscribe functionality to the application scoped event listener I get NPE:s in my beans when doing
for (MessageListener listener : listeners) { listener.message(message); }
since there is no injection available (the beans are not the same as when registering).
Any clues as how to do this kind of messaging?
-
6. Re: Events from ContextualHttpServletRequest
pmuir Mar 14, 2008 12:26 PM (in response to nickarls)The event is called within the context of the raising action (so event, then conversation etc.) - so I would think if the servlet is participating in the session and conversation it should be able to observe there as well. If not, I think it is probably a bug.
-
7. Re: Events from ContextualHttpServletRequest
nickarls Mar 14, 2008 12:44 PM (in response to nickarls)The servlet is called from outside the application so I don't think it is participating in anything.
I can live with the event being observed with the application scoped component. Now the problem (mentioned in the post above) is the observer pattern not working since the seam managed beans that I register are half the bean they used to be when called again (no injected stuff)
-
8. Re: Events from ContextualHttpServletRequest
nickarls Mar 14, 2008 1:28 PM (in response to nickarls)The problem is apparently that since the event originates from the application scope, the beans don't get their original state restored that they had in their own conversations when they were injected.
If I pass along their conversation ID:s when registering the listeners, is it possible to simulate their conversation, sort of
for (MessageListener listener : listeners) { Conversation.instance().setId(listenerConversationId) listener.message(message); }
-
9. Re: Events from ContextualHttpServletRequest
nickarls Mar 14, 2008 2:00 PM (in response to nickarls)Apparently ConversationEntries.getInstance().getConversationEntry(assumeIdentity).select(); doen't do the trick, either...
-
10. Re: Events from ContextualHttpServletRequest
nickarls Mar 14, 2008 2:27 PM (in response to nickarls)An no luck on Manager.instance().setCurrentConversationId(...) either...
-
11. Re: Events from ContextualHttpServletRequest
pmuir Mar 14, 2008 5:48 PM (in response to nickarls)Try
Manager.instance().switchConversation(id);
-
12. Re: Events from ContextualHttpServletRequest
nickarls Mar 15, 2008 12:41 PM (in response to nickarls)Ngh. No go. Not allowed across session for security reasons, I guess?
-
13. Re: Events from ContextualHttpServletRequest
pmuir Mar 15, 2008 6:02 PM (in response to nickarls)Yes, conversations are stored in the session, so you must be in the same session.
There is an open JIRA for making the context stores pluggable, but this isn't implemented currently.
-
14. Re: Events from ContextualHttpServletRequest
nickarls Mar 17, 2008 8:23 AM (in response to nickarls)I would love to have some sort of Events.getInstace().raiseGlobalEvent(
user_logged_on
). Would it overlap with the existing JIRA?What would be the remaining options? JMS? I'm on WAR so it pretty much rules out MDBs. A thread polling the application scoped component?