org.aselect.system.communication.server
Class Communicator

java.lang.Object
  extended by org.aselect.system.communication.server.Communicator

public class Communicator
extends java.lang.Object

Defines a communicator which can be used with A-Select.

Description:
Defines a communicator which can be used with A-Select. An inputmessage is normally created from an inputstream. Interfaces to IInputMessageand IOutputMessagecan be obtained by the get methods.

Note: The Communicator is part of the "Builder" design pattern that is used in the design of the A-Select server communication package. It can be seen as the director of this pattern. The init method can be seen as the construct method of the director. The message creator is the actual abstract builder and the setParam() method can be seen as a build part method of the Builder. To protect the functionality of the builder, the builder is divided into several interfaces like IInputMessage, IOutputMessage, and IMessageCreatorInterface.

Concurrency issues:
The used IMessageCreatorInterface can be a non threadsafe implementation.

It is recommended to use one Communicator per communication flow.

Author:
Alfa & Ariss

Constructor Summary
Communicator(IMessageCreatorInterface oCreator)
          Creates a new instance of Communicator.
 
Method Summary
 IInputMessage getInputMessage()
          Get input message.
 IOutputMessage getOutputMessage()
          Get output message.
 boolean init(IProtocolRequest oRequest, IProtocolResponse oResponse)
          Initializes the Communicator.
 boolean send()
          Sends the output message.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Communicator

public Communicator(IMessageCreatorInterface oCreator)
Creates a new instance of Communicator.

Description:
Creates a new instance of Communicator which uses a IMessageCreatorInterface implementation.

Concurrency issues:
oCreator should be used in one Communicator.

Preconditions:
oCreator must be an uninitialized IMessageCreatorInterface implementation which is only used in this instance.

Postconditions:
The message creator is set with oCreator.

Parameters:
oCreator - The creator to be used to create messages.
Method Detail

init

public boolean init(IProtocolRequest oRequest,
                    IProtocolResponse oResponse)
             throws ASelectCommunicationException
Initializes the Communicator.

Description:
Initializes the used IMessageCreatorInterface implementation.

Parameters:
oRequest - The request to create the input message from.
oResponse - The response to write the output message to.
Returns:
true - if initialisation was succesfull
False - if initialisation fails.
Throws:
ASelectCommunicationException - If communication fails.
See Also:
IMessageCreatorInterface.init(IProtocolRequest, IProtocolResponse)

getInputMessage

public IInputMessage getInputMessage()
Get input message.

Description:
Get the input message that was created during initialization.

Concurrency issues:
The returned IInputMessage can be a non threadsafe implementation.

Preconditions:
The Communicator must be initialized.

Postconditions:
-

Returns:
an interface to the created input message.

getOutputMessage

public IOutputMessage getOutputMessage()
Get output message.

Description:
Get the output message to add parameters.

Concurrency issues:
The returned IOutputMessage can be a non threadsafe implementation.

Preconditions:
The Communicator must be initialized.

Postconditions:
-

Returns:
an interface to the output message.

send

public boolean send()
             throws ASelectCommunicationException
Sends the output message.

Description:
Calls the send of the used IMessageCreatorInterface implementation.

Returns:
true id sent succesfull.
Throws:
ASelectCommunicationException - If communciation fails.
See Also:
IOutputMessage.send()


Copyright © 2008 SURFnet BV. All Rights Reserved.