Apama 10.15.0 | Release Notes | What's New In Apama 9.12 | Connectivity API changes in 9.12.0.1
 
Connectivity API changes in 9.12.0.1
Version 9.12.0.1 introduces a new signature for the constructor of a C++ or Java connectivity plug-in, which passes in a TransportConstructorParameters or CodecConstructorParameters object instead of a list of individual parameters.
For Java, there is a new logger field that uses the Simple Logging Facade for Java (SLF4J) instead of the Log4J LOGGER available in earlier versions.
For C++, there is a new logger field to match the Java field, but the behavior is identical to LOGGER although we recommend to use the new name where possible for consistency.
In C++ only, there are the following new macros which must be used for classes with the new 9.12.0.1 constructor:
*SAG_DECLARE_CONNECTIVITY_CODEC_CLASS (instead of SAG_DECLARE_CONNECTIVITY_CODEC)
*SAG_DECLARE_CONNECTIVITY_TRANSPORT_CLASS (instead of SAG_DECLARE_CONNECTIVITY_TRANSPORT)
The previous legacy constructors, macros and logger are still available but will be deprecated in a future release. Therefore, we recommend migrating to the new ones when possible, especially for any newly created plug-ins.
To migrate from the old C++ transport constructor and macro to the new one, change the following:
class MyPlugin: public AbstractSimpleTransport
{
public:
MyPlugin(const std::string &name, const std::string &chainId,
const map_t &config)
: AbstractSimpleTransport(name, chainId, config)
{
// do stuff with config here
// use "LOGGER" for logging
}
...
}
SAG_DECLARE_CONNECTIVITY_TRANSPORT(MyPlugin)
to:
class MyPlugin: public AbstractSimpleTransport
{
public:
MyPlugin(const TransportConstructorParameters &params)
: AbstractSimpleTransport(params)
{
// do stuff with params.getConfig() (or the config class member) here
// recommended to use "logger" for logging instead of "LOGGER"
}
...
}
// use new 9.12.0.1 macro for declaring the class
SAG_DECLARE_CONNECTIVITY_TRANSPORT_CLASS(MyPlugin)
The same applies to the C++ codecs, just replace transport with codec.
To migrate from the old Java transport constructor and logger to the new one, change the following:
public MyTransport(Map<String, Object> config, String chainId,
org.apache.log4j.Logger log4jLogger) throws Exception {
super(config, chainId, log4jLogger);
// do stuff with params.getConfig() (or the config class member) here
LOGGER.info("Transport was created correctly with config: "+config);
...
to:
public MyTransport(org.slf4j.Logger logger,
TransportConstructorParameters params) throws Exception {
super(logger, params);
logger.info("Transport was created correctly with config: "
+params.getConfig());
...
The same applies to the Java codecs, just replace transport with codec.
Be sure to change all uses of the legacy LOGGER to the new logger in your Java plug-ins. Most of the logger methods are identical (except that the new logger does not permit logging an exception without an accompanying string message).
See Requirements of a plug-in class for more information about plug-in constructors.