Thank for your replies. Finally ,I found TapestryFilter has put registry into servlet context,so I do it like this, MyHttpSessionListoner.java
@Override public void sessionDestroyed(HttpSessionEvent se) { //Get Tapestry IoC Registry Registry registry = (Registry) se.getSession().getServletContext().getAttribute(TapestryFilter.REGISTRY_CONTEXT_NAME); ISocialPartyOnlineService socialPartyOnlineService = registry.getService(ISocialPartyOnlineService.class); //Do my session sessionDestroyed logic } 2011/2/23 Kristian Marinkovic <kristian.marinko...@porscheinformatik.at> > 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" <thiag...@gmail.com> > An: "Tapestry users" <users@tapestry.apache.org>, "Kristian > Marinkovic" <kristian.marinko...@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 > <kristian.marinko...@porscheinformatik.at> wrote: > > > we'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-unsubscr...@tapestry.apache.org > For additional commands, e-mail: users-h...@tapestry.apache.org > > >