View Javadoc

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