Index: FSDirectory.java =================================================================== RCS file: /home/cvspublic/jakarta-lucene/src/java/org/apache/lucene/store/FSDirectory.java,v retrieving revision 1.36 diff -u -r1.36 FSDirectory.java --- FSDirectory.java 28 Sep 2004 20:45:26 -0000 1.36 +++ FSDirectory.java 10 Nov 2004 05:50:09 -0000 @@ -309,37 +309,49 @@ buf.append("-"); buf.append(name); - // create a lock file - final File lockFile = new File(lockDir, buf.toString()); - - return new Lock() { - public boolean obtain() throws IOException { - if (DISABLE_LOCKS) - return true; - - if (!lockDir.exists()) { - if (!lockDir.mkdirs()) { - throw new IOException("Cannot create lock directory: " + lockDir); - } + /* This is the override TODO: finish documentation */ + if( LockFactory.isOverridden() ) { + /* Should better handle exceptions, but method + doesn't throw any, so we have to eat... */ + try { + return LockFactory.getLock( buf.toString() ); + } catch(Exception e) { + e.printStackTrace(); + return null; } + } else { + // create a lock file + final File lockFile = new File(lockDir, buf.toString()); + /* Default lock mechanism (filesystem lock) */ + return new Lock() { + public boolean obtain() throws IOException { + if (DISABLE_LOCKS) + return true; + + if (!lockDir.exists()) { + if (!lockDir.mkdirs()) { + throw new IOException("Cannot create lock directory: " + lockDir); + } + } - return lockFile.createNewFile(); - } - public void release() { - if (DISABLE_LOCKS) - return; - lockFile.delete(); - } - public boolean isLocked() { - if (DISABLE_LOCKS) - return false; - return lockFile.exists(); - } + return lockFile.createNewFile(); + } + public void release() { + if (DISABLE_LOCKS) + return; + lockFile.delete(); + } + public boolean isLocked() { + if (DISABLE_LOCKS) + return false; + return lockFile.exists(); + } - public String toString() { - return "Lock@" + lockFile; - } - }; + public String toString() { + return "Lock@" + lockFile; + } + }; + } } private StringBuffer getLockPrefix() { @@ -483,4 +495,4 @@ file.close(); // close the file } -} +} \ No newline at end of file