|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.objectweb.dream.AbstractComponent
org.objectweb.dream.queue.AbstractBufferImpl
Abstract implementation of a buffer. It implements
PushQueueAttributeController
,Buffer
,
BufferAddFirstLast
, and BufferRemoveFirstLast
interfaces.
Implementations of add
, and remove
methods
(and their variants: addFirst
,addLast
,
removeFirst
,removeLast
,
getFirst
, and getLast
) are implemented as
follows
add
method checks for available space and then calls
the doAdd
method to add the message to the buffer.remove
method checks for available messages and then
calls the doRemove
method to remove a message from the buffer.
Buffer developers can inherit this class. They must implement several methods:
canAdd(message)
returns a boolean indicating whether the
given message can be added into the buffer.doAdd(message)
adds the given message into the buffer.
hasAvailableMessage()
returns a boolean indicating
whether there is an available message.doRemove()
removes a message from the buffer.
Moreover developers must use the
incrementAvailableMessagesIndicator
and
incrementStoredMessagesIndicator
methods to increment
indicators on stored messages, available messages and available space.
Note: the add
,remove
,
addFirst
,addLast
,removeFirst
,
removeLast
,getFirst
, and
getLast
methods should not be overriden.
Field Summary | |
protected int |
availableMessagesIndicator
An indicator on available messages into the buffer. |
protected Object |
lock
A lock object. |
protected int |
maxCapacity
The maximal capacity of the buffer. |
protected MessageManager |
messageManagerItf
The MessageManager client interface. |
protected int |
storedMessagesIndicator
An indicator on stored messages into the buffer. |
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 | |
AbstractBufferImpl()
|
Method Summary | |
void |
add(Message message)
This method should not be overriden. |
void |
addFirst(Message message)
Inserts the given message at the beginning of this buffer. |
void |
addLast(Message message)
Inserts the given message at the end of this buffer. |
int |
availableMessagesIndicator()
Returns an indicator on available messages. |
int |
availableSpaceIndicator()
Returns an indicator on available space. |
void |
bindFc(String clientItfName,
Object serverItf)
|
protected abstract boolean |
canAdd(Message message)
Checks whether the given message can be added into the buffer. |
protected abstract void |
doAdd(Message message)
Adds a message to the buffer. |
protected void |
doAddFirst(Message message)
Adds a message to the beginning of the buffer. |
protected void |
doAddLast(Message message)
Adds a message to end of the buffer. |
protected abstract Message |
doGet()
Gets a message from the buffer. |
protected Message |
doGetFirst()
Gets the first message from the buffer. |
protected Message |
doGetLast()
Gets the last message from the buffer. |
protected abstract Message |
doRemove()
Removes a message from the buffer. |
protected Message |
doRemoveFirst()
Removes the first message from the buffer. |
protected Message |
doRemoveLast()
Removes the last message from the buffer. |
Message |
get()
This method should not be overriden. |
int |
getCurrentSize()
Returns the current size of the queue. |
Message |
getFirst()
Returns the first message in this buffer. |
Message |
getLast()
Returns the last message in this buffer. |
int |
getMaxCapacity()
Returns the maximum capacity of the queue. |
protected abstract boolean |
hasAvailableMessage()
Checks whether there is an available message. |
protected void |
incrementAvailableMessagesIndicator(int delta)
Increments the indicator on available messages. |
protected void |
incrementStoredMessagesIndicator(int delta)
Increments the indicator on stored messages. |
String[] |
listFc()
|
Message |
remove()
This method should not be overriden. |
Message |
removeFirst()
Removes and returns the first message from this buffer. |
Message |
removeLast()
Removes and returns the last message from this buffer. |
void |
setMaxCapacity(int maxCapacity)
Sets the maximum capacity of the queue. |
int |
storedMessagesIndicator()
Returns an indicator on stored messages. |
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 |
Field Detail |
protected MessageManager messageManagerItf
MessageManager
client interface.
protected int maxCapacity
protected int availableMessagesIndicator
incrementAvailableMessagesIndicator
method.
protected int storedMessagesIndicator
incrementStoredMessagesIndicator
method.
protected final Object lock
Constructor Detail |
public AbstractBufferImpl()
Method Detail |
public int availableMessagesIndicator()
Buffer
availableMessagesIndicator
in interface Buffer
Buffer.availableMessagesIndicator()
public int storedMessagesIndicator()
Buffer
storedMessagesIndicator
in interface Buffer
Buffer.storedMessagesIndicator()
public int availableSpaceIndicator()
Buffer
Integer.MAX_VALUE
.
availableSpaceIndicator
in interface Buffer
Buffer.availableSpaceIndicator()
public void add(Message message) throws InterruptedException
add
in interface Buffer
message
- message to be addedto be appended to this list.
InterruptedException
- if it is interrupted while adding the message.Buffer.add(org.objectweb.dream.message.Message)
public Message remove() throws InterruptedException
remove
in interface Buffer
InterruptedException
- if it is interrupted while removing a message.Buffer.remove()
public Message get() throws InterruptedException
get
in interface Buffer
InterruptedException
- if it is interrupted while removing a message.Buffer.get()
public void addFirst(Message message) throws InterruptedException
BufferAddFirstLast
addFirst
in interface BufferAddFirstLast
message
- the message to be inserted at the beginning of this buffer.
InterruptedException
- if it is interrupted while waiting for a
message to be removed.BufferAddFirstLast.addFirst(org.objectweb.dream.message.Message)
public void addLast(Message message) throws InterruptedException
BufferAddFirstLast
addLast
in interface BufferAddFirstLast
message
- the message to be inserted at the end of this buffer.
InterruptedException
- if it is interrupted while waiting for a
message to be removed.BufferAddFirstLast.addLast(org.objectweb.dream.message.Message)
public Message getFirst() throws InterruptedException
BufferRemoveFirstLast
getFirst
in interface BufferRemoveFirstLast
InterruptedException
- if it is interrupted while waiting for a
message to be added.BufferRemoveFirstLast.getFirst()
public Message getLast() throws InterruptedException
BufferRemoveFirstLast
getLast
in interface BufferRemoveFirstLast
InterruptedException
- if it is interrupted while waiting for a
message to be added.BufferRemoveFirstLast.getLast()
public Message removeFirst() throws InterruptedException
BufferRemoveFirstLast
removeFirst
in interface BufferRemoveFirstLast
InterruptedException
- if it is interrupted while waiting for a
message to be added.BufferRemoveFirstLast.removeFirst()
public Message removeLast() throws InterruptedException
BufferRemoveFirstLast
removeLast
in interface BufferRemoveFirstLast
InterruptedException
- if it is interrupted while waiting for a
message to be added.BufferRemoveFirstLast.removeLast()
protected void incrementAvailableMessagesIndicator(int delta)
delta
- the delta that must be added to previous indicator.protected void incrementStoredMessagesIndicator(int delta)
delta
- the delta that must be added to previous indicator.protected abstract boolean canAdd(Message message)
message
- the message to be tested.
true
if the message can be added.protected abstract void doAdd(Message message)
add(org.objectweb.dream.message.Message)
method.
message
- the message to be added.protected abstract boolean hasAvailableMessage()
true
if there is an available message.protected abstract Message doRemove()
remove()
method.
protected abstract Message doGet()
remove()
method.
protected void doAddFirst(Message message)
add(org.objectweb.dream.message.Message)
method.
message
- the message to be added.protected void doAddLast(Message message)
add(org.objectweb.dream.message.Message)
method.
message
- the message to be added.protected Message doGetFirst()
remove()
method.
protected Message doGetLast()
remove()
method.
protected Message doRemoveFirst()
remove()
method.
protected Message doRemoveLast()
remove()
method.
public int getMaxCapacity()
QueueAttributeController
getMaxCapacity
in interface QueueAttributeController
QueueAttributeController.getMaxCapacity()
public void setMaxCapacity(int maxCapacity)
QueueAttributeController
setMaxCapacity
in interface QueueAttributeController
maxCapacity
- the maximum capacity of the queue.QueueAttributeController.setMaxCapacity(int)
public int getCurrentSize()
QueueAttributeController
getCurrentSize
in interface QueueAttributeController
QueueAttributeController.getCurrentSize()
public void bindFc(String clientItfName, Object serverItf) throws NoSuchInterfaceException, IllegalBindingException, IllegalLifeCycleException
bindFc
in interface BindingController
NoSuchInterfaceException
IllegalBindingException
IllegalLifeCycleException
BindingController.bindFc(String,
Object)
public String[] listFc()
listFc
in interface BindingController
BindingController.listFc()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |