guarana.framework.message
Class Header

java.lang.Object
  extended by guarana.framework.message.Header
All Implemented Interfaces:
Serializable

public class Header
extends Object
implements Serializable

Represents the header of a Message.
- The default message type is EVENT_MESSAGE

Since:
Guaranį SDK 1.0.0
Author:
Rafael Z. Frantz
See Also:
Serialized Form

Field Summary
 String CORRELATION_ID
          The universal identifier that indicates to which request message a reply is for.
 long EXPIRATION_DATE
          The date when the message expires, potentially turning it into an 'invalid' message.
 String MESSAGE_ID
          The message ID.
 MessagePriority PRIORITY
          Establishes the priority of this message.
 String RETURN_ADDRESS
          Identifier that indicates where to deliver the reply message.
 int SEQUENCE_NUMBER
          The number which identifies the child message within a sequence.
 int SEQUENCE_SIZE
          The total number of child messages from a split parent message into a sequence of messages.
static long serialVersionUID
           
 MessageType TYPE
          The type which describes the 'intention' of this message.
 
Constructor Summary
Header()
          Constructs a new Header.
 
Method Summary
 void addAllDynamicAttributes(Map<String,Object> attributes)
          Adds several dynamic attributes at once.
 void addCorrelationIDValue(String correlationID)
          Adds a correlation ID value to the list of correlation id values this message has.
 Object addDynamicAttribute(String name, Object value)
          Adds a dynamic attribute to the header.
 void addSequenceNumberValue(int sequenceNumber)
          Adds a sequence number value to the list of sequence number values this message has.
 void addSequenceSizeValue(int sequenceSize)
          Adds a sequence size value to the list of sequence size values this message has.
 Header copy()
          Creates a copy of this header.
 Map<String,Object> getAllDynamicAttributes()
          Returns all dynamic attributes from the header.
 Object getDynamicAttribute(String name)
          Returns the value of an specific dynamic attribute.
 Set<Parent> getParents()
          Returns all parents of this message.
 String pollCorrelationIDValue()
          Polls the last correlation ID from the list of values.
 int pollSequenceNumberValue()
          Polls the last sequence number value from the list.
 int pollSequenceSizeValue()
          Polls the last sequence size value from the list.
 Object removeDynamicAttribute(String name)
          Removes a dynamic attribute from the header.
 void removeParents()
          Removes all parents from this message.
 void setParents(Set<Parent> parents)
          Sets all ancestors for this message.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

public static final long serialVersionUID
See Also:
Constant Field Values

MESSAGE_ID

public String MESSAGE_ID
The message ID. It is automatically generated using the UUDI class and has the following format: 4190888b-fe50-42d6-83d9-4b6241d92920 (an example of message ID).


TYPE

public MessageType TYPE
The type which describes the 'intention' of this message.

See Also:
MessageType

PRIORITY

public MessagePriority PRIORITY
Establishes the priority of this message.

See Also:
MessagePriority

SEQUENCE_SIZE

public int SEQUENCE_SIZE
The total number of child messages from a split parent message into a sequence of messages.


SEQUENCE_NUMBER

public int SEQUENCE_NUMBER
The number which identifies the child message within a sequence.


CORRELATION_ID

public String CORRELATION_ID
The universal identifier that indicates to which request message a reply is for.

This is an Integration Pattern implementation

Problem: How does a requestor that has received a reply know which request this is the reply for?

Solution: Each reply message should contain a Correlation Identifier, a unique identifier that indicates which request message this reply is for.

See Also:
Correlation Identifier

RETURN_ADDRESS

public String RETURN_ADDRESS
Identifier that indicates where to deliver the reply message.

This is an Integration Pattern implementation

Problem: How does a replier know where to send the reply?

Solution: The request message should contain a Return Address that indicates where to send the reply message.

See Also:
Return Address

EXPIRATION_DATE

public long EXPIRATION_DATE
The date when the message expires, potentially turning it into an 'invalid' message.

Constructor Detail

Header

public Header()
Constructs a new Header.

Method Detail

addDynamicAttribute

public Object addDynamicAttribute(String name,
                                  Object value)
Adds a dynamic attribute to the header. A dynamic attribute is a no predefined attribute that the user can freely define and add to the header of this message.

Parameters:
name - The name which uniquely identifies the attribute in the header.
value - The value of the attribute.
Returns:
the value of an already existent attribute with the same name as the new one. The new attribute replaces the old one.

removeDynamicAttribute

public Object removeDynamicAttribute(String name)
Removes a dynamic attribute from the header.

Parameters:
name - The name of the attribute to remove.
Returns:
the value of the removed attribute.

getDynamicAttribute

public Object getDynamicAttribute(String name)
Returns the value of an specific dynamic attribute.

Parameters:
name - The name of the attribute.
Returns:
the value of the attribute.

addAllDynamicAttributes

public void addAllDynamicAttributes(Map<String,Object> attributes)
Adds several dynamic attributes at once. If there are other attributes, they will be kept.

Parameters:
attributes - the attributes to add.

getAllDynamicAttributes

public Map<String,Object> getAllDynamicAttributes()
Returns all dynamic attributes from the header.

Returns:
a map with all the attributes.

removeParents

public void removeParents()
Removes all parents from this message.


getParents

public Set<Parent> getParents()
Returns all parents of this message. Messages may have mode than one parent and each parent has zero or more parents.

Returns:
the parents.

setParents

public void setParents(Set<Parent> parents)
Sets all ancestors for this message.

Parameters:
parents - The set of ancestors.

addCorrelationIDValue

public void addCorrelationIDValue(String correlationID)
Adds a correlation ID value to the list of correlation id values this message has. This values are used by the Splitter and Aggregator task to execute their operations. The last value in this list can be accessed by using the property CORRELATION_ID.

Parameters:
correlationID - The correlation ID

pollCorrelationIDValue

public String pollCorrelationIDValue()
Polls the last correlation ID from the list of values. After executed this method will have updated the property CORRELATION_ID to the next value in the list, or null if it has polled the last value.

Returns:
the next element in the list or null if the list is empty()

addSequenceSizeValue

public void addSequenceSizeValue(int sequenceSize)
Adds a sequence size value to the list of sequence size values this message has. This values are used by the Splitter and Aggregator task to execute their operations. The last value in this list can be accessed by using the property SEQUENCE_SIZE.

Parameters:
sequenceSize - The sequence size.

pollSequenceSizeValue

public int pollSequenceSizeValue()
Polls the last sequence size value from the list. After executed this method will have updated the property SEQUENCE_SIZE to the next value in the list, or -1 if it has polled the last value. Sequence size is always greater than zero.

Returns:
the next element in the list or -1 if the list is empty().

addSequenceNumberValue

public void addSequenceNumberValue(int sequenceNumber)
Adds a sequence number value to the list of sequence number values this message has. This values are used by the Splitter and Aggregator task to execute their operations. The last value in this list can be accessed by using the property SEQUENCE_NUMBER.

Parameters:
sequenceNumber - The sequence number.

pollSequenceNumberValue

public int pollSequenceNumberValue()
Polls the last sequence number value from the list. After executed this method will have updated the property SEQUENCE_NUMBER to the next value in the list, or -1 if it has polled the last value. Sequence numbers are always greater than zero.

Returns:
the next element in the list or -1 if the list is empty().

copy

public Header copy()
Creates a copy of this header.

Returns:
a new object containing the copy of the current header; otherwise, null if the header could not be copied.


Guaranį DSL Home