Calling a Java TPS from Tcl

The relevant Tcl extensions are makeUpocInstance, processTPS, and destroyUpocInstance.

These can be used directly, or a pre-provided Tcl procedure cljTPS, which is itself a TPS-style interface, can be used to wrap them. Usually, the wrapping is adequate. There are situations, though, where Java UPoC instances are created implicitly through the wrapper and are not destroyed until the Tcl interpreter shuts down.

cljTPS requires that the ARGS include a key CLASS which has the fully-qualified name of the TPS subclass to be used. The ARGS keyed list must match any PropertyTree keys that the Java UPoC is expecting.

cljTPS can be called directly. The curly bracket syntax in the keyed list is difficult at times, so a further wrapper is provided to wrap it.

proc jtpsRun {context class msgid {userArgs {}} } {
        keylset userArgs CLASS $class
        return [cljTPS "CONTEXT $context" "MODE run" \
                "MSGID $msgid" "ARGS {$userArgs}"]
}
proc jtpsStart {context class {userArgs {}} } {
        keylset userArgs CLASS $class
        return [cljTPS "CONTEXT $context" "MODE start" \
                "MSGID $msgid" "ARGS {$userArgs}"]
}
proc jtpsTime {context class {userArgs {}} } {
        keylset userArgs CLASS $class
        return [cljTPS "CONTEXT $context" "MODE time" \
                "MSGID $msgid" "ARGS {$userArgs}"]
}
proc jtpsStop {context class {userArgs {}} } {
        keylset userArgs CLASS $class
        return [cljTPS "CONTEXT $context" "MODE stop" \
                "MSGID $msgid" "ARGS {$userArgs}"]
}

These can be used with no user arguments:

jtpsRun sms_ib_data sample.SampleTPS message0

With the user argument CHUNKSIZE:

keylset sample2Args CHUNKSIZE 30
jtpsRun sms_ib_data sample.Sample2TPS message0 $sample2Args

The return value is a disposition list. Depending on what is required, the caller could iterate through this and look at the individual messages. At this point, it is already in the correct format to be returned to the engine.

A new instance is created implicitly whenever different user arguments are specified for the first time. There is no requirement to invoke Start mode first if the Java TPS does not require to be called in Start mode for any reason.