View Javadoc

1   package com.atlassian.bonnie.index;
2   
3   import com.atlassian.bonnie.LuceneConnection;
4   import com.atlassian.core.util.ProgressWrapper;
5   import org.apache.lucene.document.Document;
6   import org.apache.lucene.index.IndexWriter;
7   
8   import java.io.IOException;
9   
10  /**
11   * DocumentWritingScheme to write a single object to index.
12   */
13  class SingleDocumentWritingScheme extends BaseDocumentWritingScheme
14  {
15      private LuceneConnection conn;
16  
17      public SingleDocumentWritingScheme(LuceneConnection conn)
18      {
19          this.conn = conn;
20      }
21  
22      public void write(final Document doc)
23      {
24          conn.withWriter(new LuceneConnection.WriterAction()
25          {
26              public void perform(IndexWriter writer) throws IOException
27              {
28                  writer.addDocument(doc);
29              }
30          }, LuceneConnection.WRITER_INTERACTIVE);
31      }
32  
33      public void runComplete()
34      {
35  
36      }
37  
38      public void close(LuceneConnection conn) throws IOException
39      {
40          conn.close();
41      }
42  }