org.objectweb.dream.queue
Class BufferAscendingSequenceNumberImpl

java.lang.Object
  extended byorg.objectweb.dream.AbstractComponent
      extended byorg.objectweb.dream.queue.AbstractBufferImpl
          extended byorg.objectweb.dream.queue.BufferAscendingSequenceNumberImpl
All Implemented Interfaces:
AttributeController, BindingController, Buffer, BufferAddFirstLast, BufferRemoveFirstLast, LifeCycleController, Loggable, QueueAttributeController, QueueSortedAttributeController

public class BufferAscendingSequenceNumberImpl
extends AbstractBufferImpl
implements QueueSortedAttributeController

Implementation of the Buffer interface using a sorted list. This buffer sorts messages according to a sequence number. For that purpose all messages must contain a SequenceNumberChunkchunk. The name under which this chunk is registered is specified using the QueueSortedAttributeController.

This buffer guarantees that if message m1 (with sequence number sn ) is removed from the buffer, then next message to be removed will have sequence number sn+1 . As a consequence, the number of available message may be different from the number of stored messages.

Note: This buffer DOES NOT ALLOW overflow policies that drop messages. Indicators on available space, available messages, and stored messages are expressed as number of messages.

See Also:
Buffer, @

Nested Class Summary
static class BufferAscendingSequenceNumberImpl.Element
          This class represents elements of a linked list.
 
Field Summary
protected  BufferAscendingSequenceNumberImpl.Element first
          The first element stored in this buffer.
protected  BufferAscendingSequenceNumberImpl.Element last
          The last element stored in this buffer.
protected  long lastInSequence
          The last sequence number in sequence.
protected  ObjectPool objectPoolItf
          The client interface used to access the pool of BufferAscendingSequenceNumberImpl.Elementinstances.
protected  String sortingChunkName
          The name under which the chunk containing the sequence number is registered.
 
Fields inherited from class org.objectweb.dream.queue.AbstractBufferImpl
availableMessagesIndicator, lock, maxCapacity, messageManagerItf, storedMessagesIndicator
 
Fields inherited from class org.objectweb.dream.AbstractComponent
bindingLogger, componentDesc, fcState, firstStart, lifeCycleLogger, logger, weaveableC
 
Fields inherited from interface org.objectweb.dream.queue.Buffer
ITF_NAME
 
Fields inherited from interface org.objectweb.dream.queue.BufferAddFirstLast
ITF_NAME
 
Fields inherited from interface org.objectweb.dream.queue.BufferRemoveFirstLast
ITF_NAME
 
Fields inherited from interface org.objectweb.fractal.api.control.LifeCycleController
STARTED, STOPPED
 
Constructor Summary
BufferAscendingSequenceNumberImpl()
           
 
Method Summary
 void bindFc(String clientItfName, Object serverItf)
           
protected  boolean canAdd(Message message)
          Checks whether the given message can be added into the buffer.
protected  void doAdd(Message message)
          Adds a message to the buffer.
protected  Message doGet()
          Gets a message from the buffer.
protected  Message doRemove()
          Removes a message from the buffer.
 String getSortingChunkName()
          Returns the name of the chunk to be used to sort messages.
protected  boolean hasAvailableMessage()
          Checks whether there is an available message.
 String[] listFc()
           
 void setSortingChunkName(String name)
          Sets the name of the chunk to be used to sort messages.
 
Methods inherited from class org.objectweb.dream.queue.AbstractBufferImpl
add, addFirst, addLast, availableMessagesIndicator, availableSpaceIndicator, doAddFirst, doAddLast, doGetFirst, doGetLast, doRemoveFirst, doRemoveLast, get, getCurrentSize, getFirst, getLast, getMaxCapacity, incrementAvailableMessagesIndicator, incrementStoredMessagesIndicator, remove, removeFirst, removeLast, setMaxCapacity, storedMessagesIndicator
 
