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

Service



Services are processing units which are provided or required by modules[1]
See Service-oriented framework on Wikipedia
.

A Service has a contract and associated input and output datas[2]
It is perfectly valid for a Service to not have associated Datas at all. For example, it can be sufficient to be notified from the execution of an Event Service without the need to have any additional datas, such as a click on a Button for example
. Note that Services are not always unidirectional. For example a Request-Response Service can be invoked:
  • By a Service subscriber: to emit a request
  • By the Service provider: to return the response to a request

Overview


archi
A module:
  • Provides Services
  • Subscribe to Services
Typically the runtime cycle for a Service is:
  • A module invoke the Service
  • The framework sends the result of the Service to the modules which must be notified of the invocation[3]
    That can be on the same JVM, on the same platform, or even on the Network
  • Each notified module executes the methods associated with the Service notification

Service contract

There are several kinds of Services, each with an associated contract:
  • publish Service: The provider updates datas associated with the Service, and publish these datas to all subscribed Modules. A Publication Service can only have one active provider at a time. The values of Datas which have not been updated keep their previous value
  • Event Service: The provider set the data values associated with the Service, and publish these datas to all subscribed Modules. A Publication Service can have more than active provider at a time. The values of Datas which have not been updated take their default value
  • Request-Response Service: A subscriber sends a request to the provider associated with request datas. The provider sends a response corresponding to this request with the associated response datas

Declaring the Service

The declaration of the Service is performed in the services configuration XML file. To declare the Service, you must specify:
  • The Service name. The service name is mandatory
  • The Service numeric ID (which is a long). The service ID is optional
Both the name and ID must be unique for all the declared services. Note that each data declared in the Service must be unique inside the Service.

For example:
      <publish name="position" id="1" >
         <data name="latitude" type="float" />
         <data name="longitude" type="float" />
         <data name="altitude" type="float" />
      </publish>
The declaration of the content of the Service itself (the datas associated with the Service) depends on the Service type.

Using namespaces

Main Article: Namespace

To avoid names clashes, it is possible to define namespaces for services. To define a namespace, you just have to declare the namespace element as a parent of the services declaration[4]
Of course, you can define more than one namespace in a services XML file
. For example:
      <services>
        <namespace uri="http://mydomain.com/aircraft" >
          <publish name="position" >
            <data name="latitude" type="float" />
            <data name="longitude" type="float" />
            <data name="altitude" type="float" />
          </publish>
          <publish name="speed" >
              <data name="speedNorth" type="float" />
              <data name="speedEast" type="float" />
              <data name="speedDown" type="float" />
           </publish>
        </namespace>
      </services>
Note that services of a specified namespace can access types of the same namespace, or types with no namespace declaration.

Specifying how the service should be invoked

Main Article: Invoking a service

It is possible to set the mode of invocation at the service level by specifying the value of the invocationMode attribute in the service definition:
  • By default the framework behavior will be used
  • If the attribute has the executorService value, the framework will perform the invocation in a background Thread
  • If the property has the blocking value, the framework will perform the invocation in the same Thread as the caller[5]
    See blocking for more information


For example:
      <publish name="position" invocationMode="blocking" >
         <data name="latitude" type="float" />
         <data name="longitude" type="float" />
         <data name="altitude" type="float" />
      </publish>

Interfacing with the Service

The declaration of a Service does not mention which modules provide this Service and which modules subscribe to this Service. This means that a module which uses the Service (for invocation or subscription) has not direct link to the other modules associated with this Service. For example, if you declare a position Service, you don't declare directly with the Service:
  • Which module provides the position
  • Which modules subscribe to the position
It is even possible and it is not an error to define a Service which is never provided or has no subscribed modules[6]
In the example above, we can have no module providing the position but have modules subscribing to it, which means that they will never be notified of a position publication. Or we can have a provider but have no subscribers, which means that if the provider invokes the Service, no module will be notified
.

It is allowed and it is not an error for a Module to be both a provider and subscriver of a Service. See also being both a provider and a subscriber of a Service.

Service providers


A Service provider is a module which executes the Service. The result of the Service execution is notified to its subscribers.

Some services may only have one active provider, whereas other services can have several providers. For example:
  • A publish Service is designed to send datas to its subscribers (even cyclically), so only provider can be active
  • An event Service is designed to send events to its subscribers, so more than one provider can be active

Service subscribers


A Service subscriber is a module which is notified from the Service execution. Not that which subscriber is notified depends on the Service contract. For example:
  • A publish Service sends its datas to all its subscribers
  • Even if a request-response Service may have more than one subscriber, the provider only sends the response to the subscriber which sent the request

Declaring the Service interface

The declaration of the Service interface is performed in the module configuration:
  • The module declares for which services it interfaces to
  • For each Service it interfaces to, it specifies if it is a provider or a subscriber of this Service
  • Several properties can be defined depending on the Service type
In the following example, the FlightManagementSystem module:
  • subscribe to the position publish service
  • subscribe to the directTo event service
  • provides the computeFlightPlan request-response service
      <module name="FlightManagementSystem" id="1" >
         <interfaces>
            <subscribe service="position" />
            <eventReceived service="directTo"/>
            <requestReceived service="computeFlightPlan"/>
         </interfaces>
      </module>

serviceintexample

Interfacing with services which have a namespace

Main Article: Namespace

To interface with services which have a namespace, you jyst have to add the namespace uri to the declaration. For example:
      <module name="FlightManagementSystem" id="1" >
         <interfaces>
            <subscribe service="position" uri="http://mydomain.com/aircraft" />
            <eventReceived service="directTo"/>
            <requestReceived service="computeFlightPlan"/>
         </interfaces>
      </module>

Service alias

Main Article: Service alias

A Service alias is an alias name for another Service.

Services implementation

Main Article: Service implementation

The declaration of the Service interface is performed in the Module configuration:
  • The module declares for which services it interfaces to
  • For each Service it interfaces to, it specifies if it is a provider or a subscriber of this Service
  • Several properties can be defined depending on the Service type

Example

      <services>
         <publish name="position" id="1" >
            <data name="latitude" type="float" />
            <data name="longitude" type="float" />
            <data name="altitude" type="float" />
         </publish>
      </services>
With namespaces:
      <services>
        <namespace uri="http://mydomain.com" >
           <publish name="position" id="1" >
              <data name="latitude" type="float" />
              <data name="longitude" type="float" />
              <data name="altitude" type="float" />
           </publish>
        </namespace>
      </services>

Notes

  1. ^ See Service-oriented framework on Wikipedia
  2. ^ It is perfectly valid for a Service to not have associated Datas at all. For example, it can be sufficient to be notified from the execution of an Event Service without the need to have any additional datas, such as a click on a Button for example
  3. ^ That can be on the same JVM, on the same platform, or even on the Network
  4. ^ Of course, you can define more than one namespace in a services XML file
  5. ^ See blocking for more information
  6. ^ In the example above, we can have no module providing the position but have modules subscribing to it, which means that they will never be notified of a position publication. Or we can have a provider but have no subscribers, which means that if the provider invokes the Service, no module will be notified

See also


Categories: concepts

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