thank you for the answer and for the sample.
----- Original Message ----- From: "steve rock" <[EMAIL PROTECTED]> To: "MyFaces Discussion" <users@myfaces.apache.org> Sent: Wednesday, June 08, 2005 3:01 PM Subject: Re: initialize a mangaged bean in application scope at applicationstartup Actually you can have multiple application startup listeners, each doing it's own thing. You don't need to override StartupServletContextListener. Just make a new one and implement the functionality that you need. For example I have 2 application scope listeners, and one session scope listener. In my web.xml: <listener> <listener-class>org.apache.myfaces.webapp.StartupServletContextListener</lis tener-class> </listener> <listener> <listener-class>com.m2g.stationtools.web.listeners.StationToolsApplicationLi stener</listener-class> </listener> <listener> <listener-class>com.m2g.stationtools.web.listeners.StationToolsSessionListen er</listener-class> </listener> In StationToolsApplicationListener I load resources like config parameters from the database, and make sure database connections are closed when the application shuts down. In StationToolsSessionListener I load a list of stations from the database and put it in the session that is a JSF referenced-bean. Class: public class StationToolsSessionListener implements HttpSessionListener { private static Log log = LogFactory.getLog(StationToolsSessionListener.class); public void sessionCreated(HttpSessionEvent event) { log.info("sessionCreated(): Starting"); HttpSession session = event.getSession(); session.setAttribute("stationList", new StationList()); log.info("sessionCreated(): Ending"); } public void sessionDestroyed(HttpSessionEvent event) { log.info("sessionDestroyed(): Starting"); DBUtil.closeSessions(); log.info("sessionDestroyed(): Ending"); } } faces-config.xml <faces-config> <referenced-bean> <referenced-bean-name>stationList</referenced-bean-name> <referenced-bean-class>com.m2g.stationtools.web.faces.model.StationList</ref erenced-bean-class> </referenced-bean> ... Cheers, -Steve On 6/8/05, Claudio Tamietto <[EMAIL PROTECTED]> wrote: > > if i undestand your answer i have to subclass the class > org.apache.myfaces.webapp.StartupServletContextListener > and override contextInitialized. Correct ? > > > ----- Original Message ----- > From: Pierpaolo Follia > To: MyFaces Discussion > Sent: Tuesday, June 07, 2005 11:00 AM > Subject: Re: initialize a mangaged bean in application scope at > applicationstartup > > No Claudio, you have to use a Servlet that initialize it (maybe simply > referincing it via FacesContext). > Another solution is to create a new ServletContextListener and use the > contextInitialized() method to initialize your factory. > > bye > > Claudio Tamietto wrote: > > i'm tryng to use jpox and jsf and i have used a managed bean at application > scope for initialize the PersistenceManagerFactory. > This activity is very time consuming and start only when the first user > request reference the bean. is there a way to initialize the bean > at application startup and not at the first reference ? > -- > Pierpaolo Follia >