com.atlassian.jira.issue.index
Class DefaultLuceneConnectionManager

java.lang.Object
  extended by com.atlassian.jira.issue.index.DefaultLuceneConnectionManager
All Implemented Interfaces:
LuceneConnectionManager

public class DefaultLuceneConnectionManager
extends Object
implements LuceneConnectionManager

Default implementation of the LuceneConnectionManager interface. This implemetation guarantees that any threads calling get() after a call to shutdown() will fail.

The actual construction of a concrete ILuceneConnection is delegated to a LuceneConnectionFactory.

Note: It uses a ThreadsafeLazyLoadedReference hold the the LuceneConnection. This class lazily loads the connection when it is first requested (ie. on the first call to get() rather than during init(String, boolean, org.apache.lucene.analysis.Analyzer). As the LuceneConnection needs to be cleared when shutdown we throw away the LuceneConnection reference when shutdown, and for thread safety we hold the lazy load reference inside an AtomicReference. It is important to remember that due to this, the LuceneConnection is doubly dereferenced. AtomicRef -> ThreadsafyLazyLoadedRef -> LuceneConnection.


Constructor Summary
DefaultLuceneConnectionManager(LuceneConnectionFactory connectionFactory)
          Construct a new object.
 
Method Summary
 com.atlassian.bonnie.ILuceneConnection get()
          Get a live LuceneConnection.
 void init(String indexPath, boolean create, org.apache.lucene.analysis.Analyzer analyzer)
          The init parameters for the LuceneConnection.
 boolean isActive()
          Whether the LuceneConnection has been inited and not shutdown.
 void shutdown()
          Close the LuceneConnection and discard it.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultLuceneConnectionManager

DefaultLuceneConnectionManager(LuceneConnectionFactory connectionFactory)
                         throws NullPointerException
Construct a new object.

Parameters:
connectionFactory - to use for actual construction of a ILuceneConnection instance
Throws:
NullPointerException - if the LuceneConnectionFactory is null
Method Detail

get

public com.atlassian.bonnie.ILuceneConnection get()
Description copied from interface: LuceneConnectionManager
Get a live LuceneConnection. Live means it has not been closed by a call to LuceneConnectionManager.shutdown().

Specified by:
get in interface LuceneConnectionManager
Returns:

init

public void init(String indexPath,
                 boolean create,
                 org.apache.lucene.analysis.Analyzer analyzer)
Description copied from interface: LuceneConnectionManager
The init parameters for the LuceneConnection. This method should be called once when LuceneConnectionManager.isActive() is false. Subsequent calls once the LuceneConnection is active are ignored.

Specified by:
init in interface LuceneConnectionManager

isActive

public boolean isActive()
Description copied from interface: LuceneConnectionManager
Whether the LuceneConnection has been inited and not shutdown.

Specified by:
isActive in interface LuceneConnectionManager

shutdown

public void shutdown()
Description copied from interface: LuceneConnectionManager
Close the LuceneConnection and discard it. Any subsequent calls to LuceneConnectionManager.get() should fail, until LuceneConnectionManager.init(String, boolean, org.apache.lucene.analysis.Analyzer) is invoked.

Subsequent calls to shutdown are ignored.

Specified by:
shutdown in interface LuceneConnectionManager


Copyright © 2002-2007 Atlassian. All Rights Reserved.