Interface ConnectMessage
- All Superinterfaces:
Serializable
- All Known Implementing Classes:
ConnectMessageImpl
ConnectMessage is the object transferred between ConnectAgent components. Its main purpose is
to couple the input and output of two ConnectAgent components with each other. Basically it is the
interface between two ConnectAgent components.
A ConnectMessage contains Properties and one or more ConnectMessageParts. The Properties are used to register all kinds of Properties regarding this ConnectMessage like ConnectMessageID, timestamp and correllationId. The ConnectMessageParts contain the actual data to be transferred between components.
A new ConnectMessage automatically gets a unique connectmessageID and a connectmessageTimestamp property.
- Author:
- kgarstman
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addPart
(String id, ConnectMessagePart<?> part) CallsaddPart(String, ConnectMessagePart, boolean)
with boolean = truevoid
addPart
(String id, ConnectMessagePart<?> part, boolean overwrite) Adds a ConnectMessagePart to this ConnectMessage.void
addProperties
(Map<Object, Object> props) Adds all properties in a map to this ConnectMessage properties.void
addProperties
(Properties props) Adds all properties in props to this ConnectMessage properties.void
addProperty
(Object key, Object value) Adds a property to this ConnectMessage properties.boolean
Tests if the specified key is a property in this ConnectMessage.boolean
containsProperty
(Object key) Deprecated.void
Copies a ConnectMessagePart.Gets the first (oldest) ConnectMessagePart.Gets the last (newest) ConnectMessagePart.Gets the value of a property as an Object.int
Gets the number of ConnectMessageParts in this ConnectMessage.getPartById
(String id) Gets the ConnectMessagePart identified by id in this ConnectMessage.getPartByPartNumber
(int partNumber) Gets the ConnectMessagePart with a certain partNumber.getParts()
Gets all ConnectMessageParts of this ConnectMessage.Gets the Properties of this ConnectMessagegetPropertyValue
(Object key) Deprecated.Gets the value of a property as a String.Deprecated.void
Moves a ConnectMessagePart to another partId.void
setParts
(Map<String, ConnectMessagePart<?>> parts) Sets (and replaces!) the ConnectMessageParts of this ConnectMessage.void
setProperties
(Properties properties) Sets (and replaces!) the Properties of this ConnectMessage.toXML()
Gets a simplified XML message of this ConnectMessage.
-
Method Details
-
getProperties
Properties getProperties()Gets the Properties of this ConnectMessage- Returns:
- The Properties of this ConnectMessage
-
setProperties
Sets (and replaces!) the Properties of this ConnectMessage.- Parameters:
properties
- The Properties object to insert into this ConnectMessage.
-
getParts
Map<String,ConnectMessagePart<?>> getParts()Gets all ConnectMessageParts of this ConnectMessage.- Returns:
- a map of all ConnectMessageParts indexed by part id.
-
setParts
Sets (and replaces!) the ConnectMessageParts of this ConnectMessage.- Parameters:
parts
- AMap
of ConnectMessageParts
-
getPropertyValue
Deprecated.Gets the value of a property as an Object. Property key will be searched in ConnectMessage properties. When not found the search will be extended to the properties of the contained ConnectMessageParts.- Parameters:
key
- Name of the property to find- Returns:
- The found value as an Object or null if not found
-
getMessagePropertyValue
Gets the value of a property as an Object. Property key will be searched in ConnectMessage properties only.- Parameters:
key
- Name of the property to find- Returns:
- The found value as an Object or null if not found
-
getStringPropertyValue
Deprecated.Gets the value of a property as a String.- Parameters:
key
- Name of the property to find- Returns:
- The found value as a String or an empty String if not found or value cannot be cast to String
- See Also:
-
getStringMessagePropertyValue
Gets the value of a property as a String.- Parameters:
key
- Name of the property to find- Returns:
- The found value as a String or an empty String if not found or value cannot be cast to String
- See Also:
-
getPartById
Gets the ConnectMessagePart identified by id in this ConnectMessage.- Parameters:
id
- Name or id of the wanted ConnectMessagePart- Returns:
- The requested ConnectMessagePart or null if not found.
-
getPartByPartNumber
Gets the ConnectMessagePart with a certain partNumber. Each ConnectMessagePart gets a subsequent partNumber when it is stored in a ConnectMessage. PartNumbers start at 0 for the first ConnectMessagePart stored.- Parameters:
partNumber
- The number of the part to retrieve.- Returns:
- The ConnectMessagePart with partNumer or null when not found
-
addPart
CallsaddPart(String, ConnectMessagePart, boolean)
with boolean = true- Parameters:
id
- PartId to store this ConnectMessagePartpart
- The ConnectMessagePart to add.
-
addPart
Adds a ConnectMessagePart to this ConnectMessage. The ConnectMessagePart is mapped with the id into the ConnectMessage. The boolean defines if the ConnectMessagePart will be overwritten if it already exists.- Parameters:
id
- PartId to store this ConnectMessagePartpart
- The ConnectMessagePart to add.overwrite
- Defines the overwrite mode.
-
movePart
Moves a ConnectMessagePart to another partId. The partId of a ConnectMessagePart is renamed. If the new partId already exists the overwrite boolean decides if the rename will actually occur.- Parameters:
oldId
- partid of the existing ConnectMessagePartnewId
- new partId to rename the oldIdoverwrite
- Defines the overwrite mode.
-
copyPart
Copies a ConnectMessagePart. The new ConnectMessagePart is stored under the newId. The copy of the part is NOT a clone but just a reference copy. The boolean decides if the copy will overwrite an existing ConnectMessagePart.- Parameters:
oldId
- partid of the existing ConnectMessagePartnewId
- new partId to copy the exiting ConnectMessagePart to.clone
- Defines if the content of the ConnectMessagePart will be cloned.overwrite
- Defines the overwrite mode.
-
addProperty
Adds a property to this ConnectMessage properties. If the property key already exists the old value will be overwritten.- Parameters:
key
- Key name of the propertyvalue
- Value of the property to add
-
addProperties
Adds all properties in props to this ConnectMessage properties. Any existing properties in ConnectMessage will be kept unless overwritten by the new properties in props.- Parameters:
props
- Properties to add
-
addProperties
Adds all properties in a map to this ConnectMessage properties. Any existing properties in ConnectMessage will be kept unless overwritten by the new proprties in the map.- Parameters:
props
- Map of properties to add
-
getNumberOfParts
int getNumberOfParts()Gets the number of ConnectMessageParts in this ConnectMessage.- Returns:
- The number of parts.
-
containsProperty
Deprecated.Tests if the specified key is a property in this ConnectMessage or any of its ConnectMessageParts.- Parameters:
key
- The property key to test- Returns:
- True if the property is found, false otherwise
-
containsMessageProperty
Tests if the specified key is a property in this ConnectMessage.- Parameters:
key
- The property key to test- Returns:
- True if the property is found, false otherwise
-
getFirstPart
ConnectMessagePart<?> getFirstPart()Gets the first (oldest) ConnectMessagePart. The part with partnumber 0 is the first part that was added to this ConnectMessage. Because parts can be removed and partnumbers can not be changed on ConnectMessageParts the first part will not automatically be part with partnumber 0.- Returns:
- The ConnectMessagePart with the lowest partNumber
-
getLastPart
ConnectMessagePart<?> getLastPart()Gets the last (newest) ConnectMessagePart.- Returns:
- The ConnectMessagePart with the highest partNumber
-
toXML
String toXML()Gets a simplified XML message of this ConnectMessage. Must only be used for logging purposes. The returned XML does not reflect the actual (JABX) XML reference of this ConnectMessage.- Returns:
- The simplified XML message as a String
-