SQLJet Home

org.tmatesoft.sqljet.core.table
Class SqlJetDefaultBusyHandler

java.lang.Object
  extended by org.tmatesoft.sqljet.core.table.SqlJetDefaultBusyHandler
All Implemented Interfaces:
ISqlJetBusyHandler

public class SqlJetDefaultBusyHandler
extends java.lang.Object
implements ISqlJetBusyHandler

Implementation of SQLJet busy handlers. Used by default in SqlJetDb.

Performs some number of retries (by default 10 or SQLJET_BUSY_RETRIES system property value) per every time interval (by default 100 milliseconds or SQLJET_BUSY_SLEEP system property value in milliseconds).

Author:
TMate Software Ltd., Sergey Scherbina (sergey.scherbina@gmail.com)

Field Summary
static java.lang.String SQLJET_BUSY_RETRIES_PROPERTY
          Name of system property which defines retries count by default.
static java.lang.String SQLJET_BUSY_SLEEP_PROPERTY
          Name of system property which defines time wait by default.
 
Constructor Summary
SqlJetDefaultBusyHandler()
          Creates busy handler with default parameters.
SqlJetDefaultBusyHandler(int retries, int sleep)
          Creates busy handler with custom parameters.
 
Method Summary
 boolean call(int number)
           Callback which implements busy handler.
 int getRetries()
          Returns number of attempts to make to lock database.
 int getSleep()
          Returns sleep time interval in milliseconds between retries to lock database.
 boolean isCancel()
          Check is busy handler to cancel.
 void setCancel(boolean cancel)
          Allow cancel urgently busy retries.
 void setRetries(int retries)
          Sets number of attempts to make to lock database.
 void setSleep(int sleep)
          Sets sleep time interval in milliseconds between retries to lock database.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SQLJET_BUSY_RETRIES_PROPERTY

public static final java.lang.String SQLJET_BUSY_RETRIES_PROPERTY
Name of system property which defines retries count by default.

See Also:
Constant Field Values

SQLJET_BUSY_SLEEP_PROPERTY

public static final java.lang.String SQLJET_BUSY_SLEEP_PROPERTY
Name of system property which defines time wait by default.

See Also:
Constant Field Values
Constructor Detail

SqlJetDefaultBusyHandler

public SqlJetDefaultBusyHandler()
Creates busy handler with default parameters.


SqlJetDefaultBusyHandler

public SqlJetDefaultBusyHandler(int retries,
                                int sleep)
Creates busy handler with custom parameters.

Parameters:
retries - number of retries to perform
sleep - sleep time interval in milliseconds between retries to lock database.
Method Detail

getRetries

public int getRetries()
Returns number of attempts to make to lock database.

Returns:
number of attempts.

setRetries

public void setRetries(int retries)
Sets number of attempts to make to lock database.

Parameters:
retries - number of attempts.

getSleep

public int getSleep()
Returns sleep time interval in milliseconds between retries to lock database.

Returns:
sleep interval time in milliseconds.

setSleep

public void setSleep(int sleep)
Sets sleep time interval in milliseconds between retries to lock database.

Parameters:
sleep - interval time in milliseconds.

setCancel

public void setCancel(boolean cancel)
Allow cancel urgently busy retries. To cancel set it to true - in this case busy handler will not wait in next retry.

Parameters:
cancel - if true then busy handler will not wait.

isCancel

public boolean isCancel()
Check is busy handler to cancel.

Returns:
true if lock attempts should be cancelled.

call

public boolean call(int number)
Description copied from interface: ISqlJetBusyHandler

Callback which implements busy handler.

To method call() is passed number of retry to obtain database lock. If call() returns true then retries to locking still continue. If call() returns false then will be thrown SqlJetException with SqlJetErrorCode.BUSY.

Specified by:
call in interface ISqlJetBusyHandler
Parameters:
number - number of retry to obtain lock on database.
Returns:
true if retries will continue or false if retries will stop.

SQLJet Home

Copyright © 2009-2010 TMate Software Ltd. All Rights Reserved.