1 21 22 package org.apache.derby.impl.store.raw.xact; 23 24 import org.apache.derby.iapi.services.locks.LockFactory; 25 import org.apache.derby.iapi.services.locks.C_LockFactory; 26 27 import org.apache.derby.iapi.store.raw.ContainerHandle; 28 import org.apache.derby.iapi.store.raw.ContainerLock; 29 import org.apache.derby.iapi.store.raw.Transaction; 30 31 import org.apache.derby.iapi.error.StandardException; 32 33 34 40 public class ContainerLocking2 extends NoLocking { 41 42 private final LockFactory lf; 43 44 protected ContainerLocking2() 45 { 46 this.lf = null; 47 } 48 49 protected ContainerLocking2(LockFactory lf) 50 { 51 this.lf = lf; 52 } 53 54 60 public boolean lockContainer( 61 Transaction t, 62 ContainerHandle container, 63 boolean waitForLock, 64 boolean forUpdate) 65 throws StandardException 66 { 67 Object qualifier = forUpdate ? ContainerLock.CX : ContainerLock.CS; 68 69 Object group = 72 forUpdate ? t : container.getUniqueId(); 73 74 return( 75 lf.lockObject( 76 t.getCompatibilitySpace(), group, container.getId(), qualifier, 77 waitForLock ? 78 C_LockFactory.TIMED_WAIT : C_LockFactory.NO_WAIT)); 79 } 80 81 92 public void unlockContainer( 93 Transaction t, 94 ContainerHandle container) 95 { 96 if (container.isReadOnly()) 98 { 99 lf.unlockGroup(t.getCompatibilitySpace(), container.getUniqueId()); 100 } 101 } 102 103 public int getMode() { 104 return MODE_CONTAINER; 105 } 106 107 108 113 } 114 | Popular Tags |