things.thinger.service.command.local
Class LocalCommandResponse

java.lang.Object
  extended by things.thinger.service.command.local.LocalCommandResponse
All Implemented Interfaces:
CommandResponse

public class LocalCommandResponse
extends java.lang.Object
implements CommandResponse

A local command response implementation. This is NOT thread safe!!! This will work only with the other Local implementations.

Version:
1.0

Version History

EPG - Initial - 10 APR 06
 
Author:
Erich P. Gatejen

Nested Class Summary
 
Nested classes/interfaces inherited from interface things.thinger.service.command.CommandResponse
CommandResponse.CompletionDisposition, CommandResponse.ResponseState
 
Constructor Summary
LocalCommandResponse(CommandDefinition originalCommandDefinition, LocalCommander commander)
          The Local command response.
 
Method Summary
 void add(Entity<Receipt> responseItem)
          Add a response item.
 void dispose()
          Dispose of the response, command, or anything else that might be associated with this interaction.
 Receipt getFinalReceipt()
          Get the final receipt.
 ReceiptList getReceiptList()
          Get the receipt list.
 CommandResponse.ResponseState getState()
          Get state of the command response.
 Entity<Receipt> next()
          Get next available submission.
 AttributeReader rollup()
          Get a rollup of all the attributes.
 CommandResponse.CompletionDisposition validateCompletion(boolean throwReason)
          Assuming the response is done, was the reponse well formed per the scheme?
 Entity<Receipt> waitResponse(int timeout)
          Wait for a submission and then get it.
 AttributeReader waitRollup(int timeout)
          Wait for the whole transation to be done and then get a rollup of attributes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LocalCommandResponse

public LocalCommandResponse(CommandDefinition originalCommandDefinition,
                            LocalCommander commander)
The Local command response. This will only work with a LocalCommander since it needs to help drain it.

Method Detail

getState

public CommandResponse.ResponseState getState()
Get state of the command response.

Specified by:
getState in interface CommandResponse
Returns:
the State

validateCompletion

public CommandResponse.CompletionDisposition validateCompletion(boolean throwReason)
                                                         throws SystemException
Assuming the response is done, was the reponse well formed per the scheme?

Specified by:
validateCompletion in interface CommandResponse
Parameters:
throwReason - If true and the disposition is BAD, it will throw a SystemException for the reason that makes it BAD.
Throws:
SystemException

getFinalReceipt

public Receipt getFinalReceipt()
Get the final receipt.

Specified by:
getFinalReceipt in interface CommandResponse
Returns:
the terminal receipt for the interaction, or null if it isn't DONE.
See Also:
Receipt

getReceiptList

public ReceiptList getReceiptList()
Get the receipt list.

Specified by:
getReceiptList in interface CommandResponse
Returns:
the complete receipt list for the interaction, or null if it isn't DONE.
See Also:
Receipt

next

public Entity<Receipt> next()
                     throws SystemException
Get next available submission.

Specified by:
next in interface CommandResponse
Returns:
submission, or null if nothing is available.
Throws:
SystemException
See Also:
Receipt, Entity

waitResponse

public Entity<Receipt> waitResponse(int timeout)
                             throws SystemException
Wait for a submission and then get it. If there is an exception, it'll be from the underlying implementation and not something specific to API usage.

Specified by:
waitResponse in interface CommandResponse
Parameters:
timeout - a timeout period in milliseconds. It'll throw a ThingsCodes.SYSTEM_SERVICE_RESPONSE_TIMEOUT SystemException at the end of the timeout. This is a harmless exception and can be safely thrown away. The timeout resolution isn't exact, so don't base any critical timing on it.
Returns:
submission, or null if nothing is available.
Throws:
SystemException
See Also:
Receipt, Entity

rollup

public AttributeReader rollup()
                       throws SystemException
Get a rollup of all the attributes.

Specified by:
rollup in interface CommandResponse
Returns:
submission or null if it is not DONE.
Throws:
SystemException
See Also:
Receipt, Entity

waitRollup

public AttributeReader waitRollup(int timeout)
                           throws SystemException
Wait for the whole transation to be done and then get a rollup of attributes. It will validate against the scheme.

Specified by:
waitRollup in interface CommandResponse
Parameters:
timeout - a timeout period in milliseconds. It'll throw a ThingsCodes.SYSTEM_SERVICE_RESPONSE_TIMEOUT SystemException at the end of the timeout. This is a harmless exception and can be safely thrown away. The timeout resolution isn't exact, so don't base any critical timing on it.
Returns:
submission, or null if it is not DONE.
Throws:
SystemException
See Also:
Receipt, Entity

dispose

public void dispose()
Dispose of the response, command, or anything else that might be associated with this interaction. You should let your commander call this for you.

Specified by:
dispose in interface CommandResponse

add

public void add(Entity<Receipt> responseItem)
         throws SystemException
Add a response item. It may throw and exception if the processing doesn't make sense.

Throws:
SystemException
See Also:
Receipt, Entity


Things.