sds.data
Class TransactionInfo

java.lang.Object
  extended by sds.data.TransactionInfo
All Implemented Interfaces:
java.io.Serializable

public final class TransactionInfo
extends java.lang.Object
implements java.io.Serializable

Message transaction information in terms of requests / responses correlation, expressed by the combination of last and next identifiers.

A typical transaction between two server-oriented distributed objects A and B is described as follows:

  1. A creates a request message including transactional information. It randomly generates an identifier to initialize next identifier with
  2. A sends the transactional message to B
  3. B receives the message from A. It checks that this message contains transactional information. If so, B should produce a response
  4. B creates a response message and assigns a transactional information in return. This transactional information duplicates the received next identifier as its last field value
  5. A receives a message from B. It checks if it contains transactional information to determine to which request this message responds to

Finally, B could also have set a next identifier value if a response from A is needed...

Author:
ncottin
See Also:
Serialized Form

Constructor Summary
TransactionInfo()
           Creates an empty transaction information.
TransactionInfo(TransactionInfo other)
           Creates and initializes this transaction information with another information
 
Method Summary
 TransactionInfo createResponse()
           Produces a pre-filled transactional information element from this transactional information (which should be taken from a request message)
static TransactionInfo createResponse(TransactionInfo source)
           Produces a pre-filled transactional information element from a given transactional information (which should be taken from a request message)
 java.lang.Long getLastIdentifier()
           Gets the last identifier
 java.lang.Long getNextIdentifier()
           Gets the next identifier
 boolean hasLastIdentifier()
           Checks that this transactional information contains a last identifier
 boolean hasNextIdentifier()
           Checks that this transactional information contains a next identifier
 boolean isInitialized()
           Makes sure this transactional information is initialized before inclusion in a message
 boolean isSignatureRequired()
           
 void setLastIdentifier(java.lang.Long lastIdentifier)
           Assigns the last identifier value in case this transactional information takes part of a response of a transactional request message.
 void setNextIdentifier(java.lang.Long nextIdentifier)
           Assigns the next identifier so that the recipient can assign its last identifier value when generating a reply.
 void setSignatureRequired(boolean requiresSignature)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TransactionInfo

public TransactionInfo()

Creates an empty transaction information. isInitialized() returns false


TransactionInfo

public TransactionInfo(TransactionInfo other)

Creates and initializes this transaction information with another information

Parameters:
other - The existing transaction information to be duplicated. Null indicates that this transaction information is left uninitialized
Method Detail

createResponse

public TransactionInfo createResponse()

Produces a pre-filled transactional information element from this transactional information (which should be taken from a request message)

Returns:
A newly created transactional information object containing a copy of the current next identifier assigned as last identifier. This transactional information is left empty (uninitialized) in case the current transactional information does not hold any next identifier value

createResponse

public static TransactionInfo createResponse(TransactionInfo source)

Produces a pre-filled transactional information element from a given transactional information (which should be taken from a request message)

Parameters:
source - The source transaction information (usually taken from a request message) to be used to create the resulting transactional information
Returns:
A newly created transactional information object containing a copy of the provided transactional information's next identifier assigned as last identifier. This transactional information is left empty (uninitialized) if either the given transactional information is null or does not hold any next identifier value
See Also:
createResponse()

getLastIdentifier

public java.lang.Long getLastIdentifier()

Gets the last identifier

Returns:
The last known identifier or null if this transaction does not hold any last identifier

setLastIdentifier

public void setLastIdentifier(java.lang.Long lastIdentifier)

Assigns the last identifier value in case this transactional information takes part of a response of a transactional request message. This value must be taken from the latter and corresponds to its next identifier

Parameters:
lastIdentifier - The last transactional identifier or null for no identifier
See Also:
createResponse()

getNextIdentifier

public java.lang.Long getNextIdentifier()

Gets the next identifier

Returns:
The next identifier to be returned back by the recipient of the message (which includes this transactional information) or null if this transaction does not hold any next identifier

setNextIdentifier

public void setNextIdentifier(java.lang.Long nextIdentifier)

Assigns the next identifier so that the recipient can assign its last identifier value when generating a reply. This value should be randomly generated

Parameters:
nextIdentifier - The next transactional identifier or null for no identifier. This identifier is returned back by the enclosing message recipients

hasNextIdentifier

public boolean hasNextIdentifier()

Checks that this transactional information contains a next identifier

Returns:
True only if the next identifier is not null

hasLastIdentifier

public boolean hasLastIdentifier()

Checks that this transactional information contains a last identifier

Returns:
True only if the last identifier is not null

isSignatureRequired

public boolean isSignatureRequired()
Returns:
true means that this transactional information requires the answer to be digitally signed

setSignatureRequired

public void setSignatureRequired(boolean requiresSignature)
Parameters:
requiresSignature - true only if this transactional information requires the answer to be digitally signed

isInitialized

public boolean isInitialized()

Makes sure this transactional information is initialized before inclusion in a message

Returns:
True only if this transactional information holds at least one non-null identifier