1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 2<!--NewPage--> 3<HTML> 4<HEAD> 5<!-- Generated by javadoc (build 1.6.0_03) on Mon Apr 12 16:25:50 EDT 2010 --> 6<TITLE> 7TransactionRunner (Oracle - Berkeley DB Java API) 8</TITLE> 9 10<META NAME="date" CONTENT="2010-04-12"> 11 12<LINK REL ="stylesheet" TYPE="text/css" HREF="../../../style.css" TITLE="Style"> 13 14<SCRIPT type="text/javascript"> 15function windowTitle() 16{ 17 if (location.href.indexOf('is-external=true') == -1) { 18 parent.document.title="TransactionRunner (Oracle - Berkeley DB Java API)"; 19 } 20} 21</SCRIPT> 22<NOSCRIPT> 23</NOSCRIPT> 24 25</HEAD> 26 27<BODY BGCOLOR="white" onload="windowTitle();"> 28<HR> 29 30 31<!-- ========= START OF TOP NAVBAR ======= --> 32<A NAME="navbar_top"><!-- --></A> 33<A HREF="#skip-navbar_top" title="Skip navigation links"></A> 34<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY=""> 35<TR> 36<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> 37<A NAME="navbar_top_firstrow"><!-- --></A> 38<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY=""> 39 <TR ALIGN="center" VALIGN="top"> 40 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD> 41 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD> 42 <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD> 43 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/TransactionRunner.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD> 44 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD> 45 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD> 46 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD> 47 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD> 48 </TR> 49</TABLE> 50</TD> 51<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM> 52<b>Berkeley DB</b><br><font size="-1"> version 4.8.30</font></EM> 53</TD> 54</TR> 55 56<TR> 57<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> 58 <A HREF="../../../com/sleepycat/collections/StoredValueSet.html" title="class in com.sleepycat.collections"><B>PREV CLASS</B></A> 59 <A HREF="../../../com/sleepycat/collections/TransactionWorker.html" title="interface in com.sleepycat.collections"><B>NEXT CLASS</B></A></FONT></TD> 60<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> 61 <A HREF="../../../index.html?com/sleepycat/collections/TransactionRunner.html" target="_top"><B>FRAMES</B></A> 62 <A HREF="TransactionRunner.html" target="_top"><B>NO FRAMES</B></A> 63 <SCRIPT type="text/javascript"> 64 <!-- 65 if(window==top) { 66 document.writeln('<A HREF="../../../allclasses-noframe.html"><B>All Classes</B></A>'); 67 } 68 //--> 69</SCRIPT> 70<NOSCRIPT> 71 <A HREF="../../../allclasses-noframe.html"><B>All Classes</B></A> 72</NOSCRIPT> 73 74 75</FONT></TD> 76</TR> 77<TR> 78<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> 79 SUMMARY: NESTED | <A HREF="#field_summary">FIELD</A> | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD> 80<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> 81DETAIL: <A HREF="#field_detail">FIELD</A> | <A HREF="#constructor_detail">CONSTR</A> | <A HREF="#method_detail">METHOD</A></FONT></TD> 82</TR> 83</TABLE> 84<A NAME="skip-navbar_top"></A> 85<!-- ========= END OF TOP NAVBAR ========= --> 86 87<HR> 88<!-- ======== START OF CLASS DATA ======== --> 89<H2> 90<FONT SIZE="-1"> 91com.sleepycat.collections</FONT> 92<BR> 93Class TransactionRunner</H2> 94<PRE> 95<A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">java.lang.Object</A> 96 <IMG SRC="../../../resources/inherit.gif" ALT="extended by "><B>com.sleepycat.collections.TransactionRunner</B> 97</PRE> 98<HR> 99<DL> 100<DT><PRE>public class <B>TransactionRunner</B><DT>extends <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</A></DL> 101</PRE> 102 103<P> 104Starts a transaction, calls <A HREF="../../../com/sleepycat/collections/TransactionWorker.html#doWork()"><CODE>TransactionWorker.doWork()</CODE></A>, and handles 105 transaction retry and exceptions. To perform a transaction, the user 106 implements the <A HREF="../../../com/sleepycat/collections/TransactionWorker.html" title="interface in com.sleepycat.collections"><CODE>TransactionWorker</CODE></A> interface and passes an instance of 107 that class to the <A HREF="../../../com/sleepycat/collections/TransactionRunner.html#run(com.sleepycat.collections.TransactionWorker)"><CODE>run</CODE></A> method. 108 109 <p>A single TransactionRunner instance may be used by any number of threads 110 for any number of transactions.</p> 111 112 <p>The behavior of the run() method depends on whether the environment is 113 transactional, whether nested transactions are enabled, and whether a 114 transaction is already active.</p> 115 116 <ul> 117 <li>When the run() method is called in a transactional environment and no 118 transaction is active for the current thread, a new transaction is started 119 before calling doWork(). If DeadlockException is thrown by doWork(), 120 the transaction will be aborted and the process will be repeated up to the 121 maximum number of retries. If another exception is thrown by doWork() or 122 the maximum number of retries has occurred, the transaction will be aborted 123 and the exception will be rethrown by the run() method. If no exception is 124 thrown by doWork(), the transaction will be committed. The run() method 125 will not attempt to commit or abort a transaction if it has already been 126 committed or aborted by doWork().</li> 127 128 <li>When the run() method is called and a transaction is active for the 129 current thread, and nested transactions are enabled, a nested transaction is 130 started before calling doWork(). The transaction that is active when 131 calling the run() method will become the parent of the nested transaction. 132 The nested transaction will be committed or aborted by the run() method 133 following the same rules described above. Note that nested transactions may 134 not be enabled for the JE product, since JE does not support nested 135 transactions.</li> 136 137 <li>When the run() method is called in a non-transactional environment, the 138 doWork() method is called without starting a transaction. The run() method 139 will return without committing or aborting a transaction, and any exceptions 140 thrown by the doWork() method will be thrown by the run() method.</li> 141 142 <li>When the run() method is called and a transaction is active for the 143 current thread and nested transactions are not enabled (the default) the 144 same rules as above apply. All the operations performed by the doWork() 145 method will be part of the currently active transaction.</li> 146 </ul> 147 148 <p>In a transactional environment, the rules described above support nested 149 calls to the run() method and guarantee that the outermost call will cause 150 the transaction to be committed or aborted. This is true whether or not 151 nested transactions are supported or enabled. Note that nested transactions 152 are provided as an optimization for improving concurrency but do not change 153 the meaning of the outermost transaction. Nested transactions are not 154 currently supported by the JE product.</p> 155<P> 156 157<P> 158<HR> 159 160<P> 161<!-- =========== FIELD SUMMARY =========== --> 162 163<A NAME="field_summary"><!-- --></A> 164<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> 165<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> 166<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2"> 167<B>Field Summary</B></FONT></TH> 168</TR> 169<TR BGCOLOR="white" CLASS="TableRowColor"> 170<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 171<CODE>static int</CODE></FONT></TD> 172<TD><CODE><B><A HREF="../../../com/sleepycat/collections/TransactionRunner.html#DEFAULT_MAX_RETRIES">DEFAULT_MAX_RETRIES</A></B></CODE> 173 174<BR> 175 The default maximum number of retries.</TD> 176</TR> 177</TABLE> 178 179<!-- ======== CONSTRUCTOR SUMMARY ======== --> 180 181<A NAME="constructor_summary"><!-- --></A> 182<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> 183<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> 184<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2"> 185<B>Constructor Summary</B></FONT></TH> 186</TR> 187<TR BGCOLOR="white" CLASS="TableRowColor"> 188<TD><CODE><B><A HREF="../../../com/sleepycat/collections/TransactionRunner.html#TransactionRunner(com.sleepycat.db.Environment)">TransactionRunner</A></B>(<A HREF="../../../com/sleepycat/db/Environment.html" title="class in com.sleepycat.db">Environment</A> env)</CODE> 189 190<BR> 191 Creates a transaction runner for a given Berkeley DB environment.</TD> 192</TR> 193<TR BGCOLOR="white" CLASS="TableRowColor"> 194<TD><CODE><B><A HREF="../../../com/sleepycat/collections/TransactionRunner.html#TransactionRunner(com.sleepycat.db.Environment, int, com.sleepycat.db.TransactionConfig)">TransactionRunner</A></B>(<A HREF="../../../com/sleepycat/db/Environment.html" title="class in com.sleepycat.db">Environment</A> env, 195 int maxRetries, 196 <A HREF="../../../com/sleepycat/db/TransactionConfig.html" title="class in com.sleepycat.db">TransactionConfig</A> config)</CODE> 197 198<BR> 199 Creates a transaction runner for a given Berkeley DB environment and 200 with a given number of maximum retries.</TD> 201</TR> 202</TABLE> 203 204<!-- ========== METHOD SUMMARY =========== --> 205 206<A NAME="method_summary"><!-- --></A> 207<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> 208<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> 209<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2"> 210<B>Method Summary</B></FONT></TH> 211</TR> 212<TR BGCOLOR="white" CLASS="TableRowColor"> 213<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 214<CODE> boolean</CODE></FONT></TD> 215<TD><CODE><B><A HREF="../../../com/sleepycat/collections/TransactionRunner.html#getAllowNestedTransactions()">getAllowNestedTransactions</A></B>()</CODE> 216 217<BR> 218 Returns whether nested transactions will be created if 219 <code>run()</code> is called when a transaction is already active for 220 the current thread.</TD> 221</TR> 222<TR BGCOLOR="white" CLASS="TableRowColor"> 223<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 224<CODE> int</CODE></FONT></TD> 225<TD><CODE><B><A HREF="../../../com/sleepycat/collections/TransactionRunner.html#getMaxRetries()">getMaxRetries</A></B>()</CODE> 226 227<BR> 228 Returns the maximum number of retries that will be performed when 229 deadlocks are detected.</TD> 230</TR> 231<TR BGCOLOR="white" CLASS="TableRowColor"> 232<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 233<CODE> <A HREF="../../../com/sleepycat/db/TransactionConfig.html" title="class in com.sleepycat.db">TransactionConfig</A></CODE></FONT></TD> 234<TD><CODE><B><A HREF="../../../com/sleepycat/collections/TransactionRunner.html#getTransactionConfig()">getTransactionConfig</A></B>()</CODE> 235 236<BR> 237 Returns the transaction configuration used for calling 238 <A HREF="../../../com/sleepycat/db/Environment.html#beginTransaction(com.sleepycat.db.Transaction, com.sleepycat.db.TransactionConfig)"><CODE>Environment.beginTransaction(com.sleepycat.db.Transaction, com.sleepycat.db.TransactionConfig)</CODE></A>.</TD> 239</TR> 240<TR BGCOLOR="white" CLASS="TableRowColor"> 241<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 242<CODE> int</CODE></FONT></TD> 243<TD><CODE><B><A HREF="../../../com/sleepycat/collections/TransactionRunner.html#handleException(java.lang.Exception, int, int)">handleException</A></B>(<A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Exception.html?is-external=true" title="class or interface in java.lang">Exception</A> exception, 244 int retries, 245 int maxRetries)</CODE> 246 247<BR> 248 Handles exceptions that occur during a transaction, and may implement 249 transaction retry policy.</TD> 250</TR> 251<TR BGCOLOR="white" CLASS="TableRowColor"> 252<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 253<CODE> void</CODE></FONT></TD> 254<TD><CODE><B><A HREF="../../../com/sleepycat/collections/TransactionRunner.html#run(com.sleepycat.collections.TransactionWorker)">run</A></B>(<A HREF="../../../com/sleepycat/collections/TransactionWorker.html" title="interface in com.sleepycat.collections">TransactionWorker</A> worker)</CODE> 255 256<BR> 257 Calls the <A HREF="../../../com/sleepycat/collections/TransactionWorker.html#doWork()"><CODE>TransactionWorker.doWork()</CODE></A> method and, for transactional 258 environments, may begin and end a transaction.</TD> 259</TR> 260<TR BGCOLOR="white" CLASS="TableRowColor"> 261<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 262<CODE> void</CODE></FONT></TD> 263<TD><CODE><B><A HREF="../../../com/sleepycat/collections/TransactionRunner.html#setAllowNestedTransactions(boolean)">setAllowNestedTransactions</A></B>(boolean allowNestedTxn)</CODE> 264 265<BR> 266 Changes whether nested transactions will be created if 267 <code>run()</code> is called when a transaction is already active for 268 the current thread.</TD> 269</TR> 270<TR BGCOLOR="white" CLASS="TableRowColor"> 271<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 272<CODE> void</CODE></FONT></TD> 273<TD><CODE><B><A HREF="../../../com/sleepycat/collections/TransactionRunner.html#setMaxRetries(int)">setMaxRetries</A></B>(int maxRetries)</CODE> 274 275<BR> 276 Changes the maximum number of retries that will be performed when 277 deadlocks are detected.</TD> 278</TR> 279<TR BGCOLOR="white" CLASS="TableRowColor"> 280<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 281<CODE> void</CODE></FONT></TD> 282<TD><CODE><B><A HREF="../../../com/sleepycat/collections/TransactionRunner.html#setTransactionConfig(com.sleepycat.db.TransactionConfig)">setTransactionConfig</A></B>(<A HREF="../../../com/sleepycat/db/TransactionConfig.html" title="class in com.sleepycat.db">TransactionConfig</A> config)</CODE> 283 284<BR> 285 Changes the transaction configuration used for calling 286 <A HREF="../../../com/sleepycat/db/Environment.html#beginTransaction(com.sleepycat.db.Transaction, com.sleepycat.db.TransactionConfig)"><CODE>Environment.beginTransaction(com.sleepycat.db.Transaction, com.sleepycat.db.TransactionConfig)</CODE></A>.</TD> 287</TR> 288</TABLE> 289 <A NAME="methods_inherited_from_class_java.lang.Object"><!-- --></A> 290<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> 291<TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor"> 292<TH ALIGN="left"><B>Methods inherited from class java.lang.<A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</A></B></TH> 293</TR> 294<TR BGCOLOR="white" CLASS="TableRowColor"> 295<TD><CODE><A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html?is-external=true#clone()" title="class or interface in java.lang">clone</A>, <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html?is-external=true#equals(java.lang.Object)" title="class or interface in java.lang">equals</A>, <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html?is-external=true#finalize()" title="class or interface in java.lang">finalize</A>, <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html?is-external=true#getClass()" title="class or interface in java.lang">getClass</A>, <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html?is-external=true#hashCode()" title="class or interface in java.lang">hashCode</A>, <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html?is-external=true#notify()" title="class or interface in java.lang">notify</A>, <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html?is-external=true#notifyAll()" title="class or interface in java.lang">notifyAll</A>, <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html?is-external=true#toString()" title="class or interface in java.lang">toString</A>, <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html?is-external=true#wait()" title="class or interface in java.lang">wait</A>, <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html?is-external=true#wait(long)" title="class or interface in java.lang">wait</A>, <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html?is-external=true#wait(long, int)" title="class or interface in java.lang">wait</A></CODE></TD> 296</TR> 297</TABLE> 298 299<P> 300 301<!-- ============ FIELD DETAIL =========== --> 302 303<A NAME="field_detail"><!-- --></A> 304<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> 305<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> 306<TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2"> 307<B>Field Detail</B></FONT></TH> 308</TR> 309</TABLE> 310 311<A NAME="DEFAULT_MAX_RETRIES"><!-- --></A><H3> 312DEFAULT_MAX_RETRIES</H3> 313<PRE> 314public static final int <B>DEFAULT_MAX_RETRIES</B></PRE> 315<DL> 316<DD>The default maximum number of retries. 317<P> 318<DL> 319<DT><B>See Also:</B><DD><A HREF="../../../constant-values.html#com.sleepycat.collections.TransactionRunner.DEFAULT_MAX_RETRIES">Constant Field Values</A></DL> 320</DL> 321 322<!-- ========= CONSTRUCTOR DETAIL ======== --> 323 324<A NAME="constructor_detail"><!-- --></A> 325<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> 326<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> 327<TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2"> 328<B>Constructor Detail</B></FONT></TH> 329</TR> 330</TABLE> 331 332<A NAME="TransactionRunner(com.sleepycat.db.Environment)"><!-- --></A><H3> 333TransactionRunner</H3> 334<PRE> 335public <B>TransactionRunner</B>(<A HREF="../../../com/sleepycat/db/Environment.html" title="class in com.sleepycat.db">Environment</A> env)</PRE> 336<DL> 337<DD>Creates a transaction runner for a given Berkeley DB environment. 338 The default maximum number of retries (<A HREF="../../../com/sleepycat/collections/TransactionRunner.html#DEFAULT_MAX_RETRIES"><CODE>DEFAULT_MAX_RETRIES</CODE></A>) and 339 a null (default) <A HREF="../../../com/sleepycat/db/TransactionConfig.html" title="class in com.sleepycat.db"><CODE>TransactionConfig</CODE></A> will be used. 340<P> 341<DL> 342<DT><B>Parameters:</B><DD><CODE>env</CODE> - is the environment for running transactions.</DL> 343</DL> 344<HR> 345 346<A NAME="TransactionRunner(com.sleepycat.db.Environment, int, com.sleepycat.db.TransactionConfig)"><!-- --></A><H3> 347TransactionRunner</H3> 348<PRE> 349public <B>TransactionRunner</B>(<A HREF="../../../com/sleepycat/db/Environment.html" title="class in com.sleepycat.db">Environment</A> env, 350 int maxRetries, 351 <A HREF="../../../com/sleepycat/db/TransactionConfig.html" title="class in com.sleepycat.db">TransactionConfig</A> config)</PRE> 352<DL> 353<DD>Creates a transaction runner for a given Berkeley DB environment and 354 with a given number of maximum retries. 355<P> 356<DL> 357<DT><B>Parameters:</B><DD><CODE>env</CODE> - is the environment for running transactions.<DD><CODE>maxRetries</CODE> - is the maximum number of retries that will be 358 performed when deadlocks are detected.<DD><CODE>config</CODE> - the transaction configuration used for calling 359 <A HREF="../../../com/sleepycat/db/Environment.html#beginTransaction(com.sleepycat.db.Transaction, com.sleepycat.db.TransactionConfig)"><CODE>Environment.beginTransaction(com.sleepycat.db.Transaction, com.sleepycat.db.TransactionConfig)</CODE></A>, or null to use the default 360 configuration. The configuration object is not cloned, and 361 any modifications to it will impact subsequent transactions.</DL> 362</DL> 363 364<!-- ============ METHOD DETAIL ========== --> 365 366<A NAME="method_detail"><!-- --></A> 367<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> 368<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> 369<TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2"> 370<B>Method Detail</B></FONT></TH> 371</TR> 372</TABLE> 373 374<A NAME="getMaxRetries()"><!-- --></A><H3> 375getMaxRetries</H3> 376<PRE> 377public int <B>getMaxRetries</B>()</PRE> 378<DL> 379<DD>Returns the maximum number of retries that will be performed when 380 deadlocks are detected. 381<P> 382<DD><DL> 383</DL> 384</DD> 385</DL> 386<HR> 387 388<A NAME="setMaxRetries(int)"><!-- --></A><H3> 389setMaxRetries</H3> 390<PRE> 391public void <B>setMaxRetries</B>(int maxRetries)</PRE> 392<DL> 393<DD>Changes the maximum number of retries that will be performed when 394 deadlocks are detected. 395 Calling this method does not impact transactions already running. 396<P> 397<DD><DL> 398</DL> 399</DD> 400</DL> 401<HR> 402 403<A NAME="getAllowNestedTransactions()"><!-- --></A><H3> 404getAllowNestedTransactions</H3> 405<PRE> 406public boolean <B>getAllowNestedTransactions</B>()</PRE> 407<DL> 408<DD>Returns whether nested transactions will be created if 409 <code>run()</code> is called when a transaction is already active for 410 the current thread. 411 By default this property is false. 412 413 <p>Note that this method always returns false in the JE product, since 414 nested transactions are not supported by JE.</p> 415<P> 416<DD><DL> 417</DL> 418</DD> 419</DL> 420<HR> 421 422<A NAME="setAllowNestedTransactions(boolean)"><!-- --></A><H3> 423setAllowNestedTransactions</H3> 424<PRE> 425public void <B>setAllowNestedTransactions</B>(boolean allowNestedTxn)</PRE> 426<DL> 427<DD>Changes whether nested transactions will be created if 428 <code>run()</code> is called when a transaction is already active for 429 the current thread. 430 Calling this method does not impact transactions already running. 431 432 <p>Note that true may not be passed to this method in the JE product, 433 since nested transactions are not supported by JE.</p> 434<P> 435<DD><DL> 436</DL> 437</DD> 438</DL> 439<HR> 440 441<A NAME="getTransactionConfig()"><!-- --></A><H3> 442getTransactionConfig</H3> 443<PRE> 444public <A HREF="../../../com/sleepycat/db/TransactionConfig.html" title="class in com.sleepycat.db">TransactionConfig</A> <B>getTransactionConfig</B>()</PRE> 445<DL> 446<DD>Returns the transaction configuration used for calling 447 <A HREF="../../../com/sleepycat/db/Environment.html#beginTransaction(com.sleepycat.db.Transaction, com.sleepycat.db.TransactionConfig)"><CODE>Environment.beginTransaction(com.sleepycat.db.Transaction, com.sleepycat.db.TransactionConfig)</CODE></A>. 448 449 <p>If this property is null, the default configuration is used. The 450 configuration object is not cloned, and any modifications to it will 451 impact subsequent transactions.</p> 452<P> 453<DD><DL> 454 455<DT><B>Returns:</B><DD>the transaction configuration.</DL> 456</DD> 457</DL> 458<HR> 459 460<A NAME="setTransactionConfig(com.sleepycat.db.TransactionConfig)"><!-- --></A><H3> 461setTransactionConfig</H3> 462<PRE> 463public void <B>setTransactionConfig</B>(<A HREF="../../../com/sleepycat/db/TransactionConfig.html" title="class in com.sleepycat.db">TransactionConfig</A> config)</PRE> 464<DL> 465<DD>Changes the transaction configuration used for calling 466 <A HREF="../../../com/sleepycat/db/Environment.html#beginTransaction(com.sleepycat.db.Transaction, com.sleepycat.db.TransactionConfig)"><CODE>Environment.beginTransaction(com.sleepycat.db.Transaction, com.sleepycat.db.TransactionConfig)</CODE></A>. 467 468 <p>If this property is null, the default configuration is used. The 469 configuration object is not cloned, and any modifications to it will 470 impact subsequent transactions.</p> 471<P> 472<DD><DL> 473<DT><B>Parameters:</B><DD><CODE>config</CODE> - the transaction configuration.</DL> 474</DD> 475</DL> 476<HR> 477 478<A NAME="run(com.sleepycat.collections.TransactionWorker)"><!-- --></A><H3> 479run</H3> 480<PRE> 481public void <B>run</B>(<A HREF="../../../com/sleepycat/collections/TransactionWorker.html" title="interface in com.sleepycat.collections">TransactionWorker</A> worker) 482 throws <A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A>, 483 <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Exception.html?is-external=true" title="class or interface in java.lang">Exception</A></PRE> 484<DL> 485<DD>Calls the <A HREF="../../../com/sleepycat/collections/TransactionWorker.html#doWork()"><CODE>TransactionWorker.doWork()</CODE></A> method and, for transactional 486 environments, may begin and end a transaction. If the environment given 487 is non-transactional, a transaction will not be used but the doWork() 488 method will still be called. See the class description for more 489 information. 490<P> 491<DD><DL> 492 493<DT><B>Throws:</B> 494<DD><CODE><A HREF="../../../com/sleepycat/db/DeadlockException.html" title="class in com.sleepycat.db">DeadlockException</A></CODE> - when it is thrown by doWork() and the 495 maximum number of retries has occurred. The transaction will have been 496 aborted by this method. 497<DD><CODE><A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Exception.html?is-external=true" title="class or interface in java.lang">Exception</A></CODE> - when any other exception is thrown by doWork(). The 498 exception will first be unwrapped by calling <A HREF="../../../com/sleepycat/util/ExceptionUnwrapper.html#unwrap(java.lang.Exception)"><CODE>ExceptionUnwrapper.unwrap(java.lang.Exception)</CODE></A>. The transaction will have been aborted by 499 this method. 500<DD><CODE><A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></CODE></DL> 501</DD> 502</DL> 503<HR> 504 505<A NAME="handleException(java.lang.Exception, int, int)"><!-- --></A><H3> 506handleException</H3> 507<PRE> 508public int <B>handleException</B>(<A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Exception.html?is-external=true" title="class or interface in java.lang">Exception</A> exception, 509 int retries, 510 int maxRetries) 511 throws <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Exception.html?is-external=true" title="class or interface in java.lang">Exception</A></PRE> 512<DL> 513<DD>Handles exceptions that occur during a transaction, and may implement 514 transaction retry policy. The transaction is aborted by the <A HREF="../../../com/sleepycat/collections/TransactionRunner.html#run(com.sleepycat.collections.TransactionWorker)"><CODE>run</CODE></A> method before calling this method. 515 516 <p>The default implementation of this method throws the <code>exception</code> parameter if it is not an instance of <A HREF="../../../com/sleepycat/db/DeadlockException.html" title="class in com.sleepycat.db"><CODE>DeadlockException</CODE></A> and otherwise returns the <code>maxRetries</code> 517 parameter value. This method can be overridden to throw a different 518 exception or return a different number of retries. For example:</p> 519 <ul> 520 <li>This method could call <code>Thread.sleep</code> for a short interval to 521 allow other transactions to finish.</li> 522 523 <li>This method could return a different <code>maxRetries</code> value 524 depending on the <code>exception</code> that occurred.</li> 525 526 <li>This method could throw an application-defined exception when the 527 <code>retries</code> value is greater or equal to the <code>maxRetries</code> and 528 a <A HREF="../../../com/sleepycat/db/DeadlockException.html" title="class in com.sleepycat.db"><CODE>DeadlockException</CODE></A> occurs, to override the default behavior 529 which is to throw the <A HREF="../../../com/sleepycat/db/DeadlockException.html" title="class in com.sleepycat.db"><CODE>DeadlockException</CODE></A>.</li> 530 </ul> 531<P> 532<DD><DL> 533<DT><B>Parameters:</B><DD><CODE>exception</CODE> - an exception that was thrown by the <A HREF="../../../com/sleepycat/collections/TransactionWorker.html#doWork()"><CODE>TransactionWorker.doWork()</CODE></A> method or thrown when beginning or committing 534 the transaction. If the <code>retries</code> value is greater or equal to 535 <code>maxRetries</code> when this method returns normally, this exception 536 will be thrown by the <A HREF="../../../com/sleepycat/collections/TransactionRunner.html#run(com.sleepycat.collections.TransactionWorker)"><CODE>run</CODE></A> method.<DD><CODE>retries</CODE> - the current value of a counter that starts out at zero 537 and is incremented when each retry is performed.<DD><CODE>maxRetries</CODE> - the maximum retries to be performed. By default, 538 this value is set to <A HREF="../../../com/sleepycat/collections/TransactionRunner.html#getMaxRetries()"><CODE>getMaxRetries()</CODE></A>. This method may return a 539 different maximum retries value to override that default. 540<DT><B>Returns:</B><DD>the maximum number of retries to perform. The 541 default policy is to return the <code>maxRetries</code> parameter value 542 if the <code>exception</code> parameter value is an instance of <A HREF="../../../com/sleepycat/db/DeadlockException.html" title="class in com.sleepycat.db"><CODE>DeadlockException</CODE></A>. 543<DT><B>Throws:</B> 544<DD><CODE><A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Exception.html?is-external=true" title="class or interface in java.lang">Exception</A></CODE> - to cause the exception to be thrown by the <A HREF="../../../com/sleepycat/collections/TransactionRunner.html#run(com.sleepycat.collections.TransactionWorker)"><CODE>run</CODE></A> method. The default policy is to throw the <code>exception</code> 545 parameter value if it is not an instance of <A HREF="../../../com/sleepycat/db/DeadlockException.html" title="class in com.sleepycat.db"><CODE>DeadlockException</CODE></A>.<DT><B>Since:</B></DT> 546 <DD>3.4</DD> 547</DL> 548</DD> 549</DL> 550<!-- ========= END OF CLASS DATA ========= --> 551<HR> 552 553 554<!-- ======= START OF BOTTOM NAVBAR ====== --> 555<A NAME="navbar_bottom"><!-- --></A> 556<A HREF="#skip-navbar_bottom" title="Skip navigation links"></A> 557<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY=""> 558<TR> 559<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> 560<A NAME="navbar_bottom_firstrow"><!-- --></A> 561<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY=""> 562 <TR ALIGN="center" VALIGN="top"> 563 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD> 564 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD> 565 <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD> 566 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/TransactionRunner.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD> 567 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD> 568 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD> 569 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD> 570 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD> 571 </TR> 572</TABLE> 573</TD> 574<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM> 575<b>Berkeley DB</b><br><font size="-1"> version 4.8.30</font></EM> 576</TD> 577</TR> 578 579<TR> 580<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> 581 <A HREF="../../../com/sleepycat/collections/StoredValueSet.html" title="class in com.sleepycat.collections"><B>PREV CLASS</B></A> 582 <A HREF="../../../com/sleepycat/collections/TransactionWorker.html" title="interface in com.sleepycat.collections"><B>NEXT CLASS</B></A></FONT></TD> 583<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> 584 <A HREF="../../../index.html?com/sleepycat/collections/TransactionRunner.html" target="_top"><B>FRAMES</B></A> 585 <A HREF="TransactionRunner.html" target="_top"><B>NO FRAMES</B></A> 586 <SCRIPT type="text/javascript"> 587 <!-- 588 if(window==top) { 589 document.writeln('<A HREF="../../../allclasses-noframe.html"><B>All Classes</B></A>'); 590 } 591 //--> 592</SCRIPT> 593<NOSCRIPT> 594 <A HREF="../../../allclasses-noframe.html"><B>All Classes</B></A> 595</NOSCRIPT> 596 597 598</FONT></TD> 599</TR> 600<TR> 601<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> 602 SUMMARY: NESTED | <A HREF="#field_summary">FIELD</A> | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD> 603<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> 604DETAIL: <A HREF="#field_detail">FIELD</A> | <A HREF="#constructor_detail">CONSTR</A> | <A HREF="#method_detail">METHOD</A></FONT></TD> 605</TR> 606</TABLE> 607<A NAME="skip-navbar_bottom"></A> 608<!-- ======== END OF BOTTOM NAVBAR ======= --> 609 610<HR> 611<font size=1>Copyright (c) 1996-2009 Oracle. All rights reserved.</font> 612</BODY> 613</HTML> 614