Home
Categories
Dictionary
Glossary
Download
Project Details
Changes Log
What Links Here
FAQ
License

OptionalServicesConfigurator usage



The OptionalServicesConfigurator class allows to get the services which are consistent to a template declaration in a module:
  • If it returns null for a Service, it means that this service is not present or not compatible with its template declaration
  • If it returns a not null value for a Service, it means that this service is present and is compatible with its template declaration

Compatibility checks

For a service to be compatinle with its reference:
  • The service must exist in the reference
  • The service must have the same type as in the reference
  • The service must be of the same direction as in the reference
  • The service must contain exactly the same datas as in the reference (note that this rule is slightly different if the valdiation is not strict, see Loose validation)
  • For each data, the type of this data must be identical as in the reference

Configuration

To configure the OptionalServicesConfigurator, you must create an instance with the following arguments:

Loose validation

If the validation is not strict, it will be allowed for a provider to have less datas than in the reference.

Example

In this example, we want to check if one service is present and compatible with a module declaration.
      // create an OptionalServicesConfigurator with the XML files defining the expected services and types
      OptionalServicesConfigurator configurator = new OptionalServicesConfigurator(module, <services definition>, <types definition>);

      // add a service provided by the module to be checked
      configurator.addService("myService", true);

      // setup the configurator, this is necessary to detect the compatible services
      configurator.setup();

      // get the service, it will return the service if it is compatible, or null if it is not
      ServiceInstance<?, ?> service = configurator.getService("myService");

See also


Categories: concepts

Copyright 2017-2020 Dassault Aviation. All Rights Reserved. Documentation and source under the LGPL v3 licence