01: /*
02:
03: Derby - Class org.apache.derby.impl.store.raw.xact.ContainerLocking3
04:
05: Licensed to the Apache Software Foundation (ASF) under one or more
06: contributor license agreements. See the NOTICE file distributed with
07: this work for additional information regarding copyright ownership.
08: The ASF licenses this file to you under the Apache License, Version 2.0
09: (the "License"); you may not use this file except in compliance with
10: the License. You may obtain a copy of the License at
11:
12: http://www.apache.org/licenses/LICENSE-2.0
13:
14: Unless required by applicable law or agreed to in writing, software
15: distributed under the License is distributed on an "AS IS" BASIS,
16: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17: See the License for the specific language governing permissions and
18: limitations under the License.
19:
20: */
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: A locking policy that implements container level locking with
35: isolation degree 3.
36:
37: @see org.apache.derby.iapi.store.raw.LockingPolicy
38: */
39: public class ContainerLocking3 extends NoLocking {
40:
41: protected final LockFactory lf;
42:
43: protected ContainerLocking3(LockFactory lf) {
44: this .lf = lf;
45: }
46:
47: /**
48: Obtain a Container shared or exclusive lock until
49: the end of the nested transaction.
50:
51: @exception StandardException Standard Cloudscape error policy
52: */
53: public boolean lockContainer(Transaction t,
54: ContainerHandle container, boolean waitForLock,
55: boolean forUpdate) throws StandardException {
56: Object qualifier = forUpdate ? ContainerLock.CX
57: : ContainerLock.CS;
58:
59: return (lf.lockObject(t.getCompatibilitySpace(), t, container
60: .getId(), qualifier,
61: waitForLock ? C_LockFactory.TIMED_WAIT
62: : C_LockFactory.NO_WAIT));
63: }
64:
65: public int getMode() {
66: return MODE_CONTAINER;
67: }
68:
69: /*
70: ** We can inherit all the others methods of NoLocking since we hold the
71: ** container lock until the end of transaction, and we don't obtain row
72: ** locks.
73: */
74: }
|