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

ExternalComm: starting and stopping services



It is possible to start and stop services (both Services for which the application is a provider or subscriber) through the two following services:
  • The http://dassault-aviation.com/externalcomm:stopServices service allow to stop an array of services
  • The http://dassault-aviation.com/externalcomm:startServices service allow to start an array of services
The services which are provided in the array of services can be declared as Strings or as NamespaceKeys.
The services are those which are defined as part of the services for which the externalComm application is a provider (received from the Network) or a subscriber (sent to the network).

Start and stop services declarations

The declaration for the "start and stop services are:
      <services>
         <namespace uri="http://dassault-aviation.com/externalcomm">            
            <event name="startServices">
               <data name="services" type="serviceArray" />
            </event>
            <event name="stopServices">
               <data name="services" type="serviceArray" />
            </event>      
         </namespace>
      </services>
And the associated types[1]
The serviceID uses a switch type to be able to use both a String or a NamespaceKey for a service identification
:
      <types>
         <namespace uri="http://dassault-aviation.com/externalcomm">     
            <simpleType name="string" baseType="string" />
            <objectType name="namespaceKey" class="org.da.protoframework.model.namespace.NamespaceKey" />
            <switchType name="serviceID" types="string namespaceKey" />
            <arrayType name="serviceArray" type="serviceID" />
         </namespace>
      </types>
The http://dassault-aviation.com/externalcomm:stopServices service and http://dassault-aviation.com/externalcomm:startServices service must be declared for the externalComm module. For example, for the External Communication tutorial applications declaration:
      <applications>
         <application name="eventAppli">
            <deployment>
               <lib url="samplesEvents.jar" />
            </deployment>
            <modules>
               <module name="EventModule"> 
                  <implementation path="org.da.samples.protoframework.event.EventModule" >
                     <initEntryPoint method="init" />
                     <defaultReceiveEntryPoint method="subscribe" />
                  </implementation>
                  <interfaces>
                     <eventSend service="event"/>
                     <subscribe service="published" />
                  </interfaces>             
               </module>
            </modules>
         </application>  
         <application name="externalCommEvent">
            <deployment>
               <lib url="externalComm.jar" />
            </deployment>
            <modules>
               <module name="externalComm"> 
                  <interfaces>
                     <eventReceived service="event"/>
                     <push service="published"/>
      <eventReceived service="stopServices"/>
                     <eventReceived service="startServices"/>
                  </interfaces>             
               </module>
            </modules>
         </application>        
      </applications>
We must also add these two services declarations:
      <services>
         <event name="event" id="1" >  
            <data name="event" type="bool" />                     
         </event>    
         <publish name="published" id="2" >  
            <data name="value" type="int" />                                     
         </publish>      
      <namespace uri="http://dassault-aviation.com/externalcomm">            
            <event name="startServices">
               <data name="services" type="serviceArray" />
            </event>
            <event name="stopServices">
               <data name="services" type="serviceArray" />
            </event>      
         </namespace>        
      </services>
and the types declarations:
      <types>
         <simpleType name="bool" baseType="boolean" />
         <simpleType name="int" baseType="int" />     
         <namespace uri="http://dassault-aviation.com/externalcomm">     
            <simpleType name="string" baseType="string" />
            <objectType name="namespaceKey" class="org.da.protoframework.model.namespace.NamespaceKey" />
            <switchType name="serviceID" types="string namespaceKey" />
            <arrayType name="serviceArray" type="serviceID" />
         </namespace>       
      </types>

Stopping a service

The http://dassault-aviation.com/externalcomm:stopServices service allow to stop an array of services. For example, if you want to stop the published service:
      ServiceInstance service = module.getService("http://dassault-aviation.com/externalcomm", "stopServices", false);
      List array = new ArrayList();
      array.add("published");
      service.setDataValue("services", array);
      service.invoke();

Starting a service

The http://dassault-aviation.com/externalcomm:startServices service allow to stop an array of services. For example, if you want to start the published service:
      ServiceInstance service = module.getService("http://dassault-aviation.com/externalcomm", "startServices", false);
      List array = new ArrayList();
      array.add("published");
      service.setDataValue("services", array);
      service.invoke();

Check the service existence

By default the module will check that a service included in a http://dassault-aviation.com/externalcomm:startServices or http://dassault-aviation.com/externalcomm:stopServices array is a service for which the externalComm application is a provider (received from the Network) or a subscriber (sent to the network).

If it is not the case, a message such as this one will be emitted in the console:
      Application externalCommPublish, Module: externalComm$1: No Service with key toto, impossible to stop Service
It is possible to set the module to be silent in this case and not emit any error by setting the checkStartStopURI property value to false.

Notes

  1. ^ The serviceID uses a switch type to be able to use both a String or a NamespaceKey for a service identification

See also


Categories: builtin-applis

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