guarana.framework.task
Class Slot

java.lang.Object
  extended by guarana.util.observer.smart.SmartObservable
      extended by guarana.framework.task.Slot
All Implemented Interfaces:
ISource

public class Slot
extends guarana.util.observer.smart.SmartObservable
implements ISource

An in memory buffer used to decouple and transfer messages between tasks.

Graphical notation:


Since:
Guaranį SDK 1.0.0
Author:
Rafael Z. Frantz

Constructor Summary
Slot()
          Constructs a new slot.
Slot(String name)
          Constructs a new slot with a given name.
 
Method Summary
 void addMessage(Message<?> message)
          Adds a message to this slot.
 int countMessages()
          Returns the number of messages currently stored in this slot.
 Gateway getInputGateway()
          Returns the related input gateway which will consume messages from this slot.
 String getName()
          Returns the name of this source.
 Message<?> getNextMessage()
          Retrieves and removes a message from this slot.
 Gateway getOutputGateway()
          Returns the related output gateway which will produce messages to this slot.
 void setInputGateway(Gateway inputGateway)
          Sets the related input gateway which will consume messages from this slot.
 void setName(String name)
          Sets the name of this source.
 void setOutputGateway(Gateway outputGateway)
          Sets the related output gateway which will produce messages to this slot.
 
Methods inherited from class guarana.util.observer.smart.SmartObservable
addSmartObserver, containsSmartObserver, containsSmartObserver, countSmartObservers, deleteSmartObserver, deleteSmartObservers, hasChanged, notifySmartObservers, notifySmartObservers
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Slot

public Slot()
Constructs a new slot.


Slot

public Slot(String name)
Constructs a new slot with a given name.

Parameters:
name - The name of this slot.
Method Detail

addMessage

public void addMessage(Message<?> message)
                throws InvalidParameterException
Adds a message to this slot.

Parameters:
message - The message to be added.
Throws:
InvalidParameterException - if the message parameter is null.

getNextMessage

public Message<?> getNextMessage()
Retrieves and removes a message from this slot. The method is synchronised due to the possible concurrent access by workers to the slot. This situation can happen when there are multiple executions for the task and each worker will call this method to get the message.

Returns:
the message with the highest priority from the Slot or null if there is no message.

countMessages

public int countMessages()
Returns the number of messages currently stored in this slot.

Returns:
the number of messages.

setName

public void setName(String name)
Sets the name of this source.

Specified by:
setName in interface ISource
Parameters:
name - The name of this source.

getName

public String getName()
Returns the name of this source.

Specified by:
getName in interface ISource
Returns:
the name of this source.

getInputGateway

public Gateway getInputGateway()
Returns the related input gateway which will consume messages from this slot.

Returns:
the related input gateway.

setInputGateway

public void setInputGateway(Gateway inputGateway)
Sets the related input gateway which will consume messages from this slot.

Parameters:
inputGateway - The related input gateway

getOutputGateway

public Gateway getOutputGateway()
Returns the related output gateway which will produce messages to this slot.

Returns:
the related output gateway.

setOutputGateway

public void setOutputGateway(Gateway outputGateway)
Sets the related output gateway which will produce messages to this slot.

Parameters:
outputGateway - The related output gateway.


Guaranį DSL Home