org.apache.excalibur.event.impl
Class AbstractQueue

java.lang.Object
  extended byorg.apache.excalibur.event.impl.AbstractQueue
All Implemented Interfaces:
Queue, Sink, Source
Direct Known Subclasses:
DefaultQueue, FixedSizeQueue

public abstract class AbstractQueue
extends java.lang.Object
implements Queue

Provides the base functionality for the other Queue types.

Author:
Avalon Development Team

Field Summary
protected static java.lang.Object[] EMPTY_ARRAY
          An empty array used as a return value when the Queue is empty
protected  DequeueInterceptor m_interceptor
           
protected  EnqueuePredicate m_predicate
           
protected  long m_timeout
          The number of milliseconds to wait
 
Fields inherited from interface org.apache.excalibur.event.Queue
ROLE
 
Constructor Summary
AbstractQueue()
           
 
Method Summary
protected  void block(java.lang.Object lock)
          Encapsulates the logic to block the Queue for the amount of time specified by the timeout.
 int canAccept()
          Default for canAccept()
 DequeueInterceptor getDequeueInterceptor()
          Return the dequeue executable for this sink.
 EnqueuePredicate getEnqueuePredicate()
          Return the EnqueuePredicate that is already set for this Queue.
 boolean isFull()
          Check to see if the Queue is full.
 int maxSize()
          Default maxSize to -1 which is unbounded
 void setDequeueInterceptor(DequeueInterceptor executable)
          Set the dequeue executable for this sink.
 void setEnqueuePredicate(EnqueuePredicate predicate)
          Set the EnqueuePredicate to limit entries into this Queue.
 void setTimeout(long millis)
          Set the timeout for the Queue in milliseconds.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.excalibur.event.Source
dequeue, dequeue, dequeueAll, size
 
Methods inherited from interface org.apache.excalibur.event.Sink
enqueue, enqueue, prepareEnqueue, size, tryEnqueue
 

Field Detail

EMPTY_ARRAY

protected static final java.lang.Object[] EMPTY_ARRAY
An empty array used as a return value when the Queue is empty


m_timeout

protected long m_timeout
The number of milliseconds to wait


m_predicate

protected EnqueuePredicate m_predicate

m_interceptor

protected DequeueInterceptor m_interceptor
Constructor Detail

AbstractQueue

public AbstractQueue()
Method Detail

canAccept

public int canAccept()
Default for canAccept()

Specified by:
canAccept in interface Sink
Returns:
how many elements we can enqueue

maxSize

public int maxSize()
Default maxSize to -1 which is unbounded

Specified by:
maxSize in interface Sink
Returns:
the maximum number of elements

isFull

public boolean isFull()
Check to see if the Queue is full. The method uses the maxSize and size methods to determine whether the queue is full.

Specified by:
isFull in interface Sink
Returns:
true if there is no room in the Queue

setTimeout

public void setTimeout(long millis)
Set the timeout for the Queue in milliseconds. The default timeout is 0, which means that we don't wait at all.

Specified by:
setTimeout in interface Source
Parameters:
millis - The number of milliseconds to block waiting for events to be enqueued

block

protected void block(java.lang.Object lock)
Encapsulates the logic to block the Queue for the amount of time specified by the timeout.

Parameters:
lock - The object used as the mutex.

setEnqueuePredicate

public void setEnqueuePredicate(EnqueuePredicate predicate)
Set the EnqueuePredicate to limit entries into this Queue.

Specified by:
setEnqueuePredicate in interface Queue
Parameters:
predicate - the enqueue predicate for this sink

getEnqueuePredicate

public EnqueuePredicate getEnqueuePredicate()
Return the EnqueuePredicate that is already set for this Queue.

Specified by:
getEnqueuePredicate in interface Queue
Returns:
EnqueuePredicate the enqueue predicate for this sink.

setDequeueInterceptor

public void setDequeueInterceptor(DequeueInterceptor executable)
Set the dequeue executable for this sink. This mechanism allows users to define a methods that will be executed before or after dequeuing elements from a source

Specified by:
setDequeueInterceptor in interface Queue
Parameters:
executable - The dequeue executable for this sink.
Since:
Sep 23, 2002

getDequeueInterceptor

public DequeueInterceptor getDequeueInterceptor()
Return the dequeue executable for this sink.

Specified by:
getDequeueInterceptor in interface Queue
Returns:
DequeueInterceptor The dequeue executable for this sink.
Since:
Sep 23, 2002


Copyright © 1997-2005 The Apache Software Foundation. All Rights Reserved.