|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.softamis.net.exchange.support.AbstractCommunicationProtocol<D,K,V,A>
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 AbstractCommunicationProtocol<D extends java.io.Serializable,K extends java.io.Serializable,V extends java.io.Serializable,A extends java.io.Serializable>
Abstract implementation of CommunicationProtocol
that contains base methods used for
transformation application level data to/from underlying network form
CommunicationProtocol
Field Summary | |
---|---|
static boolean |
DEFAULT_COMPRESSION_MODE
Default value of compression mode |
protected java.lang.String |
fDatagramSignature
Signature used for notifications |
protected static org.apache.commons.logging.Log |
fLog
|
protected boolean |
fUseCompression
Indicates whether data that are sent via network should be compressed |
static java.lang.String |
MSG_EXCEPTION_CLOSING_STREAM
|
Constructor Summary | |
---|---|
protected |
AbstractCommunicationProtocol()
|
Method Summary | |
---|---|
protected static void |
closeStream(java.io.InputStream aStream,
java.lang.String aMessage)
Utility method used to close InputStream |
protected static void |
closeStream(java.io.OutputStream aStream,
java.lang.String aMessage)
Utility method used to close OutputStream |
D |
createDataToSend(byte aType,
java.lang.String aTo,
ItemEntry<K,V> aEntry)
Converts information stored in ItemEntry into low level data which could
be sent in network communication. |
protected abstract MessageContent<K,V,A> |
createMessageContent(byte aType,
java.lang.String aTo,
ItemEntry<K,V> aEntry)
Creates MessageContent which will be converted into form used by underlying network
communication based on provided parameters. |
protected MessageContent<K,V,A> |
createMessageContentToRead()
|
protected abstract D |
doCreateDataToSend(MessageContent<K,V,A> aContent)
Converts given MessageContent to form used by underlying network communication |
protected void |
fillEntryByMessageContent(MessageContent<K,V,A> aDatagram,
ItemEntry<K,V> aEntry)
|
byte |
fillItemEntry(D aData,
ItemEntry<K,V> aEntry)
Extracts low level data obtained from network notification and wraps them into provided ItemEntry . |
protected MessageContent<K,V,A> |
getDatagram(byte[] aData)
Constructs MessageContent from given to array of bytes by using deserialization and, if
specified by corresponding option, previous uncompression of byte stream. |
protected abstract MessageContent<K,V,A> |
getDatagramFromReceivedData(D aReceivedData)
Constructs MessageContent from underlying network data. |
java.lang.String |
getDatagramSignature()
Returns signature used for notifications |
protected byte[] |
getDataToSend(MessageContent<K,V,A> aDatagram)
Converts given MessageContent to array of bytes by using serialization and, if
specified by corresponding option, further compression. |
protected abstract boolean |
isNotOwnDatagaram(MessageContent<K,V,A> aDatagram)
Determines whether notification was obtained from external source |
boolean |
isUseCompression()
Returns indicates whether data that are sent via network should be compressed |
void |
setDatagramSignature(java.lang.String aDatagramSignature)
Sets signature used for notifications |
void |
setUseCompression(boolean aUseCompression)
Allows to specify whether data sent via network should be compressed |
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 java.lang.String fDatagramSignature
protected boolean fUseCompression
public static final boolean DEFAULT_COMPRESSION_MODE
public static final java.lang.String MSG_EXCEPTION_CLOSING_STREAM
Constructor Detail |
---|
protected AbstractCommunicationProtocol()
Method Detail |
---|
public byte fillItemEntry(D aData, ItemEntry<K,V> aEntry)
ItemEntry
.
fillItemEntry
in interface CommunicationProtocol<D extends java.io.Serializable,K extends java.io.Serializable,V extends java.io.Serializable>
aData
- low level data received with external notificationaEntry
- entry that will be filled based on received data
CommunicationHelper
protected void fillEntryByMessageContent(MessageContent<K,V,A> aDatagram, ItemEntry<K,V> aEntry)
public D createDataToSend(byte aType, java.lang.String aTo, ItemEntry<K,V> aEntry)
ItemEntry
into low level data which could
be sent in network communication.
createDataToSend
in interface CommunicationProtocol<D extends java.io.Serializable,K extends java.io.Serializable,V extends java.io.Serializable>
aType
- type of notificationaTo
- aEntry
- entry to be converted
protected abstract MessageContent<K,V,A> createMessageContent(byte aType, java.lang.String aTo, ItemEntry<K,V> aEntry)
MessageContent
which will be converted into form used by underlying network
communication based on provided parameters.
aType
- type of notificationaTo
- destination of notificationaEntry
- Item data
protected abstract D doCreateDataToSend(MessageContent<K,V,A> aContent)
MessageContent
to form used by underlying network communication
aContent
- given message content
CommunicationHelper
protected abstract boolean isNotOwnDatagaram(MessageContent<K,V,A> aDatagram)
aDatagram
- data to receive
protected abstract MessageContent<K,V,A> getDatagramFromReceivedData(D aReceivedData)
MessageContent
from underlying network data.
aReceivedData
- raw data obtained in network notification
protected MessageContent<K,V,A> getDatagram(byte[] aData)
MessageContent
from given to array of bytes by using deserialization and, if
specified by corresponding option, previous uncompression of byte stream.
aData
- data to be converted
protected MessageContent<K,V,A> createMessageContentToRead()
protected byte[] getDataToSend(MessageContent<K,V,A> aDatagram)
MessageContent
to array of bytes by using serialization and, if
specified by corresponding option, further compression.
aDatagram
- data to be converted
public boolean isUseCompression()
public void setUseCompression(boolean aUseCompression)
aUseCompression
- true if compression should be enabledprotected static void closeStream(java.io.OutputStream aStream, java.lang.String aMessage)
aStream
- stream to closeaMessage
- message to write to log (name of stream)protected static void closeStream(java.io.InputStream aStream, java.lang.String aMessage)
aStream
- stream to closeaMessage
- message to write to log (name of stream)public java.lang.String getDatagramSignature()
public void setDatagramSignature(java.lang.String aDatagramSignature)
aDatagramSignature
- signature used for notifications
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |