We use singletons all the time,Just be careful that are writer and a reader cannot be opened simultaneously on the same index. Either you write or your read (and delete).
paul Le 15-déc.-08 à 12:06, Zender00 a écrit :
I extend my original post:How is it possible to use lucene in 2 diffent classes / objects, if I dontwant to use static methods/variables? (one object read/writer, the other is read only) Kind regards, D. Penning Zender00 wrote:Hi,I tried to implement a singleton pattern for my already working luceneobject. But there is a strange error when I tried to access the instance.When my Singleton GetInstance() method is executed for the first time itcreates a new instance of my lucene object. There are some member variables in this object like an IndexWriter and IndexReader. Theseobjects are created in the constructor and I can access them directly inthe constructor successfully.GetInstance() now returns this lucene object and I have to execute some operations on it. But the IndexWriter seems to be closed meanwhile and Igot the exception:"org.apache.lucene.store.AlreadyClosed Exception: this IndexWriter isclosed" when my object tries to writer some documents. How could this happen? Isn't it possible to use lucene with a singleton-pattern? Kind regards, D. Penning-- View this message in context: http://www.nabble.com/Singleton-and-Lucene%3A-org.apache.lucene.store.AlreadyClosed-tp20983056p21011945.html Sent from the Lucene - Java Users mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org For additional commands, e-mail: java-user-h...@lucene.apache.org
smime.p7s
Description: S/MIME cryptographic signature