Main Page | Class Hierarchy | Data Structures | Directories | File List | Data Fields | Related Pages

TransactionConfig.java

00001 /*-
00002  * See the file LICENSE for redistribution information.
00003  *
00004  * Copyright (c) 2002-2005
00005  *      Sleepycat Software.  All rights reserved.
00006  *
00007  * $Id: TransactionConfig.java,v 12.2 2005/06/16 20:23:04 bostic Exp $
00008  */
00009 
00010 package com.sleepycat.db;
00011 
00012 import com.sleepycat.db.internal.DbConstants;
00013 import com.sleepycat.db.internal.DbEnv;
00014 import com.sleepycat.db.internal.DbTxn;
00015 
00016 public class TransactionConfig implements Cloneable {
00017     /*
00018      * For internal use, to allow null as a valid value for
00019      * the config parameter.
00020      */
00021     public static final TransactionConfig DEFAULT = new TransactionConfig();
00022 
00023     /* package */
00024     static TransactionConfig checkNull(TransactionConfig config) {
00025         return (config == null) ? DEFAULT : config;
00026     }
00027 
00028     private boolean readUncommitted = false;
00029     private boolean readCommitted = false;
00030     private boolean noSync = false;
00031     private boolean noWait = false;
00032     private boolean sync = false;
00033 
00034     public TransactionConfig() {
00035     }
00036 
00037     public void setReadCommitted(final boolean readCommitted) {
00038         this.readCommitted = readCommitted;
00039     }
00040     
00041     public boolean getReadCommitted() {
00042         return readCommitted;
00043     }
00044 
00046     public void setDegree2(final boolean degree2) {
00047         setReadCommitted(degree2);
00048     }
00049 
00051     public boolean getDegree2() {
00052         return getReadCommitted();
00053     }
00054 
00055     public void setReadUncommitted(final boolean readUncommitted) {
00056         this.readUncommitted = readUncommitted;
00057     }
00058 
00059     public boolean getReadUncommitted() {
00060         return readUncommitted;
00061     }
00062 
00064     public void setDirtyRead(final boolean dirtyRead) {
00065         setReadUncommitted(dirtyRead);
00066     }
00067 
00069     public boolean getDirtyRead() {
00070         return getReadUncommitted();
00071     }
00072 
00073     public void setNoSync(final boolean noSync) {
00074         this.noSync = noSync;
00075     }
00076 
00077     public boolean getNoSync() {
00078         return noSync;
00079     }
00080 
00081     public void setNoWait(final boolean noWait) {
00082         this.noWait = noWait;
00083     }
00084 
00085     public boolean getNoWait() {
00086         return noWait;
00087     }
00088 
00089     public void setSync(final boolean sync) {
00090         this.sync = sync;
00091     }
00092 
00093     public boolean getSync() {
00094         return sync;
00095     }
00096 
00097     DbTxn beginTransaction(final DbEnv dbenv, final DbTxn parent)
00098         throws DatabaseException {
00099 
00100         int flags = 0;
00101         flags |= readCommitted ? DbConstants.DB_READ_COMMITTED : 0;
00102         flags |= readUncommitted ? DbConstants.DB_READ_UNCOMMITTED : 0;
00103         flags |= noSync ? DbConstants.DB_TXN_NOSYNC : 0;
00104         flags |= noWait ? DbConstants.DB_TXN_NOWAIT : 0;
00105         flags |= sync ? DbConstants.DB_TXN_SYNC : 0;
00106 
00107         return dbenv.txn_begin(parent, flags);
00108     }
00109 }

Generated on Sun Dec 25 12:14:33 2005 for Berkeley DB 4.4.16 by  doxygen 1.4.2