com.sun.sgs.impl.util
Class ManagedQueue<E>

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractQueue<E>
          extended by com.sun.sgs.impl.util.ManagedQueue<E>
Type Parameters:
E - the type for elements in the queue TODO: The element type should not be required to be a managed object, but should just be serializable. Should it handle both?
All Implemented Interfaces:
ManagedObject, ManagedObjectRemoval, Serializable, Iterable<E>, Collection<E>, Queue<E>

public class ManagedQueue<E>
extends AbstractQueue<E>
implements Serializable, ManagedObjectRemoval

A simple implementation of a persistent queue. When an element is removed from the queue, that element is also removed from the data store.

Note: The size and iterator methods are not supported.

Note: If a given instance of ManagedQueue contains a large number of elements, invoking the clear method on the queue may be a lengthy operation. Therefore, the queue should either contain a smaller number of elements, or elements should be removed from the queue a few at at time.

See Also:
Serialized Form

Constructor Summary
ManagedQueue()
           
 
Method Summary
 boolean equals(Object o)
          
 int hashCode()
          
 boolean isEmpty()
          
 Iterator<E> iterator()
          
 boolean offer(E o)
          
 E peek()
          
 E poll()
          
 void removingObject()
          Performs additional operations that are needed when this object is removed.
 int size()
          
 String toString()
          
 
Methods inherited from class java.util.AbstractQueue
add, addAll, clear, element, remove
 
Methods inherited from class java.util.AbstractCollection
contains, containsAll, remove, removeAll, retainAll, toArray, toArray
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Collection
contains, containsAll, remove, removeAll, retainAll, toArray, toArray
 

Constructor Detail

ManagedQueue

public ManagedQueue()
Method Detail

offer

public boolean offer(E o)

Specified by:
offer in interface Queue<E>

peek

public E peek()

Specified by:
peek in interface Queue<E>

poll

public E poll()

Specified by:
poll in interface Queue<E>

size

public int size()

This method is not supported.

Specified by:
size in interface Collection<E>
Specified by:
size in class AbstractCollection<E>

isEmpty

public boolean isEmpty()

Specified by:
isEmpty in interface Collection<E>
Overrides:
isEmpty in class AbstractCollection<E>

iterator

public Iterator<E> iterator()

This method is not supported.

Specified by:
iterator in interface Iterable<E>
Specified by:
iterator in interface Collection<E>
Specified by:
iterator in class AbstractCollection<E>

hashCode

public int hashCode()

Specified by:
hashCode in interface Collection<E>
Overrides:
hashCode in class Object

equals

public boolean equals(Object o)

Specified by:
equals in interface Collection<E>
Overrides:
equals in class Object

toString

public String toString()

Overrides:
toString in class AbstractCollection<E>

removingObject

public void removingObject()
Performs additional operations that are needed when this object is removed.

This implementation clears all elements from the queue, thus removing all elements from the data store. TODO: For queues with a large number of elements, removing the enqueued elements should be performed in a separate task (or tasks).

Specified by:
removingObject in interface ManagedObjectRemoval

RedDwarf, Version 0.10.1
2010-03-14 10:56:12

Copyright © 2010 The RedDwarf Authors. All rights reserved
Copyright © 2007-2010 Sun Microsystems, Inc. All rights reserved