eneter.messaging.messagingsystems.websocketmessagingsystem
Class WebSocketMessagingSystemFactory

java.lang.Object
  extended by eneter.messaging.messagingsystems.websocketmessagingsystem.WebSocketMessagingSystemFactory
All Implemented Interfaces:
IMessagingSystemFactory

public class WebSocketMessagingSystemFactory
extends java.lang.Object
implements IMessagingSystemFactory

Messaging system delivering messages via websockets. It creates the communication channels using WebSockets for sending and receiving messages. The channel id must be a valid URI address. E.g.: ws://127.0.0.1:6080/MyService/.


Constructor Summary
WebSocketMessagingSystemFactory()
          Constructs the websocket messaging factory.
WebSocketMessagingSystemFactory(IProtocolFormatter protocolFormatter)
          Constructs the websocket messaging factory.
 
Method Summary
 IDuplexInputChannel createDuplexInputChannel(java.lang.String channelId)
          Creates the duplex input channel receiving messages from the duplex output channel and sending back response messages by using WebSocket.
 IDuplexOutputChannel createDuplexOutputChannel(java.lang.String channelId)
          Creates the duplex output channel sending messages to the duplex input channel and receiving response messages by using WebSocket.
 IDuplexOutputChannel createDuplexOutputChannel(java.lang.String channelId, java.lang.String responseReceiverId)
          Creates the duplex output channel sending messages to the duplex input channel and receiving response messages by using WebSocket.
 IClientSecurityFactory getClientSecurity()
          Gets the factory that is used for creation of client sockets.
 IThreadDispatcherProvider getInputChannelThreading()
          Gets threading mode used for input channels.
 IThreadDispatcherProvider getOutputChannelThreading()
          Gets threading mode used for output channels.
 int getPingFrequency()
          Returns the ping frequency in milliseconds.
 IServerSecurityFactory getServerSecurity()
          Gets the factory that is used for creation of server sockets.
 WebSocketMessagingSystemFactory setClientSecurity(IClientSecurityFactory clientSecurityFactory)
          Sets the factory that will be used for creation of secured client socket.
 WebSocketMessagingSystemFactory setInputChannelThreading(IThreadDispatcherProvider inputChannelThreading)
          Sets threading mode for input channels.
 WebSocketMessagingSystemFactory setOutputChannelThreading(IThreadDispatcherProvider outputChannelThreading)
          Sets threading mode for output channels.
 WebSocketMessagingSystemFactory setPingFrequency(int milliseconds)
          Sets frequency to send the websocket ping message.
 WebSocketMessagingSystemFactory setServerSecurity(IServerSecurityFactory serverSecurityFactory)
          Sets the factory that will be used for creation of server sockets.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WebSocketMessagingSystemFactory

public WebSocketMessagingSystemFactory()
Constructs the websocket messaging factory. The ping frequency is set to default value 5 minutes. The pinging is intended to keep the connection alive in environments that would drop the connection if not active for some time. (e.g. Android phone can drop the connection if there is no activity several minutes.)


WebSocketMessagingSystemFactory

public WebSocketMessagingSystemFactory(IProtocolFormatter protocolFormatter)
Constructs the websocket messaging factory.

Parameters:
protocolFormatter - formatter used for low-level messages between output and input channels.
Method Detail

createDuplexOutputChannel

public IDuplexOutputChannel createDuplexOutputChannel(java.lang.String channelId)
                                               throws java.lang.Exception
Creates the duplex output channel sending messages to the duplex input channel and receiving response messages by using WebSocket.

Specified by:
createDuplexOutputChannel in interface IMessagingSystemFactory
Parameters:
channelId - Identifies the receiving duplex input channel. The channel id must be a valid URI address e.g. ws://127.0.0.1:8090/MyService/
Returns:
output channel
Throws:
java.lang.Exception

createDuplexOutputChannel

public IDuplexOutputChannel createDuplexOutputChannel(java.lang.String channelId,
                                                      java.lang.String responseReceiverId)
                                               throws java.lang.Exception
Creates the duplex output channel sending messages to the duplex input channel and receiving response messages by using WebSocket.

Specified by:
createDuplexOutputChannel in interface IMessagingSystemFactory
Parameters:
channelId - Identifies the receiving duplex input channel. The channel id must be a valid URI address e.g. ws://127.0.0.1:8090/
responseReceiverId - Identifies the response receiver of this duplex output channel.
Returns:
duplex output channel
Throws:
java.lang.Exception

createDuplexInputChannel

public IDuplexInputChannel createDuplexInputChannel(java.lang.String channelId)
                                             throws java.lang.Exception
Creates the duplex input channel receiving messages from the duplex output channel and sending back response messages by using WebSocket.

Specified by:
createDuplexInputChannel in interface IMessagingSystemFactory
Parameters:
channelId - Identifies this duplex input channel. The channel id must be a valid URI address (e.g. ws://127.0.0.1:8090/MyService/) the input channel will listen to.
Returns:
input channel
Throws:
java.lang.Exception

setServerSecurity

public WebSocketMessagingSystemFactory setServerSecurity(IServerSecurityFactory serverSecurityFactory)
Sets the factory that will be used for creation of server sockets. Except security (e.g. using encrypted SSL communication) the factory also allows to specify other communication parameters e.g. timeouts, buffers, etc.

Parameters:
serverSecurityFactory -

getServerSecurity

public IServerSecurityFactory getServerSecurity()
Gets the factory that is used for creation of server sockets. Except security (e.g. using encrypted SSL communication) the factory also allows to specify other communication parameters e.g. timeouts, buffers, etc.

Returns:

setClientSecurity

public WebSocketMessagingSystemFactory setClientSecurity(IClientSecurityFactory clientSecurityFactory)
Sets the factory that will be used for creation of secured client socket. Except security (e.g. using encrypted SSL communication) the factory also allows to specify other communication parameters e.g. timeouts, buffers, etc.

Parameters:
clientSecurityFactory -

getClientSecurity

public IClientSecurityFactory getClientSecurity()
Gets the factory that is used for creation of client sockets. Except security (e.g. using encrypted SSL communication) the factory also allows to specify other communication parameters e.g. timeouts, buffers, etc.

Returns:

setInputChannelThreading

public WebSocketMessagingSystemFactory setInputChannelThreading(IThreadDispatcherProvider inputChannelThreading)
Sets threading mode for input channels.

Parameters:
inputChannelThreading - threading model
Returns:

getInputChannelThreading

public IThreadDispatcherProvider getInputChannelThreading()
Gets threading mode used for input channels.

Returns:

setOutputChannelThreading

public WebSocketMessagingSystemFactory setOutputChannelThreading(IThreadDispatcherProvider outputChannelThreading)
Sets threading mode for output channels.

Parameters:
outputChannelThreading -
Returns:

getOutputChannelThreading

public IThreadDispatcherProvider getOutputChannelThreading()
Gets threading mode used for output channels.

Returns:

setPingFrequency

public WebSocketMessagingSystemFactory setPingFrequency(int milliseconds)
Sets frequency to send the websocket ping message. The pinging is intended to keep the connection alive in environments that would drop the connection if not active for some time.

Parameters:
milliseconds - frequency in milliseconds
Returns:
this WebSocketMessagingSystemFactory

getPingFrequency

public int getPingFrequency()
Returns the ping frequency in milliseconds. The pinging is intended to keep the connection alive in environments that would drop the connection if not active for some time.

Returns:
ping frequency in milliseconds.