KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sleepycat > je > DbInternal


1 /*-
2  * See the file LICENSE for redistribution information.
3  *
4  * Copyright (c) 2002,2006 Oracle. All rights reserved.
5  *
6  * $Id: DbInternal.java,v 1.44 2006/11/06 20:36:55 linda Exp $
7  */

8
9 package com.sleepycat.je;
10
11 import java.io.File JavaDoc;
12 import java.util.Properties JavaDoc;
13
14 import com.sleepycat.je.dbi.CursorImpl;
15 import com.sleepycat.je.dbi.DatabaseImpl;
16 import com.sleepycat.je.dbi.EnvironmentImpl;
17 import com.sleepycat.je.dbi.GetMode;
18 import com.sleepycat.je.txn.Locker;
19
20 /**
21  * For internal use only. It serves to shelter methods that must be public to
22  * be used by other BDBJE packages but that are not part of the public api
23  * available to applications.
24  */

25 public class DbInternal {
26
27     /**
28      * Proxy to Database.invalidate()
29      */

30     public static void dbInvalidate(Database db) {
31         db.invalidate();
32     }
33
34     /**
35      * Proxy to Database.setHandleLockOwnerTxn
36      */

37     public static void dbSetHandleLocker(Database db, Locker locker) {
38         db.setHandleLocker(locker);
39     }
40
41     /**
42      * Proxy to Environment.getDbEnvironment
43      */

44     public static EnvironmentImpl envGetEnvironmentImpl(Environment env) {
45         return env.getEnvironmentImpl();
46     }
47
48     /**
49      * Proxy to new Cursor(DatabaseImpl, Locker, CursorConfig)
50      */

51     public static Cursor newCursor(DatabaseImpl dbImpl,
52                    Locker locker,
53                                    CursorConfig cursorConfig)
54         throws DatabaseException {
55
56         return new Cursor(dbImpl, locker, cursorConfig);
57     }
58
59     /**
60      * Proxy to new Cursor.position().
61      */

62     public static OperationStatus position(Cursor cursor,
63                                            DatabaseEntry key,
64                                            DatabaseEntry data,
65                                            LockMode lockMode,
66                                            boolean first)
67         throws DatabaseException {
68
69         return cursor.position(key, data, lockMode, first);
70     }
71     
72     /**
73      * Proxy to new Cursor.retrieveNext().
74      */

75     public static OperationStatus retrieveNext(Cursor cursor,
76                                                DatabaseEntry key,
77                                                DatabaseEntry data,
78                                                LockMode lockMode,
79                                                GetMode getMode)
80         throws DatabaseException {
81
82         return cursor.retrieveNext(key, data, lockMode, getMode);
83     }
84
85     /**
86      * Proxy to Cursor.advanceCursor()
87      */

88     public static boolean advanceCursor(Cursor cursor,
89                                         DatabaseEntry key,
90                                         DatabaseEntry data) {
91     return cursor.advanceCursor(key, data);
92     }
93
94     /**
95      * Proxy to Cursor.getCursorImpl()
96      */

97     public static CursorImpl getCursorImpl(Cursor cursor) {
98         return cursor.getCursorImpl();
99     }
100
101     /**
102      * Proxy to Database.getDatabase()
103      */

104     public static DatabaseImpl dbGetDatabaseImpl(Database db) {
105         return db.getDatabaseImpl();
106     }
107
108     /**
109      * Proxy to JoinCursor.getSortedCursors()
110      */

111     public static Cursor[] getSortedCursors(JoinCursor cursor) {
112     return cursor.getSortedCursors();
113     }
114
115     /**
116      * Proxy to EnvironmentConfig.setLoadPropertyFile()
117      */

118     public static void setLoadPropertyFile(EnvironmentConfig config,
119                                            boolean loadProperties) {
120         config.setLoadPropertyFile(loadProperties);
121     }
122
123     /**
124      * Proxy to EnvironmentConfig.setCreateUP()
125      */

126     public static void setCreateUP(EnvironmentConfig config,
127                                    boolean checkpointUP) {
128         config.setCreateUP(checkpointUP);
129     }
130
131     /**
132      * Proxy to EnvironmentConfig.getCreateUP()
133      */

134     public static boolean getCreateUP(EnvironmentConfig config) {
135         return config.getCreateUP();
136     }
137
138     /**
139      * Proxy to EnvironmentConfig.setCheckpointUP()
140      */

141     public static void setCheckpointUP(EnvironmentConfig config,
142                                        boolean checkpointUP) {
143         config.setCheckpointUP(checkpointUP);
144     }
145
146     /**
147      * Proxy to EnvironmentConfig.getCheckpointUP()
148      */

149     public static boolean getCheckpointUP(EnvironmentConfig config) {
150         return config.getCheckpointUP();
151     }
152
153     /**
154      * Proxy to EnvironmentConfig.setTxnReadCommitted()
155      */

156     public static void setTxnReadCommitted(EnvironmentConfig config,
157                                            boolean txnReadCommitted) {
158         config.setTxnReadCommitted(txnReadCommitted);
159     }
160
161     /**
162      * Proxy to EnvironmentConfig.setTxnReadCommitted()
163      */

164     public static boolean getTxnReadCommitted(EnvironmentConfig config) {
165         return config.getTxnReadCommitted();
166     }
167
168     /**
169      * Proxy to EnvironmentConfig.cloneConfig()
170      */

171     public static EnvironmentConfig cloneConfig(EnvironmentConfig config) {
172         return config.cloneConfig();
173     }
174
175     /**
176      * Proxy to EnvironmentMutableConfig.cloneMutableConfig()
177      */

178     public static
179         EnvironmentMutableConfig cloneMutableConfig(EnvironmentMutableConfig
180                                                     config) {
181         return config.cloneMutableConfig();
182     }
183
184     /**
185      * Proxy to EnvironmentMutableConfig.checkImmutablePropsForEquality()
186      */

187     public static void
188         checkImmutablePropsForEquality(EnvironmentMutableConfig config,
189                                        EnvironmentMutableConfig passedConfig)
190         throws IllegalArgumentException JavaDoc {
191
192         config.checkImmutablePropsForEquality(passedConfig);
193     }
194
195     /**
196      * Proxy to EnvironmentMutableConfig.copyMutablePropsTo()
197      */

198     public static void copyMutablePropsTo(EnvironmentMutableConfig config,
199                                           EnvironmentMutableConfig toConfig) {
200         config.copyMutablePropsTo(toConfig);
201     }
202
203     /**
204      * Proxy to EnvironmentMutableConfig.validateParams.
205      */

206     public static void disableParameterValidation
207     (EnvironmentMutableConfig config) {
208     config.setValidateParams(false);
209     }
210
211     /**
212      * Proxy to EnvironmentMutableConfig.getProps
213      */

214     public static Properties JavaDoc getProps(EnvironmentMutableConfig config) {
215         return config.getProps();
216     }
217
218     /**
219      * Proxy to DatabaseConfig.setUseExistingConfig()
220      */

221     public static void setUseExistingConfig(DatabaseConfig config,
222                                             boolean useExistingConfig) {
223         config.setUseExistingConfig(useExistingConfig);
224     }
225
226     /**
227      * Proxy to DatabaseConfig.match(DatabaseConfig()
228      */

229     public static void databaseConfigValidate(DatabaseConfig config1,
230                          DatabaseConfig config2)
231     throws DatabaseException {
232
233         config1.validate(config2);
234     }
235
236     /**
237      * Proxy to Transaction.getLocker()
238      */

239     public static Locker getLocker(Transaction txn)
240         throws DatabaseException {
241
242         return txn.getLocker();
243     }
244
245     /**
246      * Proxy to Environment.getDefaultTxnConfig()
247      */

248     public static TransactionConfig getDefaultTxnConfig(Environment env) {
249         return env.getDefaultTxnConfig();
250     }
251
252     /**
253      * Get an Environment only if the environment is already open. This
254      * will register this Enviroment in the EnvironmentImpl's reference count,
255      * but will not configure the environment.
256      * @return null if the environment is not already open.
257      */

258     public static Environment
259         getEnvironmentShell(File JavaDoc environmentHome) {
260
261         Environment env = null;
262         try {
263             env = new Environment(environmentHome);
264
265             /* If the environment is not already open, return a null. */
266             if (env.getEnvironmentImpl() == null) {
267                 env = null;
268             }
269         } catch (DatabaseException e) {
270
271         /*
272          * Klockwork - ok
273              * the environment is not valid.
274          */

275         }
276         return env;
277     }
278
279     public static RunRecoveryException makeNoArgsRRE() {
280     return new RunRecoveryException();
281     }
282
283     public static ExceptionEvent makeExceptionEvent(Exception JavaDoc e, String JavaDoc n) {
284     return new ExceptionEvent(e, n);
285     }
286 }
287
Popular Tags