org.objectweb.dream.queue.keyed
Class BufferKeyChunkAddKeyedRemoveImpl

java.lang.Object
  extended by org.objectweb.dream.AbstractComponent
      extended by org.objectweb.dream.queue.keyed.AbstractBufferKeyedRemoveImpl
          extended by org.objectweb.dream.queue.keyed.BufferKeyChunkAddKeyedRemoveImpl
All Implemented Interfaces:
ContextualBindingController, NeedAsyncStartController, PrepareStopLifeCycleController, Loggable, BufferAdd, BufferAttributeController, BufferAttributeControllerKeyChunkAdd, KeyedBufferRemove, AttributeController, BindingController, LifeCycleController

public class BufferKeyChunkAddKeyedRemoveImpl
extends AbstractBufferKeyedRemoveImpl
implements BufferAttributeControllerKeyChunkAdd

This buffer stores every incoming message according to a key that is contained in the message as a chunk which name can be specified as a Fractal component attribute using the interface of type BufferAttributeControllerKeyChunkAdd. The doRemove(Object) method removes the message with the specified key.


Field Summary
protected  String keyChunkName
           
protected  TreeMap<AbstractChunk,LinkedList<Message>> queue
          Used to sort the messages according to the key that is a chunk in every message added to this buffer.
 
Fields inherited from class org.objectweb.dream.queue.keyed.AbstractBufferKeyedRemoveImpl
availableMessagesCount, CLIENT_INTERFACE_NAMES, lock, maxCapacity, messageManagerItf, storedMessagesCount
 
Fields inherited from class org.objectweb.dream.AbstractComponent
bindingLogger, fcNeedAsyncStart, fcState, lifeCycleLogger, logger, weaveableC
 
Fields inherited from interface org.objectweb.dream.queue.BufferAdd
ITF_NAME
 
Fields inherited from interface org.objectweb.dream.queue.keyed.KeyedBufferRemove
ITF_NAME
 
Fields inherited from interface org.objectweb.fractal.api.control.LifeCycleController
STARTED, STOPPED
 
Constructor Summary
BufferKeyChunkAddKeyedRemoveImpl()
           
 
Method Summary
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(Object key)
          Gets a message from the buffer.
protected  Message doRemove(Object key)
          Removes a message from the buffer.
protected  Message doRemoveAll()
          Removes all the messages stored into the buffer.
 String getKeyChunkName()
          Returns the name of the chunk that is used as a key.
 void setKeyChunkName(String keyChunkName)
          Sets the name of the chunk that is used as a key.
 
Methods inherited from class org.objectweb.dream.queue.keyed.AbstractBufferKeyedRemoveImpl
add, availableSpace, bindFc, get, getCurrentSize, getMaxCapacity, hasAvailableMessage, incrementAvailableMessagesCount, incrementStoredMessagesCount, listFc, remove, removeAll, setMaxCapacity, tryAdd, tryGet, tryRemove
 
Methods inherited from class org.objectweb.dream.AbstractComponent
beforeFirstStart, bindFc, getFcNeedAsyncStart, getFcState, initComponent, lookupFc, prepareStopFc, 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.BufferAttributeController
getCurrentSize, getMaxCapacity, setMaxCapacity
 

Field Detail

keyChunkName

protected String keyChunkName

queue

protected TreeMap<AbstractChunk,LinkedList<Message>> queue
Used to sort the messages according to the key that is a chunk in every message added to this buffer.

Constructor Detail

BufferKeyChunkAddKeyedRemoveImpl

public BufferKeyChunkAddKeyedRemoveImpl()
Method Detail

doAdd

protected void doAdd(Message message)
Description copied from class: AbstractBufferKeyedRemoveImpl
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 AbstractBufferKeyedRemoveImpl.add(org.objectweb.dream.message.Message)method. The lockhas been acquired when this method is called.

Specified by:
doAdd in class AbstractBufferKeyedRemoveImpl
Parameters:
message - the message to be added.

doRemove

protected Message doRemove(Object key)
Description copied from class: AbstractBufferKeyedRemoveImpl
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 AbstractBufferKeyedRemoveImpl.remove(java.lang.Object)method. The lockhas been acquired when this method is called.

Specified by:
doRemove in class AbstractBufferKeyedRemoveImpl
Returns:
a message.

doGet

protected Message doGet(Object key)
Description copied from class: AbstractBufferKeyedRemoveImpl
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 AbstractBufferKeyedRemoveImpl.get(java.lang.Object) method. The lockhas been acquired when this method is called.

Specified by:
doGet in class AbstractBufferKeyedRemoveImpl
Returns:
a message.

doRemoveAll

protected Message doRemoveAll()
Description copied from class: AbstractBufferKeyedRemoveImpl
Removes all the messages stored into the buffer. The lockhas been acquired when this method is called.

Specified by:
doRemoveAll in class AbstractBufferKeyedRemoveImpl
Returns:
an aggregated message.

canAdd

protected boolean canAdd(Message message)
Description copied from class: AbstractBufferKeyedRemoveImpl
Checks whether the given message can be added into the buffer. The lockhas been acquired when this method is called.

Overrides:
canAdd in class AbstractBufferKeyedRemoveImpl
Parameters:
message - the message to be tested.
Returns:
true if the message can be added.

setKeyChunkName

public void setKeyChunkName(String keyChunkName)
Description copied from interface: BufferAttributeControllerKeyChunkAdd
Sets the name of the chunk that is used as a key.

Specified by:
setKeyChunkName in interface BufferAttributeControllerKeyChunkAdd
Parameters:
keyChunkName - the name of the chunk.
See Also:
BufferAttributeControllerKeyChunkAdd.setKeyChunkName(String)

getKeyChunkName

public String getKeyChunkName()
Description copied from interface: BufferAttributeControllerKeyChunkAdd
Returns the name of the chunk that is used as a key.

Specified by:
getKeyChunkName in interface BufferAttributeControllerKeyChunkAdd
Returns:
the name of the chunk that is used as a key.
See Also:
BufferAttributeControllerKeyChunkAdd.getKeyChunkName()


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