KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > derbyTesting > functionTests > util > T_Access


1 /*
2
3    Derby - Class org.apache.derbyTesting.functionTests.util.T_Access
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.derbyTesting.functionTests.util;
23
24 import org.apache.derby.iapi.error.StandardException;
25 import org.apache.derby.iapi.sql.conn.LanguageConnectionContext;
26 import org.apache.derby.iapi.sql.conn.ConnectionUtil;
27 import org.apache.derby.iapi.sql.conn.LanguageConnectionFactory;
28 import org.apache.derby.iapi.store.access.TransactionController;
29 import org.apache.derby.iapi.store.access.AccessFactory;
30 import org.apache.derby.iapi.error.PublicAPI;
31 import java.sql.SQLException JavaDoc;
32
33 /**
34    This class provides mechanism to call access Factory methods from sql-j.
35   */

36
37 public class T_Access
38 {
39
40     public static AccessFactory getAccessFactory() throws SQLException JavaDoc
41     {
42         LanguageConnectionContext lcc = ConnectionUtil.getCurrentLCC();
43         LanguageConnectionFactory lcf = lcc.getLanguageConnectionFactory();
44         return (AccessFactory)lcf.getAccessFactory();
45     }
46
47     /*
48      *Followng call waits until post commit thread queue is empty.
49      *This call is useful for tests which checks for the following type
50      *of cases:
51      * 1) Checking for space usage after delete statements
52      * 2) Checking for locks when delete statements are involved,
53      * because post commit thread might be holding locks when
54      * checking for snap shot of locks, so best thing to do
55      * to get consistent results is to call the following function
56      * before checking for locks (eg: store/updatelocks.sql)
57      * 3) Depending on whethere the space is not released yet by the post commit thread
58      * for commited deletes or not can change the order of rows in the heap.
59      * In such cases , it is good idea to call this method before doing
60      * inserts(Even adding/dropping constraints can have effect because they
61      * do inderectly deletes/inserts on system tables.) eg: lang/fk_nonsps.sql
62      */

63     public static void waitForPostCommitToFinish() throws SQLException JavaDoc
64     {
65             AccessFactory af = getAccessFactory();
66             af.waitForPostCommitToFinishWork();
67     }
68 }
69
70
Popular Tags