2

I'm trying to run a full ADTF configuration from my own C++ command-line application using the ADTF SDK. ADTF version: 2.9.1 (pretty old).

Here's what I have (want) to do:

  1. Load manifest file
  2. Load globals-xml
  3. Load config-xml

2 & 3 are done, using the session-manager service - see ISessionManager interface: https://support.digitalwerk.net/adtf/v2/adtf_sdk_html_docs/classadtf_1_1_i_session_manager.html , functions LoadGlobalsFromFile & LoadConfigFromFile.

The problem is that I don't know how to do point 1: currently, instead of loading a manifest, I manually load the list of services myself using _runtime->RegisterPlugin, _runtime->CreateInstance and _runtime->RegisterObject.

What I've managed to do is to load only the namespace service and use the INamespace interface which has a method for loading manifest files: https://support.digitalwerk.net/adtf/v2/adtf_sdk_html_docs/classadtf_1_1_i_namespace.html - see ImportFile with ui32ImportFlags = CF_IMPORT_MANIFEST.

But this only loads the manifest settings into the namespace, it doesn't actually instantiate the services. I could do it manually, by:

  1. Do _runtime->RegisterPlugin for every url under root/plugins/ in the namespace
  2. Do _runtime->CreateInstance for every objectid under root/services/ in the namespace

But I want this to be more robust and I'm hoping there's already a service that handles the populated namespace subsequently and does these actions. Is there such a service?

Note: if you know how this could be done in ADTF3 that might also be of help for me, so don't hesitate to answer/comment

UPDATE

See "Flow of the system" on this page: https://support.digitalwerk.net/adtf/v2/adtf_sdk_html_docs/page_service_layer.html

Apparently the runtime instance itself handles the manifest file (see run-levels shutdown & kernel) but I don't know how I'm supposed to tell it where it is.

I've tried setting the command-line arguments to be count = 2 and the 2nd = manifest file path when instantiating cRuntime. It doesn't work :).

Zuzu Corneliu
  • 1,594
  • 2
  • 15
  • 27

3 Answers3

3

In ADTF3 you can just use the supplied cADTFSystem class to initiate an ADTF system and then use the ISessionManager interface to load a session of your choice.

Martin
  • 71
  • 1
  • @CorneliuZuzu, the file corresponding to an ADTF2 manifest is called .adtfsystem in ADTF3. It still defines which plugins are loaded and which services are instantiated. And yes, cADTFSystem in combination with the session manager found in the adtf_core.adtfplugin supports everything you can do with the adtf_launcher executable as well. An ADTF session (.adtfsession) defines the combination of .adtfsystem, .adtfgraph and .adtfproperties files. – Martin Dec 13 '18 at 11:34
  • Ah, I understand. And what is the exact procedure? I don't see cADTFSystem to offer a method to load an .adtfsystem file either, just as the cRuntime in ADTF2 doesn't offer a method to load a manifest file. https://support.digitalwerk.net/adtf/v3/adtf_html/classadtf_1_1system_1_1ant_1_1c_a_d_t_f_system.html – Zuzu Corneliu Dec 13 '18 at 11:52
  • Create your cADTFSystem instance and call its Launch method, then retrieve the adtf::services::ISessionManager interface via the runtime. This interface offers a CreateSession(...) method. – Martin Dec 13 '18 at 12:17
  • I see, so the ISessionManager has this capability. I'm guessing the session-manager service needs to be loaded manually, as in ADTF2, yes? – Zuzu Corneliu Dec 13 '18 at 17:32
  • Please take a look at the cADTFSystem class definition. Just pass the filename of the adtf_core.adtfplugin to it's SetADTFCorePlugin method and then call the EnableSessionManagerCreation method before you call Launch. – Martin Dec 14 '18 at 18:46
2

Found the answer, not exactly what I expected though. I tried debugging adtf_runtime.exe to find out what arguments it passes to cRuntime.

The result is indeed similar to what I've suspected (and actually tried):

  • arg1 = adtf_runtime.exe (argv[0] in adtf_runtime)
  • arg2 = full path to manifest file (e.g. $(ADTF_DIR)\bin\adtf_devenv.manifest)
  • arg3 = basename of manifest file, without extension (e.g. "adtf_devenv")

While this suggested that cRuntime indeed is responsible with loading and handling the manifest, it turned out to be NOT quite so, passing the same arguments to it did not do the job. The answer came when I noticed that adtf_runtime.exe was actually using an extension of cRuntime called cRuntimeEx which is NOT part of the SDK (at least I haven't found it).

This class IS among the exported symbols of the ADTF SDK library, i.e. a "dumpbin /symbols adtfsdk_290.lib" renders at some point:

public: __cdecl adtf::cRuntimeEx::cRuntimeEx(int,char const * * const,class ucom::IException * *)

but it is NOT part of the SDK (you won't find a header file defining it).

Among its methods you'll also find this:

protected: long __cdecl adtf::cRuntimeEx::LoadManifest(class adtf_util::cString const &,class std::set,class std::allocator > *,class ucom::IException * *)

Voila. And thus, unfortunately, I cannot achieve what I wanted in a robust fashion. :)

I ended up manually implementing the manifest-loading logic, since cRuntimeEx is not made available within the SDK. Something along these lines:

  1. Use a cDOM instance to load the manifest file
  2. Call FindNodes("/adtf:manifest/environment/variable") to find the environment-variables that need to be set and set them using "cSystem::SetEnvVariable"
  3. Call FindNodes("/adtf:manifest/dependencies/platform") to find library dependencies and use cDynamicLinkage::Load to load the libraries that target the current platform (win32/linux)
  4. Call FindNodes("/adtf:manifest/plugins/plugin") to find the services to be loaded using _runtime->RegisterPlugin (you may also handle "optional" attribute)
  5. Call FindNodes("/adtf:manifest/services/service") to find the services that need to be created using _runtime->CreateInstance and _runtime->RegisterObject (you may also handle "optional" attribute)
  6. And, finally, call FindNodes("/adtf:manifest/manifests/manifest") to (recursively) load child-manifests (you may also handle "optional" attribute)
Zuzu Corneliu
  • 1,594
  • 2
  • 15
  • 27
0

The only thing you need to do is start the adtf launcher with the meta files (manifest. This works for adtf 2 as well as for adtf 3. It can be done (console) application. If you also want to do a little bit more in adtf 3, you can use adtf control instead of adtf launcher with its scripting interface (see the scripts under examples)

C-3PFLO
  • 311
  • 2
  • 4
  • Hi @C-3PFLO, thank you for your answer. I want to do what adtf-launcher does programatically, from my own C++ application. I need to do this because there are also some other custom things I'm trying to achieve programatically. – Zuzu Corneliu Nov 30 '18 at 14:27