You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Jochen Hebbrecht <jo...@gmail.com> on 2012/07/02 15:44:33 UTC
Best practise closing Lucene index
Hi all,
I currently have a Seam component which is in my session. This component is
holding (private attribute) a custom "Lucene object" which opens a Lucene
index in the constructor. When I want to search, I use the "Lucene object"
in my session which uses the already opened Lucene index.
So when I want to search on something else, I can still reuse the already
opened index.
But now, I don't have some Java logic which closes the reader. Shouldn't
this be done in some method like the destroy() method (which is called by
te JVM)?
Or is it ok if I don't manually close the reader?
Thanks,
Jochen
Re: Best practise closing Lucene index
Posted by Jochen Hebbrecht <jo...@gmail.com>.
Thanks. We are currently more thinking of a statefull EJB. We are thinking
to use the @Remove annotation ...
2012/7/2 Torsten Krah <tk...@fachschaft.imn.htwk-leipzig.de>
> I you really want a per session based reader, use a
>
>
> http://docs.oracle.com/javaee/5/api/javax/servlet/http/HttpSessionListener.html
>
> and create the object there in sessionCreated and destroy the Reader in
> sessionDestroyed.
> You seam component can get the create objected under a well known name
> you've choosen from the session.
>
> So you won't miss to close the object and won't leak file handles.
>
> regards
>
> Torsten
>
> Am Montag, den 02.07.2012, 15:44 +0200 schrieb Jochen Hebbrecht:
> > Hi all,
> >
> > I currently have a Seam component which is in my session. This component
> is
> > holding (private attribute) a custom "Lucene object" which opens a Lucene
> > index in the constructor. When I want to search, I use the "Lucene
> object"
> > in my session which uses the already opened Lucene index.
> > So when I want to search on something else, I can still reuse the already
> > opened index.
> >
> > But now, I don't have some Java logic which closes the reader. Shouldn't
> > this be done in some method like the destroy() method (which is called by
> > te JVM)?
> > Or is it ok if I don't manually close the reader?
> >
> > Thanks,
> > Jochen
>
>
Re: Best practise closing Lucene index
Posted by Torsten Krah <tk...@fachschaft.imn.htwk-leipzig.de>.
I you really want a per session based reader, use a
http://docs.oracle.com/javaee/5/api/javax/servlet/http/HttpSessionListener.html
and create the object there in sessionCreated and destroy the Reader in
sessionDestroyed.
You seam component can get the create objected under a well known name
you've choosen from the session.
So you won't miss to close the object and won't leak file handles.
regards
Torsten
Am Montag, den 02.07.2012, 15:44 +0200 schrieb Jochen Hebbrecht:
> Hi all,
>
> I currently have a Seam component which is in my session. This component is
> holding (private attribute) a custom "Lucene object" which opens a Lucene
> index in the constructor. When I want to search, I use the "Lucene object"
> in my session which uses the already opened Lucene index.
> So when I want to search on something else, I can still reuse the already
> opened index.
>
> But now, I don't have some Java logic which closes the reader. Shouldn't
> this be done in some method like the destroy() method (which is called by
> te JVM)?
> Or is it ok if I don't manually close the reader?
>
> Thanks,
> Jochen