lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From o...@apache.org
Subject cvs commit: jakarta-lucene/src/java/org/apache/lucene/store FSDirectory.java
Date Tue, 25 Jun 2002 16:09:15 GMT
otis        2002/06/25 09:09:15

  Modified:    src/java/org/apache/lucene/store FSDirectory.java
  Log:
  - Reduced the number of condition checks for disabling locks.
  - Documented the use of 'disableLocks' system property in class Javadoc.
  
  Revision  Changes    Path
  1.8       +20 -18    jakarta-lucene/src/java/org/apache/lucene/store/FSDirectory.java
  
  Index: FSDirectory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/src/java/org/apache/lucene/store/FSDirectory.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- FSDirectory.java	21 Jun 2002 14:57:46 -0000	1.7
  +++ FSDirectory.java	25 Jun 2002 16:09:15 -0000	1.8
  @@ -63,10 +63,13 @@
   import org.apache.lucene.util.Constants;
   
   /**
  -  Straightforward implementation of Directory as a directory of files.
  -    @see Directory
  -    @author Doug Cutting
  -*/
  + * Straight forward implementation of Directory as a directory of files.
  + * If the system property 'disableLocks' has the String value of "true", lock
  + * creation will be disabled.
  + *
  + * @see Directory
  + * @author Doug Cutting
  + */
   
   final public class FSDirectory extends Directory {
     /** This cache of directories ensures that there is a unique Directory
  @@ -77,14 +80,15 @@
      * require Java 1.2.  Instead we use refcounts...  */
     private static final Hashtable DIRECTORIES = new Hashtable();
   
  -  private static final boolean DISABLE_LOCKS = Boolean.getBoolean("disableLocks");
  +  private static final boolean DISABLE_LOCKS =
  +      Boolean.getBoolean("disableLocks") || Constants.JAVA_1_1;
   
     /** Returns the directory instance for the named location.
  -   * 
  +   *
      * <p>Directories are cached, so that, for a given canonical path, the same
      * FSDirectory instance will always be returned.  This permits
      * synchronization on directories.
  -   * 
  +   *
      * @param path the path to the directory.
      * @param create if true, create, or erase any existing contents.
      * @return the FSDirectory for the named file.  */
  @@ -94,11 +98,11 @@
     }
   
     /** Returns the directory instance for the named location.
  -   * 
  +   *
      * <p>Directories are cached, so that, for a given canonical path, the same
      * FSDirectory instance will always be returned.  This permits
      * synchronization on directories.
  -   * 
  +   *
      * @param file the path to the directory.
      * @param create if true, create, or erase any existing contents.
      * @return the FSDirectory for the named file.  */
  @@ -151,19 +155,19 @@
     public final String[] list() throws IOException {
       return directory.list();
     }
  -       
  +
     /** Returns true iff a file with the given name exists. */
     public final boolean fileExists(String name) throws IOException {
       File file = new File(directory, name);
       return file.exists();
     }
  -       
  +
     /** Returns the time the named file was last modified. */
     public final long fileModified(String name) throws IOException {
       File file = new File(directory, name);
       return file.lastModified();
     }
  -       
  +
     /** Returns the time the named file was last modified. */
     public static final long fileModified(File directory, String name)
          throws IOException {
  @@ -229,15 +233,13 @@
       final File lockFile = new File(directory, name);
       return new Lock() {
   	public boolean obtain() throws IOException {
  -          if (Constants.JAVA_1_1)
  -	      return true;    // locks disabled in jdk 1.1
   	  if (DISABLE_LOCKS)
   	      return true;
             return lockFile.createNewFile();
   	}
   	public void release() {
  -          if (Constants.JAVA_1_1)
  -	      return;         // locks disabled in jdk 1.1
  +	  if (DISABLE_LOCKS)
  +	      return;
   	  lockFile.delete();
   	}
   	public String toString() {
  @@ -308,7 +310,7 @@
     }
   
     protected final void finalize() throws IOException {
  -    close();					  // close the file 
  +    close();					  // close the file
     }
   
     public Object clone() {
  @@ -345,7 +347,7 @@
     }
   
     protected final void finalize() throws IOException {
  -    file.close();				  // close the file 
  +    file.close();				  // close the file
     }
   
   }
  
  
  

--
To unsubscribe, e-mail:   <mailto:lucene-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:lucene-dev-help@jakarta.apache.org>


Mime
View raw message