Thanks Richard, this is truly a bit of magic, one question though regarding the last step:

Is there any reason why I would need to use the ApplicationStateManager object, can I rather access a service directly using getService() ?

For instance, I get the registry like so:
Registry reg = (Registry) event.getSession().getServletContext().getAttribute("org.apache.tapestry.Registry:IRM"); //where IRM is the name of the servlet

and then use something like:
reg.getService(Visit.class);

Thanks again,
Peter

Richard Kirby wrote:
Hi Peter,

One way of doing this is to access the HiveMind Registry object that Tapestry creates, from within your listener class, so that you can then access the ApplicationStateManager, and from that access your ASO.

However, you have to use a little magic to access the Registry object:

1. From the sessionCreated/sessionDestroyed method you have access to the HttpSessionEvent object. 2. From the HttpSessionEvent object you have access to the HttpSession object.
3. From the HttpSession object you have access to the ServletContext
4. From the ServletContext object you can look up the HiveMind Registry using the getAttribute method with the key "org.apache.tapestry.Registry:SERVLET_NAME" where SERVLET_NAME is the name of the Tapestry application servlet you have specified in your web.xml (this is the magic bit since it requires knowing how Tapestry squirrels away the Registry object). 5. You can then get the ApplicationStateManager object from the Registry, and finally your ASO.

Hope that helps

Richard.

Peter Stavrinides wrote:
What is the best approach for the following scenario:

I have a listener class that listens for session activity, its configured only in my web.xml (not for instance in hivemind) I have a state object that I need to inject into the listener class, but since I cannot make the listener class abstract how will I inject my state object? or what can I do otherwise?

Thanks
Peter


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


--
Peter Stavrinides
Albourne Partners (Cyprus) Ltd
Tel: +357 22 750652

If you are not an intended recipient of this e-mail, please notify the sender, delete it and do not read, act upon, print, disclose, copy, retain or redistribute it. Please visit http://www.albourne.com/email.html for important additional terms relating to this e-mail.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to