hi thiage,
you're right HttpSessionActivationListener is another possibility :)
i dont recreate the registry in my HttpSessionListener, i just reuse the
one created by my tapestry listener
My TapestryListener snippet (could be a filter):
public class TapestryListener implements ServletContextListener
{
public static final String REGISTRY_CONTEXT_NAME =
"org.apache.tapestry5.application-registry";
public void contextInitialized(ServletContextEvent sce)
{
// same code as in TapestryFilter
....
registry = appInitializer.createRegistry();
// set registry in context
context.setAttribute(REGISTRY_CONTEXT_NAME, registry);
...
// same code as in TapestryFilter
}
}
My HttpSessionListener:
public final class MyHttpSessionListener implements HttpSessionListener
{
...
public void sessionDestroyed(HttpSessionEvent event)
{
HttpSession httpSession = event.getSession();
...
Registry registry = (Registry)
httpSession.getServletContext().getAttribute(TapestryListener.
REGISTRY_CONTEXT_NAME);
if(registry == null)
throw new RuntimeException("No Tapestry registry
found. Please check that TapestryListener or -Filter is added as
<listener>");
... //do something
}
}
g,
kris
Von: "Thiago H. de Paula Figueiredo" <***@gmail.com>
An: "Tapestry users" <***@tapestry.apache.org>, "Kristian
Marinkovic" <***@porscheinformatik.at>
Datum: 23.02.2011 12:15
Betreff: Re: Hello,Can anyone tell how to use servlet session
Listener with tapestry IoC services ?
On Wed, 23 Feb 2011 06:18:24 -0300, Kristian Marinkovic
Post by Kristian Marinkovicwe've written an own listener (you can create a filter as well) that
starts tapestry. this listener saves the registry in the servlet context
so another serlvet listener can then access it. we use it in a
HttpSessionListener to clear lock if the user session expires.
My approach was to use a RequestFilter to put in the session an object
that implements HttpSessionActivationListener. It will be notified when
the session is created and when its destroyed. No need to create the
Registry manually. :)
--
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br
---------------------------------------------------------------------
To unsubscribe, e-mail: users-***@tapestry.apache.org
For additional commands, e-mail: users-***@tapestry.apache.org