|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.softamis.net.exchange.support.AbstractCommunicationHelper<byte[],K,V>
org.softamis.net.exchange.udp.UDPCommunicationHelper<K,V>
K - type of keys used to identify registry itemsV - type of values stored in the registrypublic class UDPCommunicationHelper<K extends java.io.Serializable,V extends java.io.Serializable>
Implementation of CommunicationHelper that uses UDP multicast as underlying trasport mechanizm of network communications.
RegistryEventProcessor| Field Summary | |
|---|---|
static java.lang.String |
DEFAULT_GROUP_NAME
Default multicast group. |
static int |
DEFAULT_PORT
Default port used for multicasting |
protected int |
fDefaultPort
Default port for datagram packets. |
protected int |
fDefaultTimeToLive
Default time to live for datagram packets. |
protected static org.apache.commons.logging.Log |
fLog
|
protected Multicaster |
fMulticaster
Multicaster that is used to perfom UDP packets sending and receiving |
protected boolean |
fOwnMulticaster
Internal flag that indicates whether multicaster was not assigned outside. |
| Fields inherited from class org.softamis.net.exchange.support.AbstractCommunicationHelper |
|---|
fCommunicationProtocol, fDefaultGroupName, fDefaultMessageSignature, fOwnCommunicationProtocol, fRegistryEventsMulticaster |
| Fields inherited from interface org.softamis.net.exchange.CommunicationHelper |
|---|
COMMAND_ITEM_INVALID, COMMAND_ITEM_REGISTERED, COMMAND_ITEM_REQUEST, COMMAND_ITEM_UNREGISTERED |
| Constructor Summary | |
|---|---|
UDPCommunicationHelper()
|
|
| Method Summary | |
|---|---|
void |
close()
Closing helper and multicaster (if one was not set from outside) |
void |
dataReceived(MulticastDataEvent aEvent)
Listens for incoming multicaster' events and calls AbstractCommunicationHelper.receiveData(D)
for futher processing |
int |
getDefaultPort()
Returns default port for datagram packets. |
int |
getDefaultTimeToLive()
Returns default time to live for datagram packets. |
Multicaster |
getMulticaster()
Returns multicaster that is used to perfom UDP packets sending and receiving |
void |
init()
Method used for initialization of communication helper. |
protected void |
initMulticaster()
|
protected void |
insureCommunicationProtocolAndMulticasterSet()
|
protected void |
processUnexpectedMessage(byte aMessageType,
ItemEntry<K,V> aEntry)
Method that is used to handle messages with unexpected type. |
protected void |
sendData(byte[] aDataToSend)
Sends newtorking notification with provided data by delegating data provided to multicaster. |
void |
setDefaultMessageSignature(java.lang.String aDefaultMessageSignature)
Sets signature that will be set to CommunicationProtocol if one is created (and not specified explicitely) |
void |
setDefaultPort(int aDefaultPort)
Sets default port for datagram packets. |
void |
setDefaultTimeToLive(int aDefaultTimeToLive)
Sets default time to live for datagram packets. |
void |
setMulticaster(Multicaster aMulticaster)
Sets multicaster that is used to perfom UDP packets sending and receiving. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static final org.apache.commons.logging.Log fLog
protected Multicaster fMulticaster
protected int fDefaultTimeToLive
protected int fDefaultPort
protected boolean fOwnMulticaster
public static final java.lang.String DEFAULT_GROUP_NAME
public static final int DEFAULT_PORT
| Constructor Detail |
|---|
public UDPCommunicationHelper()
| Method Detail |
|---|
protected void insureCommunicationProtocolAndMulticasterSet()
throws java.net.UnknownHostException
java.net.UnknownHostExceptionpublic void setDefaultMessageSignature(java.lang.String aDefaultMessageSignature)
setDefaultMessageSignature in interface CommunicationHelper<K extends java.io.Serializable,V extends java.io.Serializable>setDefaultMessageSignature in class AbstractCommunicationHelper<byte[],K extends java.io.Serializable,V extends java.io.Serializable>aDefaultMessageSignature - signature that will be set to CommunicationProtocol if one is created (and not specified explicitely)
public void init()
throws java.io.IOException
init in interface CommunicationHelper<K extends java.io.Serializable,V extends java.io.Serializable>java.io.IOException - if
protected void initMulticaster()
throws java.io.IOException
java.io.IOExceptionpublic void close()
close in interface CommunicationHelper<K extends java.io.Serializable,V extends java.io.Serializable>
protected void processUnexpectedMessage(byte aMessageType,
ItemEntry<K,V> aEntry)
AbstractCommunicationHelper
processUnexpectedMessage in class AbstractCommunicationHelper<byte[],K extends java.io.Serializable,V extends java.io.Serializable>aMessageType - type of messageaEntry - entry obtained with messageprotected void sendData(byte[] aDataToSend)
sendData in class AbstractCommunicationHelper<byte[],K extends java.io.Serializable,V extends java.io.Serializable>aDataToSend - data which should be sentpublic void dataReceived(MulticastDataEvent aEvent)
AbstractCommunicationHelper.receiveData(D)
for futher processing
dataReceived in interface MulticastListeneraEvent - event from multicasterpublic Multicaster getMulticaster()
public void setMulticaster(Multicaster aMulticaster)
aMulticaster - multicasterpublic void setDefaultPort(int aDefaultPort)
aDefaultPort - default port for datagram packets.public int getDefaultTimeToLive()
public void setDefaultTimeToLive(int aDefaultTimeToLive)
aDefaultTimeToLive - default time to live for datagram packets.public int getDefaultPort()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||