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

Java modules



Java modules are the default modules type. A Java module is implemented in Java.

Java module implementation

Module hosting

Main Article: Application library

A Java Module is hosted in its parent application library. For example, if the module is hosted in the following application:
      <application name="Aircraft" id="1">
         <deployment>
            <lib url="aircraft.jar" />
         </deployment>
      ...
      </application>
Then it means that the code of the Module is in the aircraft.jar library.

Module version

Main Article: Check Modules Version

A library version for the application can be specified in the Manifest of the Application jar file with the Version manifest property.

For example:
      Version: 12.1
If the showLibVersion property is set in the framework properties, this version String will be shown in the logger.

Module path

The module path is the class which will be instanciated for the Module at the initialization of the framework. Note that this class will be instanciated by reflection. This means that:
  • This class must be public and have a public constructor without argument
  • This does not prevent from having more than one class for the Module, but all classes will be accessed through this class

Module entry points

Declaring the default module entry points

Several entry points for the module can be defined:
  • The initEntryPoint: defines the method which will be called at the end of the framework initialization
  • The preConfigureEntryPoint: defines the method which will be called when the framework is preconfigured
  • The startEntryPoint: defines the method which will be called at the start of the framework
  • The finishInvokeEntryPoint: defines the method which will be called after a service has been invoked from this module, when all the notified modules have finished their operations
  • The defaultReceiveEntryPoint: defines the default method which will be called by default when receiving the result from a Service
  • The defaultSendEntryPoint: defines the default method which will be called by default when invoking automatically a Service[1]
    some publish Services and event Servicescan be called cyclically
  • The cyclicMethod: Additionally, it is possible to declare methods which will be called cyclically without invoking any Service (see Declaring cyclic methods)
  • The defaultTriggerEntryPoint: defines the default method which will be called by default if the service is triggering an event service
  • The endEntryPoint: defines the method which will be called at the shutdown of the framework
Note that none of these entry points are mandatory.

Init EntryPoint


The signature of this method must be: <method_name>(Module module). The method will be called once after the framework has been initialized. It can be used to get the Services which are accessible to the Module.

You must be aware that the module will only be able to access properties and services when it has been initialized. For example with the following module declaration:
      <module name="theModule">
         <implementation path="org.da.MyModule" >
            <initEntryPoint method="init" />
         </implementation>
         <interfaces>
            <eventSend service="sendService" />
         </interfaces>
      </module>
You can perform the following code:
      public class MyModule() {
         private ServiceInstance sendService = null;
         public init(Module module) {
           this.sendService = module.getService("sendService");
         }
      }

Start EntryPoint

The signature of this method must be: <method_name>(). The method will be called once after the framework has been started.

You must be aware that you will be notified from services and you will be able to send services only after the start.

For example:
      <module name="theModule">
         <implementation path="org.da.MyModule" >
            <startEntryPoint method="start" />
         </implementation>
         <interfaces>
            <eventSend service="sendService" />
         </interfaces>
      </module>

End EntryPoint

The signature of this method must be: <method_name>(). The method will be called once after the framework has been shutdown.

For example:
      <module name="theModule">
         <implementation path="org.da.MyModule" >
            <endEntryPoint method="init" />
         </implementation>
         <interfaces>
            <eventSend service="sendService" />
         </interfaces>
      </module>

Preconfigure EntryPoint

The signature of this method must be: <method_name>(Module module). The method will be called when the framework is preconfigured. Defining this method can be useful if you want to define module properties programmatically.

For example:
      <module name="theModule">
         <implementation path="org.da.MyModule" >
            <preConfigureEntryPoint method="configure" />
         </implementation>
         <interfaces>
            <eventReceived service="sendService" />
         </interfaces>
      </module>

Default receive EntryPoint

The signature of this method must be: <method_name>(ServiceInstance service). The method will be called each time a Service result is received by the Module. It can be used to perform computations after the Module has been notified from the Service result.

For example:
      <module name="theModule">
         <implementation path="org.da.MyModule" >
            <defaultReceiveEntryPoint method="subscribe" />
         </implementation>
         <interfaces>
            <eventReceived service="sendService" />
         </interfaces>
      </module>

FinishInvoke EntryPoint

The signature of this method must be <method_name>(ServiceInstance service). The method will be called after a service has been invoked from this module, when all the notified modules have finished their operations.
finishinvoke
For example:
      <module name="theModule">
         <implementation path="org.da.MyModule" >
            <finishInvokeEntryPoint method="finish" />
         </implementation>
         <interfaces>
            <eventSend service="sendService" />
         </interfaces>
      </module>

Default trigger EntryPoint


The signature of this method must be: <method_name>(ServiceInstance service, ServiceInstance service). The method will be called after the notification if the service is triggering another one. The first argument is the triggering service (which must be a subscribed event service), the second is the triggered service (which must be a provided event service).

For example:
      <module name="theModule">
         <implementation path="org.da.MyModule" >
            <defaultTriggerEntryPoint method="trigger" />
         </implementation>
         <interfaces>
            <eventReceived service="triggeringService" />
            <eventSend service="triggeredService" />
         </interfaces>
      </module>

Default send EntryPoint

The signature of this method must be: <method_name>(ServiceInstance service). The method will be called each time a Service invoked automatically is invoked (just before sending its result).

It can be used to perform computations before invoking the Service (for example, setting values to datas).

For example:
      <module name="theModule">
         <implementation path="org.da.MyModule" >
            <defaultSendEntryPoint method="publish" />
         </implementation>
         <interfaces>
            <eventSend service="sendService" />
         </interfaces>
      </module>

Module entry points example

      <module name="FlightManagementSystem" id="1" >
         <implementation path="org.da.aircraft.fms.FMS" >
            <initEntryPoint method="init" />
            <startEntryPoint method="start" />
            <defaultReceiveEntryPoint method="receive" />
            <defaultSendEntryPoint method="send" />
         </implementation>
      </module>
We will have the following signature for the methods:
      public class FMS {
        public FMS() {
        }

        public init(Module module) {
        }

        public start() {
        }

        public receive(ServiceInstance service) {
        }

        public send(ServiceInstance service) {
        }
      }

Declaring cyclic methods

It is possible in the implementation to declare methods which will be called cyclically without invoking any Service. This is useful if you want to call one or several methods cyclically without invoking automatically any Service.

Cyclic methods example

For example:
      <module name="HUD" >
         <implementation path="org.da.aircraft.cockpit.HUD" >
            <initEntryPoint method="init" />
            <startEntryPoint method="start" />
            <defaultReceiveEntryPoint method="receive" />
            <cyclicMethod method="myMethod" frequency="100ms" />
         </implementation>
      </module>
In this example, myMethod() method of the org.da.aircraft.cockpit.HUD class will be called every 100 ms.

Defining specific service module entry points

For each service, it is possible to declare specific entry-points which will be used for the Service rather than the default entry points declared globally for the Module. See service implementation

Interfacing with the services

See Java modules service interface.

Defining module properties

See module properties configuration.

Example

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" >
         <implementation path="org.da.aircraft.fms.FMS" >
            <initEntryPoint method="init" />
            <startEntryPoint method="start" />
            <defaultReceiveEntryPoint method="receive" />
            <defaultSendEntryPoint method="send" />
         </implementation>
         <interfaces>
            <subscribe service="position" />
            <eventReceived service="directTo"/>
            <requestReceived service="computeFlightPlan"/>
         </interfaces>
      </module>

Notes

  1. ^ some publish Services and event Servicescan be called cyclically

See also


Categories: concepts | development

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