Last update: 2011-06-23

org.proteios.core
Class AbstractBatcher

java.lang.Object
  extended by org.proteios.core.AbstractBatcher
All Implemented Interfaces:
Batcher
Direct Known Subclasses:
BasicBatcher

public abstract class AbstractBatcher
extends Object
implements Batcher

This is an abstract class for batchers that are connected to a single DbControl object. It implements all methods in the Batcher interface except the Batcher.flush() method.

A subclass may also have to override the close() method if it has opened connections or statements to the database.

Version:
2.0
Author:
Nicklas
Last modified
$Date: 2009-04-09 08:48:11 +0200 (Thu, 09 Apr 2009) $

Method Summary
 void close()
          Flush the batcher and close it.
 int getBatchSize()
          Get the current batch size of the batcher.
 DbControl getDbControl()
          Get the DbControl object that currently manages this batcher.
 SessionControl getSessionControl()
          Get the SessionControl object that manages this item.
 boolean isClosed()
          Check if this batcher is closed or not.
 void setBatchSize(int batchSize)
          Sets the batch size.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.proteios.core.Batcher
flush
 

Method Detail

getBatchSize

public int getBatchSize()
Description copied from interface: Batcher
Get the current batch size of the batcher. The batch size indicates how many individual items a batcher is caching in memory before they are automatically flushed to the database.

Specified by:
getBatchSize in interface Batcher
Returns:
The current batch size, or 0 if automatic flushing is turned of

setBatchSize

public void setBatchSize(int batchSize)
Description copied from interface: Batcher
Sets the batch size. The batch size indicates how many individual items a batcher is caching in memory before they are automatically flushed to the database.

Specified by:
setBatchSize in interface Batcher
Parameters:
batchSize - Size of the batch, or 0 to disable automatic flushing

isClosed

public final boolean isClosed()
Check if this batcher is closed or not. The batcher is considered as closed when it isn't attached to a DbControl or if the DbControl it is attached to has been closed.

Specified by:
isClosed in interface Batcher
Returns:
TRUE if the batcher is closed, FALSE otherwise
See Also:
Batcher.close()

close

public final void close()
                 throws BaseException
Description copied from interface: Batcher
Flush the batcher and close it. A closed batcher will not accept any more data for insert, update or delete. Note! A batcher that uses an underlying DbControl to connect to the database will automatically be closed when the DbControl is closed.

Specified by:
close in interface Batcher
Throws:
BaseException - If there is an error
See Also:
Batcher.isClosed(), Batcher.flush()

getDbControl

public final DbControl getDbControl()
                             throws ConnectionClosedException
Get the DbControl object that currently manages this batcher.

Throws:
ConnectionClosedException - If the batcher is connected to a closed DbControl object, or not connected at all

getSessionControl

public final SessionControl getSessionControl()
                                       throws ConnectionClosedException
Get the SessionControl object that manages this item.

Throws:
ConnectionClosedException - If the item is connected to a closed DbControl object, or not connected at all

Last update: 2011-06-23