1 17 package org.alfresco.repo.search.transaction; 18 19 import java.util.HashMap ; 20 import java.util.concurrent.locks.ReentrantLock ; 21 22 import org.alfresco.service.cmr.repository.StoreRef; 23 24 public class LuceneIndexLock 25 { 26 private HashMap <StoreRef, ReentrantLock > locks = new HashMap <StoreRef, ReentrantLock > (); 27 28 public LuceneIndexLock() 29 { 30 super(); 31 } 32 33 public void getReadLock(StoreRef ref) 34 { 35 return; 36 } 37 38 public void releaseReadLock(StoreRef ref) 39 { 40 return; 41 } 42 43 public void getWriteLock(StoreRef ref) 44 { 45 ReentrantLock lock; 46 synchronized(locks) 47 { 48 lock = locks.get(ref); 49 if(lock == null) 50 { 51 lock = new ReentrantLock (true); 52 locks.put(ref, lock); 53 } 54 } 55 lock.lock(); 56 } 57 58 public void releaseWriteLock(StoreRef ref) 59 { 60 ReentrantLock lock; 61 synchronized(locks) 62 { 63 lock = locks.get(ref); 64 } 65 if(lock != null) 66 { 67 lock.unlock(); 68 } 69 70 } 71 } 72 | Popular Tags |