services.xml
XML file:<services> <event name="service" > <data name="array" type="structArray" /> </event> </services>
types.xml
XML file:<simpleType name="bool" baseType="boolean" /> <simpleType name="int" baseType="int" /> <simpleType name="string" baseType="string" /> <arrayType name="structArray" type="struct" /> <structType name="struct"> <field name="bool" type="bool" /> <field name="int" type="int" /> <field name="string" type="string" /> </structType>
applications.xml
XML file:<applications> <application name="appli1"> <deployment> ... </deployment> <modules> <module name="module1"> <implementation path="..." > <initEntryPoint method="init" /> <startEntryPoint method="start" /> </implementation> <interfaces> <push service="service" attach="attach"/> </interfaces> </module> </modules> </application> <application name="appli2"> <deployment> ... </deployment> <modules> <module name="module2"> <implementation path="..." > <defaultReceiveEntryPoint method="subscribe" /> </implementation> <interfaces> <subscribe service="service"/> </interfaces> </module> </modules> </application> </applications>
@DataTag public static class StructObject { @FieldTag(field = "bool") public boolean bool = false; @FieldTag(field = "string") public String str = ""; @FieldTag(field = "int") public int val = 0; }The annotations specify that:
@DataTag
: the class maps a type@FieldTag
: the class member maps a structure fieldServiceInstance service; public void init(Module module) { service = module.getProviderService("service"); } public void start() { Data data = service.getData("array"); StructObject obj = new StructObject(); obj.bool = true; obj.str = "toto"; obj.val = 2; list.add(obj); data.setValue(list); service.invoke(); }
public void subscribe(ServiceInstance service) { Data data = service.getData("array"); StructObject obj = new StructObject(); obj.bool = true; obj.str = "toto"; obj.val = 2; list.add(obj); List<StructObject> array = (List<StructObject>)data.getValue(StructObject.class); }
Copyright 2017-2020 Dassault Aviation. All Rights Reserved. Documentation and source under the LGPL v3 licence