TH2 Create new AbstractTh2ExternalMinaCodecFactory with MessageHelper
MODIFY
BackEnd/Core/sailfish-core/src/main/kotlin/com/exactpro/sf/externalapi/codec/impl/AbstractExternalMinaCodecFactory.kt
BackEnd/Core/sailfish-core/src/main/kotlin/com/exactpro/sf/externalapi/codec/impl/AbstractExternalMinaCodecFactory.kt
@@ -42,6 +42,7 @@ import com.exactpro.sf.externalapi.codec.ResourcePath
import com.exactpro.sf.scriptrunner.utilitymanager.UtilityInfo
import com.exactpro.sf.services.IServiceContext
import com.exactpro.sf.services.ITaskExecutor
+import com.exactpro.sf.services.MessageHelper
import com.exactpro.sf.storage.IMessageStorage
import com.google.common.collect.ImmutableTable
import com.google.common.collect.Table
@@ -58,6 +59,8 @@ import java.util.EnumMap
abstract class AbstractExternalMinaCodecFactory : AbstractExternalCodecFactory() {
protected abstract val codecClass: Class<out AbstractCodec>
+ protected open val messageHelperClass: Class<out MessageHelper>? = null
+ protected open val messageHelperParams: Map<String, String> = emptyMap()
override fun createCodec(settings: IExternalCodecSettings): IExternalCodec = settings.run {
val dictionary = checkNotNull(this[MAIN]) { "Main dictionary is not set" }
@@ -75,7 +78,9 @@ abstract class AbstractExternalMinaCodecFactory : AbstractExternalCodecFactory()
),
getSettings(),
messageFactory,
- dictionary
+ dictionary,
+ messageHelperClass,
+ messageHelperParams
)
}

