com.waveset.adapter
Class DblBufIterator

java.lang.Object
  extended bycom.waveset.adapter.DblBufIterator
All Implemented Interfaces:
java.lang.Runnable
Direct Known Subclasses:
DblBufAcctIter, DblBufObjectIter

Deprecated. This implementation is deprecated in favor of a new implementation please look at the JavaDoc for Supplier, DoubleBufferQueue, and BufferedAccountQueue. These classes effectively separate the concerns of DblBufIterator into a chain of responsiblity. For instance Supplier replaces the responsiblity of subFillArray. DobuleBufferQueue replaces the buffering aspect. BufferedAccountQueue converts the java Iterator interface to the AccountIterator interface required by the ResourceAdapter interface.

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

The DblBufIterator class is an abstract base class to provide a double buffering scheme for an account iterator. All the subclass needs to provide is a way to fill an array with users (subFillArray() method) and a way to handle a close in the middle (subClose() method).

Below is a basic description of how the double buffering works.

When instantiated, the first block of users is loaded. A thread is then started that loads the next block of users. It then waits for the the first block of users to be retrieved through calls to getNext(). Once all of the users in the first block are retrieved, additional calls to get next will retrieve users from the second block. Meanwhile, the thread will fill up the first block with additional users.

Synchronization of the thread getting the users from the LDAP server (the producer) and the thread calling getNext() (the consumer) is done using Java's built in locking mechanisms on the 2 ArrayList instances containing the users. When the producer finishes filling up an ArrayList it does a notify on it. It then tries to get a lock on the other ArrayList. Once it does, it checks to see if it is empty. If it is not, it waits on the the ArrayList's lock. The consumer thread will do a notify when it finishes with that ArrayList and clears it. This will wake up the producer. If the array was empty when the producer checked it, it will proceed to fill it while maintaining the lock on the ArrayList. When the consumer attempts to access an ArrayList it waits until it can get a lock on it. If it contains any entries, then it gets one off the list and returns it. If there are no entries, it waits on the ArrayList (this gives the producer control, if it is waiting for the lock).

See Also:
Supplier, BufferedAccountQueue

Field Summary
protected static Trace _trace
          Deprecated.  
static java.lang.String code_id
          Deprecated.  
 
Constructor Summary
DblBufIterator(int blockSize)
          Deprecated.  
 
Method Summary
 void close()
          Deprecated.  
protected  void finalize()
          Deprecated.  
protected  int getCurrentArray()
          Deprecated.  
protected  java.lang.Exception getError()
          Deprecated.  
 int getFillArray()
          Deprecated.  
protected  int getNextArray(int array)
          Deprecated.  
protected  int getNextIndex()
          Deprecated.  
protected  boolean hasError()
          Deprecated.  
 boolean hasNext()
          Deprecated.  
protected  boolean isDone()
          Deprecated.  
protected  boolean isRun()
          Deprecated.  
 java.lang.Object nextObject()
          Deprecated. Implements the functionality that corresponds to the next() method a normal iterator-type class/interface, but we'd like the classes that derive from this one to be able to have an class-specific version of next(), i.e.
protected  void notifyArrays()
          Deprecated.  
 void run()
          Deprecated.  
protected  void setCurrentArray(int currentArray)
          Deprecated.  
protected  void setDone(boolean done)
          Deprecated.  
protected  void setError(java.lang.Exception error)
          Deprecated.  
protected  void setRun(boolean run)
          Deprecated.  
protected  void start()
          Deprecated.  
protected abstract  void subClose()
          Deprecated.  
protected abstract  void subFillArray(java.util.ArrayList arrayList)
          Deprecated.  
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

code_id

public static final java.lang.String code_id
Deprecated. 
See Also:
Constant Field Values

_trace

protected static Trace _trace
Deprecated. 
Constructor Detail

DblBufIterator

public DblBufIterator(int blockSize)
               throws WavesetException
Deprecated. 
Method Detail

start

protected void start()
              throws WavesetException
Deprecated. 
Throws:
WavesetException

finalize

protected void finalize()
                 throws java.lang.Throwable
Deprecated. 
Throws:
java.lang.Throwable

getNextArray

protected int getNextArray(int array)
Deprecated. 

getFillArray

public int getFillArray()
Deprecated. 

isDone

protected boolean isDone()
Deprecated. 

setDone

protected void setDone(boolean done)
Deprecated. 

setRun

protected void setRun(boolean run)
Deprecated. 

isRun

protected boolean isRun()
Deprecated. 

setError

protected void setError(java.lang.Exception error)
Deprecated. 

hasError

protected boolean hasError()
Deprecated. 

getError

protected java.lang.Exception getError()
Deprecated. 

getCurrentArray

protected int getCurrentArray()
Deprecated. 

setCurrentArray

protected void setCurrentArray(int currentArray)
Deprecated. 

notifyArrays

protected void notifyArrays()
Deprecated. 

run

public void run()
Deprecated. 
Specified by:
run in interface java.lang.Runnable

subFillArray

protected abstract void subFillArray(java.util.ArrayList arrayList)
                              throws java.lang.Exception
Deprecated. 
Throws:
java.lang.Exception

subClose

protected abstract void subClose()
Deprecated. 

close

public void close()
Deprecated. 

getNextIndex

protected int getNextIndex()
                    throws WavesetException
Deprecated. 
Throws:
WavesetException

hasNext

public boolean hasNext()
                throws WavesetException
Deprecated. 
Throws:
WavesetException

nextObject

public java.lang.Object nextObject()
                            throws java.util.NoSuchElementException,
                                   WavesetException
Deprecated. 
Implements the functionality that corresponds to the next() method a normal iterator-type class/interface, but we'd like the classes that derive from this one to be able to have an class-specific version of next(), i.e. WSUser next() { return (WSUser)getNextObject(); } So we call this nextObject() to void ambiguity.

Throws:
java.util.NoSuchElementException
WavesetException