|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.softamis.net.exchange.support.AbstractCommunicationHelper<D,K,V>
D
- type of low level data that are sent via networkK
- type of keys used to identify registry itemsV
- type of values stored in the registrypublic abstract class AbstractCommunicationHelper<D extends java.io.Serializable,K extends java.io.Serializable,V extends java.io.Serializable>
Class represents base implementation of CommunicationHelper used to isolate details of networking communications from registry logic.
Field Summary | |
---|---|
protected CommunicationProtocol<D,K,V> |
fCommunicationProtocol
Communication proctocol used to transfer data |
protected java.lang.String |
fDefaultGroupName
Name of group used to form "virtual" group. |
protected java.lang.String |
fDefaultMessageSignature
Signature that will be set to CommunicationProtocol if one is created (and not specified explicitely) |
protected static org.apache.commons.logging.Log |
fLog
|
protected boolean |
fOwnCommunicationProtocol
|
protected RegistryEventsMulticaster<K,V> |
fRegistryEventsMulticaster
Processors that are responsible for processing of obtaining external notifications |
Fields inherited from interface org.softamis.net.exchange.CommunicationHelper |
---|
COMMAND_ITEM_INVALID, COMMAND_ITEM_REGISTERED, COMMAND_ITEM_REQUEST, COMMAND_ITEM_UNREGISTERED |
Constructor Summary | |
---|---|
protected |
AbstractCommunicationHelper()
|
Method Summary | |
---|---|
void |
addRegistryEventProcessor(RegistryEventProcessor<K,V> aListener)
Adds listener to list of registered RegistryEventProcessors which performs further processing of obtained external notifications |
protected ItemEntry<K,V> |
createEntryToReceiveData()
|
protected void |
dispatchCommunicationMessage(byte aMessageType,
ItemEntry<K,V> aEntry)
Performs dispatching of the incoming external notification by call of appropriate method of processors. |
protected void |
doSendItemInvalidNotification(ItemEntry<K,V> aEntry)
Creates lowlevel network data packet that corresponds to notification and sends it |
protected void |
doSendItemRegisteredNotification(ItemEntry<K,V> aEntry)
Creates lowlevel network data packet that corresponds to notification and sends it |
protected void |
doSendItemsRequestNotification(ItemEntry<K,V> aEntry,
long aTimeout)
Creates lowlevel network data packet that corresponds to notification and sends it. |
protected void |
doSendItemUnRegisteredNotification(ItemEntry<K,V> aEntry)
Creates lowlevel network data packet that corresponds to notification and sends it |
CommunicationProtocol<D,K,V> |
getCommunicationProtocol()
Returns communication proctocol used to transfer data |
java.lang.String |
getDefaultGroupName()
Returns name of group used to form "virtual" group. |
java.lang.String |
getDefaultMessageSignature()
|
protected void |
processReceivedData(D aReceivedData,
ItemEntry<K,V> aEntry)
Performs processing of received data |
protected void |
processServiceInvalid(ItemEntry<K,V> aEntry)
Initiates processing or "service invalid" notification by transferring notification data to registered processors. |
protected void |
processServiceRegistered(ItemEntry<K,V> aEntry)
Initiates processing or "service registered" notification by transferring notification data to registered processors. |
protected void |
processServiceRequest(ItemEntry<K,V> aEntry)
Initiating processing of service request by transferring notification to registered processors. |
protected void |
processServiceUnRegistered(ItemEntry<K,V> aEntry)
Initiates processing or "service unregistered" notification by transferring notification data to registered processors. |
protected abstract void |
processUnexpectedMessage(byte aMessageType,
ItemEntry<K,V> aEntry)
Method that is used to handle messages with unexpected type. |
protected void |
receiveData(D aReceivedData)
Performs processing of received data. |
void |
removeRegistryEventProcessor(RegistryEventProcessor<K,V> aListener)
Removes listener from list of registered RegistryEventProcessors which performs further processing of obtained external notifications |
protected abstract void |
sendData(D aDataToSend)
Sends newtorking notification with provided data |
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 |
setCommunicationProtocol(CommunicationProtocol<D,K,V> aCommunicationProtocol)
Sets communication proctocol used to transfer data |
void |
setDefaultGroupName(java.lang.String aDefaultGroupName)
Sets name of group used to form "virtual" group. |
void |
setDefaultMessageSignature(java.lang.String aDefaultMessageSignature)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.softamis.net.exchange.CommunicationHelper |
---|
close, init |
Field Detail |
---|
protected static final org.apache.commons.logging.Log fLog
protected RegistryEventsMulticaster<K extends java.io.Serializable,V extends java.io.Serializable> fRegistryEventsMulticaster
protected CommunicationProtocol<D extends java.io.Serializable,K extends java.io.Serializable,V extends java.io.Serializable> fCommunicationProtocol
protected java.lang.String fDefaultGroupName
protected java.lang.String fDefaultMessageSignature
protected boolean fOwnCommunicationProtocol
Constructor Detail |
---|
protected AbstractCommunicationHelper()
Method Detail |
---|
protected void processReceivedData(D aReceivedData, ItemEntry<K,V> aEntry)
aReceivedData
- raw data received from network notificationaEntry
- entry to be filled by parsed data from networkprotected void receiveData(D aReceivedData)
aReceivedData
- data received from the network.protected ItemEntry<K,V> createEntryToReceiveData()
protected void dispatchCommunicationMessage(byte aMessageType, ItemEntry<K,V> aEntry)
aMessageType
- type of incoming messageaEntry
- item entry obtained with messageprotected abstract void processUnexpectedMessage(byte aMessageType, ItemEntry<K,V> aEntry)
aMessageType
- type of messageaEntry
- entry obtained with messageprotected abstract void sendData(D aDataToSend)
aDataToSend
- data which should be sentpublic void sendItemsRequestNotification(K aItemKey, long aTimeout)
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.
sendItemsRequestNotification
in interface CommunicationHelper<K extends java.io.Serializable,V extends java.io.Serializable>
aItemKey
- key of itemaTimeout
- timeout(in ms) used for discovering itemspublic void sendItemInvalidNotification(K aItemKey, V aItemInfo)
ConsumingRegistry
.
sendItemInvalidNotification
in interface CommunicationHelper<K extends java.io.Serializable,V extends java.io.Serializable>
aItemKey
- key of the itemaItemInfo
- item invalidatedpublic void sendItemRegisteredNotification(K aItemKey, V aItemInfo)
ProvidingRegistry
.
sendItemRegisteredNotification
in interface CommunicationHelper<K extends java.io.Serializable,V extends java.io.Serializable>
aItemKey
- key of registered itemaItemInfo
- the item registeredpublic void sendItemUnRegisteredNotification(K aItemKey, V aItemInfo)
ProvidingRegistry
.
sendItemUnRegisteredNotification
in interface CommunicationHelper<K extends java.io.Serializable,V extends java.io.Serializable>
aItemKey
- key of unregistered itemaItemInfo
- the item unregisteredprotected void doSendItemInvalidNotification(ItemEntry<K,V> aEntry)
aEntry
- item entry to be set in notificationprotected void doSendItemRegisteredNotification(ItemEntry<K,V> aEntry)
aEntry
- item entry to be set in notificationprotected void doSendItemUnRegisteredNotification(ItemEntry<K,V> aEntry)
aEntry
- item entry to be set in notificationprotected void doSendItemsRequestNotification(ItemEntry<K,V> aEntry, long aTimeout)
receiveData(D)
and will be further processed by registered processors.
aEntry
- item entry to be set in notificationpublic void removeRegistryEventProcessor(RegistryEventProcessor<K,V> aListener)
removeRegistryEventProcessor
in interface CommunicationHelper<K extends java.io.Serializable,V extends java.io.Serializable>
aListener
- processor to be removedpublic void addRegistryEventProcessor(RegistryEventProcessor<K,V> aListener)
addRegistryEventProcessor
in interface CommunicationHelper<K extends java.io.Serializable,V extends java.io.Serializable>
aListener
- processor to be addedprotected void processServiceRequest(ItemEntry<K,V> aEntry)
aEntry
- entry contained in request.protected void processServiceRegistered(ItemEntry<K,V> aEntry)
aEntry
- entry contained in request.protected void processServiceUnRegistered(ItemEntry<K,V> aEntry)
aEntry
- entry contained in request.protected void processServiceInvalid(ItemEntry<K,V> aEntry)
aEntry
- entry contained in request.public CommunicationProtocol<D,K,V> getCommunicationProtocol()
public void setCommunicationProtocol(CommunicationProtocol<D,K,V> aCommunicationProtocol)
aCommunicationProtocol
- communication proctocolpublic java.lang.String getDefaultGroupName()
public void setDefaultGroupName(java.lang.String aDefaultGroupName)
aDefaultGroupName
- name of grouppublic java.lang.String getDefaultMessageSignature()
getDefaultMessageSignature
in interface CommunicationHelper<K extends java.io.Serializable,V extends java.io.Serializable>
public void setDefaultMessageSignature(java.lang.String aDefaultMessageSignature)
setDefaultMessageSignature
in interface CommunicationHelper<K extends java.io.Serializable,V extends java.io.Serializable>
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |