public Object write(WriterCallback callback) {
   LuceneIndexWriter writer = IndexWriterFactoryUtils.getIndexWriter(indexFactory);
   try {
     return callback.doWithWriter(writer);
   } catch (Exception ex) {
     throw new LuceneIndexAccessException("Error during using the IndexWriter.", ex);
   } finally {
     IndexWriterFactoryUtils.releaseIndexWriter(indexFactory, writer);
   }
 }
 public void optimize() {
   LuceneIndexWriter writer = IndexWriterFactoryUtils.getIndexWriter(indexFactory);
   try {
     writer.optimize();
   } catch (IOException ex) {
     throw new LuceneIndexAccessException("Error during optimize the index.", ex);
   } finally {
     IndexWriterFactoryUtils.releaseIndexWriter(indexFactory, writer);
   }
 }
 public void addIndexes(Directory[] directories) {
   LuceneIndexWriter writer = IndexWriterFactoryUtils.getIndexWriter(indexFactory);
   try {
     writer.addIndexes(directories);
   } catch (IOException ex) {
     throw new LuceneIndexAccessException("Error during adding indexes.", ex);
   } finally {
     IndexWriterFactoryUtils.releaseIndexWriter(indexFactory, writer);
   }
 }
 public void addDocument(Document document, Analyzer analyzer) {
   LuceneIndexWriter writer = IndexWriterFactoryUtils.getIndexWriter(indexFactory);
   try {
     doAddDocument(writer, document, null);
   } catch (IOException ex) {
     throw new LuceneIndexAccessException("Error during adding a document.", ex);
   } finally {
     IndexWriterFactoryUtils.releaseIndexWriter(indexFactory, writer);
   }
 }
 public void addDocuments(List documents, Analyzer analyzer) {
   LuceneIndexWriter writer = IndexWriterFactoryUtils.getIndexWriter(indexFactory);
   try {
     for (Iterator i = documents.iterator(); i.hasNext(); ) {
       Document document = (Document) i.next();
       doAddDocument(writer, document, analyzer);
     }
   } catch (IOException ex) {
     throw new LuceneIndexAccessException("Error during adding a document.", ex);
   } finally {
     IndexWriterFactoryUtils.releaseIndexWriter(indexFactory, writer);
   }
 }