You can use a ContextListener in a servlet engine (like Tomcat) . ContextListener has callback methods for init an destroy. You may open an IndexSearcher in the init and store it in the ServletContext by a name and every servlet can use that. When the app is stopped you get a calllback and you can close the searcher --Noble
On Sun, Nov 9, 2008 at 1:34 AM, Rafael Cunha de Almeida <[EMAIL PROTECTED]> wrote: > On Sat, 8 Nov 2008 10:53:43 +0000 > "Mindaugas Žakšauskas" <[EMAIL PROTECTED]> wrote: > >> > How do I keep only one IndexSearcher open for all the searches on my >> > website? >> >> In order to keep your IndexSearcher open, simply do not close it and >> serve the reference to the same object instance for different HTTP >> request clients. >> >> This can easily be achieved using Singleton wrapper around >> IndexSearcher which would be sitting somewhere in your backend server >> API. >> >> m. > > Yeah, I was worried because all the documentation I read didn't tell me > how to control when the servlet is loaded and when it's unloaded. So I > thought that, since I had no control, maybe the server would reload the > servlet more times than it should. But experimenting with tomcat5.5 > revealed that it's not really common for the servlet to be reloaded. > > I was a bit to worried about the costs of opening more than one > IndexSearcher at the same time and reopening it a few times (I only > reindex stuff once per semester). Now I realise that I was being too > worried about that, you just shouldn't reopen IndexSearcher too often, > but it's completely fine to reopen it every now and then. I was just > being paranoid :-P. > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- --Noble Paul --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]