90 likes | 183 Views
1st ALMA Common Software Workshop. XML « Data by Value » Transport. XML Data by Value Overview. local object. remote object. transportby value. obj.getFoo(). obj.getFoo(). Application. Subsystem1. Subsystem2. fine-grained remote calls degrade performance;
E N D
1st ALMA Common Software Workshop XML « Data by Value » Transport ESO - Garching 08 – 09 March, 2004
XML Data by ValueOverview local object remote object transportby value obj.getFoo() obj.getFoo() Application Subsystem1 Subsystem2 • fine-grained remote calls degrade performance; • more runtime coupling among computers 1st ALMA Common Software Workshop
XML Data by ValueEligible Data • Reasonably small chunks of nested object data, e.g. “User”, “ObservingProject”, “CorrelatorConfig” • Simple parameters as IDL data types, not XML • Bulk data (from correlator, pipelines) transported in binary format, not considered here. • Lists of value objects don’t need to be defined as new value object types; use CORBA sequences of existing value objects instead. 1st ALMA Common Software Workshop
Why XML? • Well-accepted open standard • XML can also be used for persistence (Database or file system) without writing much extra code • XML also for non-CORBA-Transport (email, …) • XML Schema offers constraint declaration and thus enables automatic validation • We can always deal with XML “by hand”. • important for early use of ALMA software when some data producers are not yet available. • test code can easily inject XML data 1st ALMA Common Software Workshop
XML Schema Developers describe their data model in XML schemas <xsd:elementname="SchedBlock"> <xsd:complexType> <xsd:sequence> <xsd:elementname="ObsProcedure"type="xsd:string"/> <xsd:elementname="PhaseCalTarget"type="sbl:PhaseCalTargetT"/> <xsd:elementname="SchedBlockControl"type="sbl:SchedBlockControlT"/> <xsd:elementmaxOccurs="unbounded"name="ObsTarget“ type="sbl:ObsTargetT"/> </xsd:sequence> </xsd:complexType> </xsd:element> truncated example 1st ALMA Common Software Workshop
Binding ClassesConcept • A binding class object represents an XML node in memory; we would thus have a SchedBlock class. • Binding class source code is generated from the XML schemas as part of the software build process • Classes contain code for de-/serialization from and to XML • Type-safe get()/set() methods ensure that data conflicts be noticed at compile time. Huge advantage over generic handling of XML data (as done by DOM or SAX). • Classes contain validation code to enforce schema constraints 1st ALMA Common Software Workshop
Binding ClassesExample packagealma.entity.xmlbinding.schedblock; publicclassSchedBlockextendsalma.entity.xmlbinding.obsproject.ObsUnitTimplementsjava.io.Serializable { // just a few of the generated methods publicvoidaddObsTarget(TargetTvObsTarget) {…} publicjava.util.EnumerationenumerateObsTarget() {…} publicalma.entity.xmlbinding.obsproject.ImagingProcedureTgetSchedBlockImaging() {…} } 1st ALMA Common Software Workshop
Comp Comp container XML XML container Invisible XML Serializationtype-safe data access Flat-XML API seen from outside: XML-string De-/Serialization layer (dynamic) Transparent-XML API implemented by component: SchedBlock binding class, type-safe data access Comp 1st ALMA Common Software Workshop
Invisible XML SerializationStandard and XML-binding-aware Interfaces 1st ALMA Common Software Workshop