Class AbstractMessage
java.lang.Object
ch.autumo.beetroot.server.message.AbstractMessage
- Direct Known Subclasses:
ClientAnswer,ServerCommand
Abstract message.
Reduce the transport layer to the max. with the option to encrypt all information with SHA3.
Messages are mainly used for dispatchers / distributed modules between the dedicated web-app installed in a web-container and the beetRoot server or for server administration commands.
It is also used for the file-server (if activated) to down- or upload files from/to a plug-able file storage and for roundtrip-checks of the file-server.
Messages for dispatchers are sent and received with
Reduce the transport layer to the max. with the option to encrypt all information with SHA3.
Messages are mainly used for dispatchers / distributed modules between the dedicated web-app installed in a web-container and the beetRoot server or for server administration commands.
It is also used for the file-server (if activated) to down- or upload files from/to a plug-able file storage and for roundtrip-checks of the file-server.
Messages for dispatchers are sent and received with
ClientCommunicator
and files are sent and received with FileTransfer; in this case messages
are being used for coordinating the upload and download of files that are directly transported by sockets.-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected StringTransport domain name.protected static final booleanprotected StringTransport entity name.protected StringTransport file ID.protected longTransport entity ID.static final Stringinternal message part separatorstatic final Stringinternal message part separator regular expressionprotected static final org.slf4j.Loggerprotected StringTransport message.static final Stringmessage part separatorstatic final Stringmessage part separator regular expressionprotected SerializableAdditional transport object.static Stringserver name -
Constructor Summary
ConstructorsConstructorDescriptionConstructor.AbstractMessage(String message) Constructor with a transport message. -
Method Summary
Modifier and TypeMethodDescriptionbooleanChecks if this key is contained in a paired transport message.protected voiddeserializeObject(String serializedObject) Deserialize this object with FasterXML/Jackson.byte[]getData()Get transfer data; this includes all set information including an object.intGet transfer data length.Get a domain associated with this message or null.Get entity associated with this message or null.File ID if this message is used to transport file information.longgetId()Get entity ID associated with this message or null.org.json.JSONObjectReturn a JSON object or null; null means the object hold by this message represents another object type, but it is always serializable.abstract StringGet JSON representation; this includes all set information including the additional object if set.intgetMessageIntValue(String key) Helper method for accessing paired transport message values.getMessageValue(String key) Helper method for accessing paired transport message values.Get serializable transport object hold by this message or null.abstract StringGet transfer string; this includes all set information including the additional object is set.protected StringSerialize this object with FasterXML/Jackson.voidSet an entity associated with this message.voidsetObject(Serializable object) Set any serializable object, usually a JSON string is meaningful for transport.
-
Field Details
-
LOG
protected static final org.slf4j.Logger LOG -
MSG_PART_SEPARATOR
message part separator- See Also:
-
MSG_PART_SEPARATOR_REGEXP
message part separator regular expression- See Also:
-
INTERNAL_MSG_PART_SEPARATOR
internal message part separator- See Also:
-
INTERNAL_MSG_PART_SEPARATOR_REGEXP
internal message part separator regular expression- See Also:
-
serverName
server name -
ENCRYPT
protected static final boolean ENCRYPT -
message
Transport message. -
entity
Transport entity name. -
domain
Transport domain name. -
id
protected long idTransport entity ID. -
fileId
Transport file ID. -
object
Additional transport object.
-
-
Constructor Details
-
AbstractMessage
public AbstractMessage()Constructor. -
AbstractMessage
Constructor with a transport message. A transport message is usually the minimum of information needed.- Parameters:
message- text message with an own chosen format
-
-
Method Details
-
getJSONObject
public org.json.JSONObject getJSONObject()Return a JSON object or null; null means the object hold by this message represents another object type, but it is always serializable.- Returns:
- JSON object or null
-
setObject
Set any serializable object, usually a JSON string is meaningful for transport.- Parameters:
object- serializable object, e.g. JSON string
-
getObject
Get serializable transport object hold by this message or null.- Returns:
- transport object or null
-
setEntity
Set an entity associated with this message.- Parameters:
entity- entity
-
getEntity
Get entity associated with this message or null.- Returns:
- entity or null.
-
getId
public long getId()Get entity ID associated with this message or null.- Returns:
- ID or 0.
-
getDomain
Get a domain associated with this message or null. A domain can help to categorize this message for specific destinations or logical containers.- Returns:
- domain or null.
-
getFileId
File ID if this message is used to transport file information.- Returns:
- File ID or 0
-
getData
Get transfer data; this includes all set information including an object.- Returns:
- transfer data
- Throws:
IOException- IO exception
-
getDataLength
Get transfer data length.- Returns:
- transfer data length
- Throws:
IOException- IO exception
-
getMessageIntValue
Helper method for accessing paired transport message values. A paired transport message separates values withINTERNAL_MSG_PART_SEPARATORand is set by the constructorAbstractMessage(String). Key-Value pairs are separated by the '=' sign.- Parameters:
key- key- Returns:
- value
-
getMessageValue
Helper method for accessing paired transport message values. A paired transport message separates values withINTERNAL_MSG_PART_SEPARATORand is set by the constructorAbstractMessage(String). Key-Value pairs are separated by the '=' sign.- Parameters:
key- key- Returns:
- value
-
contains
Checks if this key is contained in a paired transport message.- Parameters:
key- key- Returns:
- true if so, otherwise false
-
getTransferString
Get transfer string; this includes all set information including the additional object is set.- Returns:
- transfer string
- Throws:
IOException- IO exception
-
getJsonTransferString
Get JSON representation; this includes all set information including the additional object if set.- Returns:
- transfer JSON string
- Throws:
IOException- IO exception
-
deserializeObject
Deserialize this object with FasterXML/Jackson. Internal method, don't call it.- Parameters:
serializedObject- serialized object- Throws:
IOException
-
serializeObject
Serialize this object with FasterXML/Jackson. Internal method, don't call it.- Returns:
- serialized object
- Throws:
IOException
-