org.opensubsystems.patterns.listdata.util
Class AsyncDataLoaderRunnable

java.lang.Object
  extended by org.opensubsystems.patterns.listdata.util.AsyncDataLoaderRunnable
All Implemented Interfaces:
java.lang.Runnable

public abstract class AsyncDataLoaderRunnable
extends java.lang.Object
implements java.lang.Runnable

New Runnable object which allows to process multiple items at the same time. The processor of the data has to specify it's version (status). If the version changes before or while the processing of the data is in progress the processing will stop.

Version:
$Id: AsyncDataLoaderRunnable.java,v 1.3 2007/01/07 06:14:15 bastafidli Exp $
Author:
Miro Halas
Code reviewer:
Miro Halas
Code reviewed:
Initial revision

Field Summary
protected  int m_iOriginalObjectVersion
          Value uniquely identifying the original state of the object by which the data should be processed.
protected  java.util.List m_lstData
          List of data which should be added to the table
 
Constructor Summary
AsyncDataLoaderRunnable(java.util.List lstData, int iOriginalObjectVersion)
          Constructor
 
Method Summary
protected abstract  int getCurrentObjectVersion()
          This method has to be overriden to return the actual value of the version for object, which is processing the data.
protected abstract  void processItem(org.opensubsystems.core.data.DataObject dataToProcess)
          Process new item from the list.
 void run()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_iOriginalObjectVersion

protected int m_iOriginalObjectVersion
Value uniquely identifying the original state of the object by which the data should be processed. This can identify if the object changes and data cannot/shouldn't be added anymore.


m_lstData

protected java.util.List m_lstData
List of data which should be added to the table

Constructor Detail

AsyncDataLoaderRunnable

public AsyncDataLoaderRunnable(java.util.List lstData,
                               int iOriginalObjectVersion)
Constructor

Parameters:
lstData - - list with already loaded data
iOriginalObjectVersion - - version of the object by which the data should be processed. If the version of the object at the time when the data are being processed is different from this version, then the data will not be processed or the processing of the data stops.
Method Detail

run

public final void run()

Specified by:
run in interface java.lang.Runnable

processItem

protected abstract void processItem(org.opensubsystems.core.data.DataObject dataToProcess)
Process new item from the list. This method cannot be abstract so that we can do the in place overriding of the class.

Parameters:
dataToProcess - - data item to process

getCurrentObjectVersion

protected abstract int getCurrentObjectVersion()
This method has to be overriden to return the actual value of the version for object, which is processing the data. If the current version of the object will not match the version for which this runnable was constructed then the processing will stop.

Returns:
int


Copyright © 2003 - 2006 OpenSubsystems s.r.o.