View Javadoc

1   package com.atlassian.bonnie;
2   
3   import org.apache.lucene.analysis.Analyzer;
4   import org.apache.lucene.store.Directory;
5   
6   import java.io.File;
7   
8   /**
9    * Allow us to control the concrete class that clients use. Currently the {@link ConcurrentLuceneConnection} is in vogue.
10   * @deprecated since 3.2, use a constructor of {@link LuceneConnection}
11   */
12  public class LuceneConnectionFactory
13  {
14      private static final LuceneConnectionFactory FACTORY = new LuceneConnectionFactory();
15  
16      public static LuceneConnectionFactory get()
17      {
18          return FACTORY;
19      }
20  
21      /**
22       * Return an instance of {@link ILuceneConnection} every time.
23       *
24       * @throws LuceneException if the path does not exist. 
25       */
26      public ILuceneConnection createLuceneConnection(String path, Analyzer analyzer, ILuceneConnection.Configuration configuration)
27      {
28          return new LuceneConnection(new File(path), analyzer, configuration);
29      }
30  
31      /**
32       * Return an instance of {@link ILuceneConnection} every time.
33       *
34       * @throws LuceneException if the path does not exist.
35       */
36      public ILuceneConnection createLuceneConnection(Directory directory, Analyzer analyzer, ILuceneConnection.Configuration configuration)
37      {
38          return new LuceneConnection(directory, analyzer, configuration);
39      }
40  
41      /**
42       * Return an instance of {@link ILuceneConnection} every time.
43       *
44       * @throws LuceneException if the path does not exist. 
45       */
46      public ILuceneConnection createLuceneConnection(String path, Analyzer analyzer)
47      {
48          return createLuceneConnection(path, analyzer, ILuceneConnection.DEFAULT_CONFIGURATION);
49      }
50  
51      /**
52       * Return an instance of {@link ILuceneConnection} every time.
53       *
54       * @throws LuceneException if the path does not exist.
55       */
56      public ILuceneConnection createLuceneConnection(Directory directory, Analyzer analyzer)
57      {
58          return createLuceneConnection(directory, analyzer, ILuceneConnection.DEFAULT_CONFIGURATION);
59      }
60  }