org.softamis.net.exchange
Interface CommunicationHelper<K extends java.io.Serializable,V extends java.io.Serializable>

Type Parameters:
K - type of keys used to identify registry items
V - type of values stored in the registry
All Known Implementing Classes:
AbstractCommunicationHelper, JGCommunicationHelper, UDPCommunicationHelper

public interface CommunicationHelper<K extends java.io.Serializable,V extends java.io.Serializable>

Interface defines generic facade for network communication protocol used by distributed registry. The protocol is fairly simple and all sending of all notifications are performed using corresponding methods of the interface.

It is assumed that this interface is responsible not only for sending protocol notifications, but also for receiving them. Received notifications are later forwared for further processing to list of registered RegistryEventProcessors.

Author:
Andrew Sazonov
See Also:
RegistryEventProcessor

Field Summary
static byte COMMAND_ITEM_INVALID
          Command indicates that item is invalidated
static byte COMMAND_ITEM_REGISTERED
          Command indicates that item is registered
static byte COMMAND_ITEM_REQUEST
          Command indicates that information about items for key is requested
static byte COMMAND_ITEM_UNREGISTERED
          Command indicates that item is unregistered
 
Method Summary
 void addRegistryEventProcessor(RegistryEventProcessor<K,V> aListener)
          Adds listener to list of registered RegistryEventProcessors which performs further processing of obtained external notifications
 void close()
          Used to close helper after usage at the end of lifecycle.
 java.lang.String getDefaultMessageSignature()
           
 void init()
          Method used for initialization of communication helper.
 void removeRegistryEventProcessor(RegistryEventProcessor<K,V> aListener)
          Removes listener from list of registered RegistryEventProcessors which performs further processing of obtained external notifications
 void sendItemInvalidNotification(K aItemKey, V aItemInfo)
          Sends network notification about invalid item.
 void sendItemRegisteredNotification(K aItemKey, V aItemInfo)
          Sends network notification about item registered.
 void sendItemsRequestNotification(K aItemKey, long aTimeout)
          Sends network notification about requesting items for given key.
 void sendItemUnRegisteredNotification(K aItemKey, V aItemInfo)
          Sends network notification about item unregistration.
 void setDefaultMessageSignature(java.lang.String aValue)
           
 

Field Detail

COMMAND_ITEM_REGISTERED

static final byte COMMAND_ITEM_REGISTERED
Command indicates that item is registered

See Also:
Constant Field Values

COMMAND_ITEM_INVALID

static final byte COMMAND_ITEM_INVALID
Command indicates that item is invalidated

See Also:
Constant Field Values

COMMAND_ITEM_UNREGISTERED

static final byte COMMAND_ITEM_UNREGISTERED
Command indicates that item is unregistered

See Also:
Constant Field Values

COMMAND_ITEM_REQUEST

static final byte COMMAND_ITEM_REQUEST
Command indicates that information about items for key is requested

See Also:
Constant Field Values
Method Detail

init

void init()
          throws java.io.IOException
Method used for initialization of communication helper.

Throws:
java.io.IOException

close

void close()
Used to close helper after usage at the end of lifecycle.


sendItemsRequestNotification

void sendItemsRequestNotification(K aItemKey,
                                  long aTimeout)
Sends network notification about requesting items for given key. Typically this method will be called by ConsumingRegistry to obtain information about available items.

This method may block execution of calling thread after issuing notification for specified amount of time to let responses be collected.

Parameters:
aItemKey - key of item
aTimeout - timeout(in ms) used for discovering items

sendItemInvalidNotification

void sendItemInvalidNotification(K aItemKey,
                                 V aItemInfo)
Sends network notification about invalid item. Typically is sent by ConsumingRegistry.

Parameters:
aItemKey - key of the item
aItemInfo - item invalidated

sendItemRegisteredNotification

void sendItemRegisteredNotification(K aItemKey,
                                    V aItemInfo)
Sends network notification about item registered. Typically is sent by ProvidingRegistry.

Parameters:
aItemKey - key of registered item
aItemInfo - the item registered

sendItemUnRegisteredNotification

void sendItemUnRegisteredNotification(K aItemKey,
                                      V aItemInfo)
Sends network notification about item unregistration. Typically is sent by ProvidingRegistry.

Parameters:
aItemKey - key of unregistered item
aItemInfo - the item unregistered

removeRegistryEventProcessor

void removeRegistryEventProcessor(RegistryEventProcessor<K,V> aListener)
Removes listener from list of registered RegistryEventProcessors which performs further processing of obtained external notifications

Parameters:
aListener - processor to be removed

addRegistryEventProcessor

void addRegistryEventProcessor(RegistryEventProcessor<K,V> aListener)
Adds listener to list of registered RegistryEventProcessors which performs further processing of obtained external notifications

Parameters:
aListener - processor to be added

setDefaultMessageSignature

void setDefaultMessageSignature(java.lang.String aValue)

getDefaultMessageSignature

java.lang.String getDefaultMessageSignature()