KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > derby > impl > store > access > RllRAMAccessManager


1 /*
2
3    Derby - Class org.apache.derby.impl.store.access.RllRAMAccessManager
4
5    Licensed to the Apache Software Foundation (ASF) under one or more
6    contributor license agreements. See the NOTICE file distributed with
7    this work for additional information regarding copyright ownership.
8    The ASF licenses this file to you under the Apache License, Version 2.0
9    (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.access;
23
24 import org.apache.derby.iapi.services.monitor.Monitor;
25
26 import org.apache.derby.iapi.error.StandardException;
27
28 import org.apache.derby.iapi.store.access.AccessFactoryGlobals;
29 import org.apache.derby.iapi.store.access.TransactionController;
30
31 import org.apache.derby.iapi.store.raw.LockingPolicy;
32
33 import org.apache.derby.iapi.services.property.PropertyUtil;
34
35 import java.util.Properties JavaDoc;
36
37 import org.apache.derby.iapi.reference.Property;
38
39 /**
40
41 Implements the row level locking accessmanager.
42
43 **/

44
45 public class RllRAMAccessManager extends RAMAccessManager
46 {
47     private int system_lock_level = TransactionController.MODE_RECORD;
48
49     /**************************************************************************
50      * Constructors for This class:
51      **************************************************************************
52      */

53     public RllRAMAccessManager()
54     {
55         super();
56     }
57
58     /**************************************************************************
59      * Private/Protected methods of This class:
60      **************************************************************************
61      */

62
63     /***************************************************************************
64     ** Concrete methods of RAMAccessManager, interfaces that control locking
65     ** level of the system.
66     ****************************************************************************
67     */

68
69     /**
70      * Return the locking level of the system.
71      * <p>
72      * This routine controls the lowest level of locking enabled for all locks
73      * for all tables accessed through this accessmanager. The concrete
74      * implementation may set this value always to table level locking for
75      * a client configuration, or it may set it to row level locking for a
76      * server configuration.
77      * <p>
78      * If TransactionController.MODE_RECORD is returned table may either be
79      * locked at table or row locking depending on the type of access expected
80      * (ie. level 3 will require table locking for heap scans.)
81      *
82      * @return TransactionController.MODE_TABLE if only table locking allowed,
83      * else returns TransactionController.MODE_RECORD.
84      **/

85     protected int getSystemLockLevel()
86     {
87         return(system_lock_level);
88     }
89
90     /**
91      * Query property system to get the System lock level.
92      * <p>
93      * This routine will be called during boot after access has booted far
94      * enough, to allow access to the property conglomerate. This routine
95      * will call the property system and set the value to be returned by
96      * getSystemLockLevel().
97      * <p>
98      *
99      * @exception StandardException Standard exception policy.
100      **/

101     protected void bootLookupSystemLockLevel(
102     TransactionController tc)
103         throws StandardException
104     {
105         // The default for this module is TransactionController.MODE_RECORD,
106
// only change it if the setting is different.
107

108
109         if (isReadOnly() || !PropertyUtil.getServiceBoolean(tc, Property.ROW_LOCKING, true))
110         {
111             system_lock_level = TransactionController.MODE_TABLE;
112         }
113     }
114 }
115
Popular Tags