KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*-
2  * See the file LICENSE for redistribution information.
3  *
4  * Copyright (c) 2002,2006 Oracle. All rights reserved.
5  *
6  * $Id: EnvironmentConfig.java,v 1.35 2006/11/20 15:46:58 cwl Exp $
7  */

8
9 package com.sleepycat.je;
10
11 import java.util.Properties JavaDoc;
12
13 import com.sleepycat.je.config.EnvironmentParams;
14 import com.sleepycat.je.dbi.DbConfigManager;
15
16 /**
17  * Javadoc for this public class is generated
18  * via the doc templates in the doc_src directory.
19  */

20 public class EnvironmentConfig extends EnvironmentMutableConfig {
21     /*
22      * For internal use, to allow null as a valid value for
23      * the config parameter.
24      */

25     public static final EnvironmentConfig DEFAULT = new EnvironmentConfig();
26
27     /**
28      * For unit testing, to prevent creating the utilization profile DB.
29      */

30     private boolean createUP = true;
31
32     /**
33      * For unit testing, to prevent writing utilization data during checkpoint.
34      */

35     private boolean checkpointUP = true;
36
37     private boolean allowCreate = false;
38
39     /**
40      * For unit testing, to set readCommitted as the default.
41      */

42     private boolean txnReadCommitted = false;
43
44     private ExceptionListener exceptionListener = null;
45
46     /**
47      * Javadoc for this public method is generated via
48      * the doc templates in the doc_src directory.
49      */

50     public EnvironmentConfig() {
51         super();
52     }
53
54     /**
55      * Javadoc for this public method is generated via
56      * the doc templates in the doc_src directory.
57      */

58     public EnvironmentConfig(Properties JavaDoc properties)
59         throws IllegalArgumentException JavaDoc {
60
61         super(properties);
62     }
63
64     /**
65      * Javadoc for this public method is generated via
66      * the doc templates in the doc_src directory.
67      */

68     public void setAllowCreate(boolean allowCreate) {
69
70         this.allowCreate = allowCreate;
71     }
72
73     /**
74      * Javadoc for this public method is generated via
75      * the doc templates in the doc_src directory.
76      */

77     public boolean getAllowCreate() {
78
79         return allowCreate;
80     }
81
82     /**
83      * Javadoc for this public method is generated via
84      * the doc templates in the doc_src directory.
85      */

86     public void setLockTimeout(long timeout)
87         throws IllegalArgumentException JavaDoc {
88
89         DbConfigManager.setVal(props,
90                                EnvironmentParams.LOCK_TIMEOUT,
91                                Long.toString(timeout),
92                                validateParams);
93     }
94
95     /**
96      * Javadoc for this public method is generated via
97      * the doc templates in the doc_src directory.
98      */

99     public long getLockTimeout() {
100
101         String JavaDoc val = DbConfigManager.getVal(props,
102                                             EnvironmentParams.LOCK_TIMEOUT);
103         long timeout = 0;
104         try {
105             timeout = Long.parseLong(val);
106         } catch (NumberFormatException JavaDoc e) {
107             throw new IllegalArgumentException JavaDoc
108         ("Bad value for timeout:" + e.getMessage());
109         }
110         return timeout;
111     }
112
113     /**
114      * Javadoc for this public method is generated via
115      * the doc templates in the doc_src directory.
116      */

117     public void setReadOnly(boolean readOnly) {
118
119         DbConfigManager.setVal(props,
120                                EnvironmentParams.ENV_RDONLY,
121                                Boolean.toString(readOnly),
122                                validateParams);
123     }
124
125     /**
126      * Javadoc for this public method is generated via
127      * the doc templates in the doc_src directory.
128      */

129     public boolean getReadOnly() {
130
131         String JavaDoc val = DbConfigManager.getVal(props,
132                                             EnvironmentParams.ENV_RDONLY);
133         return (Boolean.valueOf(val)).booleanValue();
134     }
135
136     /**
137      * Javadoc for this public method is generated via
138      * the doc templates in the doc_src directory.
139      */

140     public void setTransactional(boolean transactional) {
141
142         DbConfigManager.setVal(props,
143                                EnvironmentParams.ENV_INIT_TXN,
144                                Boolean.toString(transactional),
145                                validateParams);
146     }
147
148     /**
149      * Javadoc for this public method is generated via
150      * the doc templates in the doc_src directory.
151      */

152     public boolean getTransactional() {
153
154         String JavaDoc val = DbConfigManager.getVal(props,
155                                             EnvironmentParams.ENV_INIT_TXN);
156         return (Boolean.valueOf(val)).booleanValue();
157     }
158
159     /**
160      * Javadoc for this public method is generated via
161      * the doc templates in the doc_src directory.
162      */

163     public void setLocking(boolean locking) {
164
165         DbConfigManager.setVal(props,
166                                EnvironmentParams.ENV_INIT_LOCKING,
167                                Boolean.toString(locking),
168                                validateParams);
169     }
170
171     /**
172      * Javadoc for this public method is generated via
173      * the doc templates in the doc_src directory.
174      */

175     public boolean getLocking() {
176
177         String JavaDoc val =
178             DbConfigManager.getVal(props, EnvironmentParams.ENV_INIT_LOCKING);
179         return (Boolean.valueOf(val)).booleanValue();
180     }
181
182     /**
183      * Javadoc for this public method is generated via
184      * the doc templates in the doc_src directory.
185      */

186     public void setTxnTimeout(long timeout)
187         throws IllegalArgumentException JavaDoc {
188
189         DbConfigManager.setVal(props,
190                                EnvironmentParams.TXN_TIMEOUT,
191                                Long.toString(timeout),
192                                validateParams);
193     }
194
195     /**
196      * Javadoc for this public method is generated via
197      * the doc templates in the doc_src directory.
198      */

199     public long getTxnTimeout() {
200
201         String JavaDoc val = DbConfigManager.getVal(props,
202                                             EnvironmentParams.TXN_TIMEOUT);
203         long timeout = 0;
204         try {
205             timeout = Long.parseLong(val);
206         } catch (NumberFormatException JavaDoc e) {
207             throw new IllegalArgumentException JavaDoc
208         ("Bad value for timeout:" + e.getMessage());
209         }
210         return timeout;
211     }
212
213     /**
214      * Javadoc for this public method is generated via
215      * the doc templates in the doc_src directory.
216      */

217     public void setTxnSerializableIsolation(boolean txnSerializableIsolation) {
218         
219         DbConfigManager.setVal(props,
220                                EnvironmentParams.TXN_SERIALIZABLE_ISOLATION,
221                                Boolean.toString(txnSerializableIsolation),
222                                validateParams);
223     }
224
225     /**
226      * Javadoc for this public method is generated via
227      * the doc templates in the doc_src directory.
228      */

229     public boolean getTxnSerializableIsolation() {
230
231         String JavaDoc val =
232             DbConfigManager.getVal(props,
233                                    EnvironmentParams.TXN_SERIALIZABLE_ISOLATION);
234         return (Boolean.valueOf(val)).booleanValue();
235     }
236
237     /**
238      * Javadoc for this public method is generated via
239      * the doc templates in the doc_src directory.
240      */

241     public void setExceptionListener(ExceptionListener exceptionListener) {
242     this.exceptionListener = exceptionListener;
243     }
244
245     /**
246      * Javadoc for this public method is generated via
247      * the doc templates in the doc_src directory.
248      */

249     public ExceptionListener getExceptionListener() {
250     return exceptionListener;
251     }
252
253     /**
254      * For unit testing, to set readCommitted as the default.
255      */

256     void setTxnReadCommitted(boolean txnReadCommitted) {
257         
258         this.txnReadCommitted = txnReadCommitted;
259     }
260
261     /**
262      * For unit testing, to set readCommitted as the default.
263      */

264     boolean getTxnReadCommitted() {
265         
266         return txnReadCommitted;
267     }
268
269     /**
270      * Javadoc for this public method is generated via
271      * the doc templates in the doc_src directory.
272      */

273     public void setConfigParam(String JavaDoc paramName,
274                    String JavaDoc value)
275         throws IllegalArgumentException JavaDoc {
276
277         DbConfigManager.setConfigParam(props,
278                                        paramName,
279                                        value,
280                                        false, /* requireMutablity */
281                                        validateParams,
282                                        false /* forReplication */);
283     }
284
285     /**
286      * For unit testing, to prevent creating the utilization profile DB.
287      */

288     void setCreateUP(boolean createUP) {
289         this.createUP = createUP;
290     }
291
292     /**
293      * For unit testing, to prevent creating the utilization profile DB.
294      */

295     boolean getCreateUP() {
296         return createUP;
297     }
298
299     /**
300      * For unit testing, to prevent writing utilization data during checkpoint.
301      */

302     void setCheckpointUP(boolean checkpointUP) {
303         this.checkpointUP = checkpointUP;
304     }
305
306     /**
307      * For unit testing, to prevent writing utilization data during checkpoint.
308      */

309     boolean getCheckpointUP() {
310         return checkpointUP;
311     }
312
313     /**
314      * Used by Environment to create a copy of the application
315      * supplied configuration.
316      */

317     EnvironmentConfig cloneConfig() {
318         try {
319             return (EnvironmentConfig) clone();
320         } catch (CloneNotSupportedException JavaDoc willNeverOccur) {
321             return null;
322         }
323     }
324
325     public String JavaDoc toString() {
326         return ("allowCreate=" + allowCreate + "\n" + super.toString());
327     }
328 }
329
Popular Tags