MODIFY
BackEnd/Core/sailfish-core/src/main/kotlin/com/exactpro/sf/externalapi/codec/impl/ExternalMinaCodec.kt
BackEnd/Core/sailfish-core/src/main/kotlin/com/exactpro/sf/externalapi/codec/impl/ExternalMinaCodec.kt
@@ -25,6 +25,7 @@ import com.exactpro.sf.externalapi.codec.IExternalCodec
import com.exactpro.sf.externalapi.codec.IExternalCodecContext
import com.exactpro.sf.externalapi.codec.IExternalCodecContext.Role
import com.exactpro.sf.services.IServiceContext
+import com.exactpro.sf.services.MessageHelper
import com.exactpro.sf.services.MockProtocolDecoderOutput
import com.exactpro.sf.services.MockProtocolEncoderOutput
import org.apache.mina.core.buffer.IoBuffer
@@ -36,12 +37,18 @@ class ExternalMinaCodec(
serviceContext: IServiceContext,
settings: ICommonSettings,
messageFactory: IMessageFactory,
- dictionary: IDictionaryStructure
+ dictionary: IDictionaryStructure,
+ messageHelperClass: Class<out MessageHelper>?,
+ private val messageHelperParams: Map<String, String> = emptyMap()
) : IExternalCodec {
private val codec: AbstractCodec = codecClass.newInstance().apply {
init(serviceContext, settings, messageFactory, dictionary)
}
+ private val messageHelper: MessageHelper? = messageHelperClass?.newInstance()?.apply {
+ init(messageFactory, dictionary)
+ }
+
private val encodeSession = DummySession()
private val decodeSession = DummySession()
@@ -52,7 +59,7 @@ class ExternalMinaCodec(
override fun encode(message: IMessage, context: IExternalCodecContext): ByteArray = encodeOutput.runCatching {
encodeSession.setContext(context)
- codec.encode(encodeSession, message, this)
+ codec.encode(encodeSession, messageHelper?.prepareMessageToEncode(message, messageHelperParams) ?: message, this)
check(messageQueue.size == 1) { "Expected 1 result, but got: ${messageQueue.size}" }
(messageQueue.poll() as IoBuffer).run { ByteArray(remaining()).apply { get(this) } }
}.getOrElse {

MODIFY
BackEnd/Service/service-fast/src/main/kotlin/com/exactpro/sf/externalapi/codec/impl/ExternalFastCodecFactory.kt
BackEnd/Service/service-fast/src/main/kotlin/com/exactpro/sf/externalapi/codec/impl/ExternalFastCodecFactory.kt
@@ -19,11 +19,15 @@ import com.exactpro.sf.common.codecs.AbstractCodec
import com.exactpro.sf.common.messages.IMessageFactory
import com.exactpro.sf.common.util.ICommonSettings
import com.exactpro.sf.configuration.factory.FASTMessageFactory
+import com.exactpro.sf.services.MessageHelper
import com.exactpro.sf.services.fast.FASTCodec
import com.exactpro.sf.services.fast.FASTCodecSettings
+import com.exactpro.sf.services.fast.FASTMessageHelper
class ExternalFastCodecFactory : AbstractExternalMinaCodecFactory() {
override val codecClass: Class<out AbstractCodec> = FASTCodec::class.java
override val settingsClass: Class<out ICommonSettings> = FASTCodecSettings::class.java
override val messageFactoryClass: Class<out IMessageFactory> = FASTMessageFactory::class.java
+ override val messageHelperClass: Class<out MessageHelper> = FASTMessageHelper::class.java
+ override val messageHelperParams: Map<String, String> = emptyMap()
}
\ No newline at end of file

MODIFY
BackEnd/Service/service-fix/src/main/kotlin/com/exactpro/sf/externalapi/codec/impl/ExternalFixCodecFactory.kt
BackEnd/Service/service-fix/src/main/kotlin/com/exactpro/sf/externalapi/codec/impl/ExternalFixCodecFactory.kt
@@ -19,11 +19,15 @@ import com.exactpro.sf.common.codecs.AbstractCodec
import com.exactpro.sf.common.messages.IMessageFactory
import com.exactpro.sf.common.util.ICommonSettings
import com.exactpro.sf.configuration.factory.FixMessageFactory
+import com.exactpro.sf.services.MessageHelper
import com.exactpro.sf.services.fix.FIXCodec
+import com.exactpro.sf.services.fix.FixMessageHelper
import com.exactpro.sf.services.tcpip.TCPIPSettings
class ExternalFixCodecFactory : AbstractExternalMinaCodecFactory() {
override val codecClass: Class<out AbstractCodec> = FIXCodec::class.java
override val settingsClass: Class<out ICommonSettings> = TCPIPSettings::class.java
override val messageFactoryClass: Class<out IMessageFactory> = FixMessageFactory::class.java
+ override val messageHelperClass: Class<out MessageHelper> = FixMessageHelper::class.java
+ override val messageHelperParams: Map<String, String> = emptyMap()
}
\ No newline at end of file

MODIFY
BackEnd/Service/service-itch/src/main/kotlin/com/exactpro/sf/externalapi/codec/impl/ExternalItchCodecFactory.kt
BackEnd/Service/service-itch/src/main/kotlin/com/exactpro/sf/externalapi/codec/impl/ExternalItchCodecFactory.kt
@@ -19,11 +19,19 @@ import com.exactpro.sf.common.codecs.AbstractCodec
import com.exactpro.sf.common.messages.IMessageFactory
import com.exactpro.sf.common.util.ICommonSettings
import com.exactpro.sf.configuration.factory.ITCHMessageFactory
+import com.exactpro.sf.services.MessageHelper
import com.exactpro.sf.services.itch.ITCHCodec
import com.exactpro.sf.services.itch.ITCHCodecSettings
+import com.exactpro.sf.services.itch.ITCHMessageHelper
class ExternalItchCodecFactory : AbstractExternalMinaCodecFactory() {
override val codecClass: Class<out AbstractCodec> = ITCHCodec::class.java
override val messageFactoryClass: Class<out IMessageFactory> = ITCHMessageFactory::class.java
override val settingsClass: Class<out ICommonSettings> = ITCHCodecSettings::class.java
+ override val messageHelperClass: Class<out MessageHelper> = ITCHMessageHelper::class.java
+ override val messageHelperParams: Map<String, String> = mapOf(ITCHMessageHelper.FIELD_MARKET_DATA_GROUP_NAME to "0",
+ ITCHMessageHelper.FIELD_SEQUENCE_NUMBER_NAME to "0",
+ ITCHMessageHelper.FIELD_MESSAGE_COUNT_NAME to "1",
+ ITCHMessageHelper.FIELD_LENGTH_NAME to "0"
+ )
}
\ No newline at end of file

MODIFY
BackEnd/Service/service-ntg/src/main/kotlin/com/exactpro/sf/externalapi/codec/impl/ExternalNtgCodecFactory.kt
BackEnd/Service/service-ntg/src/main/kotlin/com/exactpro/sf/externalapi/codec/impl/ExternalNtgCodecFactory.kt
@@ -19,10 +19,14 @@ import com.exactpro.sf.common.codecs.AbstractCodec
import com.exactpro.sf.common.messages.IMessageFactory
import com.exactpro.sf.common.util.ICommonSettings
import com.exactpro.sf.configuration.factory.NTGMessageFactory
+import com.exactpro.sf.services.MessageHelper
import com.exactpro.sf.services.ntg.NTGCodec
+import com.exactpro.sf.services.ntg.NTGMessageHelper
class ExternalNtgCodecFactory : AbstractExternalMinaCodecFactory() {
override val codecClass: Class<out AbstractCodec> = NTGCodec::class.java
override val settingsClass: Class<out ICommonSettings> = DummyCodecSettings::class.java
override val messageFactoryClass: Class<out IMessageFactory> = NTGMessageFactory::class.java
+ override val messageHelperClass: Class<out MessageHelper> = NTGMessageHelper::class.java
+ override val messageHelperParams: Map<String, String> = emptyMap()
}
\ No newline at end of file

TH2 #1450. Create new AbstractTh2ExternalMinaCodecFactory with MessageHelper

Change-Id: Ie719e3b612a4d350c738d262192c4f4d66746dc7