Methods inherited from class org.objectweb.dream.AbstractComponent
beforeFirstStart, getFcState, initComponent, lookupFc, setLogger, startFc, stopFc, unbindFc
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.objectweb.dream.queue.QueueAttributeController
getCurrentSize, getMaxCapacity, setMaxCapacity
 

Field Detail

sortingChunkName

protected String sortingChunkName
The name under which the chunk containing the sequence number is registered.


first

protected BufferAscendingSequenceNumberImpl.Element first
The first element stored in this buffer.


last

protected BufferAscendingSequenceNumberImpl.Element last
The last element stored in this buffer.


objectPoolItf

protected ObjectPool objectPoolItf
The client interface used to access the pool of BufferAscendingSequenceNumberImpl.Elementinstances.


lastInSequence

protected long lastInSequence
The last sequence number in sequence.

Constructor Detail

BufferAscendingSequenceNumberImpl

public BufferAscendingSequenceNumberImpl()
Method Detail

hasAvailableMessage

protected boolean hasAvailableMessage()
Description copied from class: AbstractBufferImpl
Checks whether there is an available message.

Specified by:
hasAvailableMessage in class AbstractBufferImpl
Returns:
true if there is an available message.
See Also:
AbstractBufferImpl.hasAvailableMessage()

canAdd

protected boolean canAdd(Message message)
Description copied from class: AbstractBufferImpl
Checks whether the given message can be added into the buffer.

Specified by:
canAdd in class AbstractBufferImpl
Parameters:
message - the message to be tested.
Returns:
true if the message can be added.
See Also:
AbstractBufferImpl.canAdd(org.objectweb.dream.message.Message)

doAdd

protected void doAdd(Message message)
Description copied from class: AbstractBufferImpl
Adds a message to the buffer. This method should not check if there is enough available space provided it has already been done in the AbstractBufferImpl.add(org.objectweb.dream.message.Message)method.

Specified by:
doAdd in class AbstractBufferImpl
Parameters:
message - the message to be added.
See Also:
AbstractBufferImpl.doAdd(org.objectweb.dream.message.Message)

doRemove

protected Message doRemove()
Description copied from class: AbstractBufferImpl
Removes a message from the buffer. This method should not check if there is a message available provided it has already been done in the AbstractBufferImpl.remove()method.

Specified by:
doRemove in class AbstractBufferImpl
Returns:
a message.
See Also:
AbstractBufferImpl.doRemove()

doGet

protected Message doGet()
Description copied from class: AbstractBufferImpl
Gets a message from the buffer. This method should not check if there is a message available provided it has already been done in the AbstractBufferImpl.remove() method.

Specified by:
doGet in class AbstractBufferImpl
Returns:
a message.
See Also:
AbstractBufferImpl.doGet()

getSortingChunkName

public String getSortingChunkName()
Description copied from interface: QueueSortedAttributeController
Returns the name of the chunk to be used to sort messages.

Specified by:
getSortingChunkName in interface QueueSortedAttributeController
Returns:
the name of the chunk to be used to sort messages.
See Also:
QueueSortedAttributeController.getSortingChunkName()

setSortingChunkName

public void setSortingChunkName(String name)
Description copied from interface: QueueSortedAttributeController
Sets the name of the chunk to be used to sort messages.

Specified by:
setSortingChunkName in interface QueueSortedAttributeController
Parameters:
name - the name of the chunk to be used to sort messages.
See Also:
QueueSortedAttributeController.setSortingChunkName(String)

bindFc

public void bindFc(String clientItfName,
                   Object serverItf)
            throws NoSuchInterfaceException,
                   IllegalBindingException,
                   IllegalLifeCycleException
Specified by:
bindFc in interface BindingController
Overrides:
bindFc in class AbstractBufferImpl
Throws:
NoSuchInterfaceException
IllegalBindingException
IllegalLifeCycleException
See Also:
BindingController.bindFc(String, Object)

listFc

public String[] listFc()
Specified by:
listFc in interface BindingController
Overrides:
listFc in class AbstractBufferImpl
See Also:
BindingController.listFc()


Copyright © 2003, 2004 - INRIA Rhone-Alpes - All Rights Reserved.