A ConfigFragmentInterpreter interprets one of the keys of the domain-config json of a bundle.

ConfigFragmentInterpreters are responsible for cleaning up the created resources, if a domain bundle is stopped. Stopping a domain-bundle will result in a call to dispose on the result object of the interpret function by the DomainSystem.

Interpretation order:

  • The domain bundles are interpreted by the domain system, after the app start, as soon as a map becomes available.
  • First all bundles configured by domains-system/Config/domainBundleOrder are interpreted in the listed order, one after the other.
  • After that the life cycle hook allInitialOrderedBundlesInterpreted is called on each interpreter.
  • Then all remaining active domain bundles are interpreted. One after the other.
  • After that the life cycle hook allInitialBundlesInterpreted is called on each interpreter.
  • If a new domain-bundle is started then it will interpreted immediately.
export class MyInterpreter implements ConfigFragmentInterpreter {
allInitialOrderedBundlesInterpreted(): void {}

allInitialBundlesInterpreted(): void {}

async interpret(
configFragment: ConfigFragment,
options: InterpretationOptions
): Promise<Disposable | void> {
const myConfig = configFragment.getConfig("my-custom-key");
if (!myConfig) {
// nothing to do
return Promise.resolve();
}
// interpret the config
...
// e.g. create a resource
const resource = ...;
// interpretation is finished
return Promise.resolve({
// this is called if the interpreted domain bundle is stopped
dispose() {
// ensure created resources are cleaned
resource.cleanup();
}
});
}
}
interface ConfigFragmentInterpreter {
    allInitialBundlesInterpreted(): void;
    allInitialOrderedBundlesInterpreted(): void;
    interpret(
        bundleConfig: ConfigFragment,
        options: InterpretationOptions,
    ): Promise<void | Disposable>;
}

Methods

  • Called by domain system to inform the interpreter that all initial available domain bundles are interpreted.

    Returns void

  • Called by the domain system to inform the interpreter that all ordered domain bundles are interpreted. After that the option.isInInitialOrderedBundle will never be true.

    Returns void

  • Called by domain system if a domain bundle should be interpreted.

    Parameters

    Returns Promise<void | Disposable>

    a disposable. This is responsible to clean up resources on domain-bundle stop.