Zuzu Corneliu
Zuzu Corneliu

Reputation: 1703

ADTF SDK: import manifest AND handle it

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 :).

Upvotes: 2

Views: 389

Answers (3)

Martin
Martin

Reputation: 71

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.

Upvotes: 3

Zuzu Corneliu
Zuzu Corneliu

Reputation: 1703

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)

Upvotes: 2

C-3PFLO
C-3PFLO

Reputation: 311

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)

Upvotes: 0

Related Questions