ACS Course Transparent XML DeSerialization in Java H

  • Slides: 14
Download presentation
ACS Course Transparent XML De-/Serialization in Java H. Sommer ESO - Garching 23 June

ACS Course Transparent XML De-/Serialization in Java H. Sommer ESO - Garching 23 June – 02 July, 2003

XML Invisible ALMA Project Flat-XML API seen from outside: Xml. Entity. Struct 19. November

XML Invisible ALMA Project Flat-XML API seen from outside: Xml. Entity. Struct 19. November 2002 Comp Transparent-XML API implemented by component: Sched. Block Comp De-/Serialization layer (dynamic) XML container Comp XML container 2

XML Invisible easy programming ALMA Project • Java component implementation code can work with

XML Invisible easy programming ALMA Project • Java component implementation code can work with binding classes directly, without having to convert parameters in the functional interface methods • Same for (Java) clients of the component: they see the component with an interface that takes binding classes, rather than flat XML (i. e. Xml. Entity. Struct) • It’s still possible to use the plain CORBA component interface, e. g. from a client that’s not written in Java 19. November 2002 3

XML Invisible how it works ALMA Project • Custom IDL compiler recognizes XML-entity typedefs

XML Invisible how it works ALMA Project • Custom IDL compiler recognizes XML-entity typedefs in IDL and constructs “inner” interface that uses binding classes instead of Xml. Entity. Structs. • Container can map between the CORBA-IF and the inner IF at runtime, by serializing and deserializing binding objects to/from Xml. Entity. Structs • Communication between components inside a container can be optimized to cut out XML serialization completely – binding objects are passed in memory. 19. November 2002 4

Schema + IDL Implementation code sees only binding classes ALMA Project Complex data type

Schema + IDL Implementation code sees only binding classes ALMA Project Complex data type defined as XML schema “Sched. Block. xsd” typedef Xml. Entity. Struct Sched. Block; <xsd: element name=“Sched. Block”> ref 0. . 1 void take. Sched. Block( Sched. Block sb ) 1. . n instance level 19. November 2002 Sched. Block XML document implements meta level Client component Operation defined in CORBA IDL Server component 5

Custom IDL compiler ALMA Project Flat-XML “My. Interface” IDL IF typedef xmlstring Obs. Project;

Custom IDL compiler ALMA Project Flat-XML “My. Interface” IDL IF typedef xmlstring Obs. Project; … Obs. Project get. Obs. Project() CORBA IDL compiler ACS IDL compiler Xml. Entity. Struct get. Obs. Project() Transparent-XML “My. Interface. J” alma. data. Obs. Project get. Obs. Project() Makefile mapping info: “Obs. Project” -> alma. data. Obs. Project 19. November 2002 together in one JAR file 6

Example: IDL from jcontexmpl/idl/Xml. Component. idl ALMA Project typedef xmlentity: : Xml. Entity. Struct

Example: IDL from jcontexmpl/idl/Xml. Component. idl ALMA Project typedef xmlentity: : Xml. Entity. Struct Obs. Proposal; typedef xmlentity: : Xml. Entity. Struct Sched. Block; typedef sequence <Sched. Block> Sched. Block. Seq; interface Xml. Component { Obs. Proposal create. Obs. Proposal(); Sched. Block. Seq get. All. Sched. Blocks(); void xml. In. Out. Method(in Obs. Proposal ops. Prop. In, out Sched. Block sched. Block. Out); … } Garching, 23 June – 02 July 2003 ALMA Common Software course 7

Example: Xml. Component IF created by the CORBA IDL compiler ALMA Project public interface

Example: Xml. Component IF created by the CORBA IDL compiler ALMA Project public interface Xml. Component. Operations { alma. xmlentity. Xml. Entity. Struct create. Obs. Proposal(); alma. xmlentity. Xml. Entity. Struct[] get. All. Sched. Blocks(); void xml. In. Out. Method(alma. xmlentity. Xml. Entity. Struct ops. Prop. In, alma. xmlentity. Xml. Entity. Struct. Holder sched. Block. Out); } Garching, 23 June – 02 July 2003 ALMA Common Software course 8

Example: Xml. Component IF created by the ACS IDL compiler ALMA Project ACS IDL

Example: Xml. Component IF created by the ACS IDL compiler ALMA Project ACS IDL compiler public interface Xml. Component. J adds a “J” { public alma. xmljbind. test. obsproposal. Obs. Proposal create. Obs. Proposal(); public alma. xmljbind. test. schedblock. Sched. Block[] get. All. Sched. Blocks(); public void xml. In. Out. Method(alma. xmljbind. test. obsproposal. Obs. Prop osal ops. Prop. In, alma. demo. Sched. Block. Holder sched. Block. Out); Garching, 23 June – 02 July 2003 ALMA Common Software course 9

ALMA Project Example: Component Implementation package alma. demo. Xml. Component. Impl; public class Xml.

ALMA Project Example: Component Implementation package alma. demo. Xml. Component. Impl; public class Xml. Component. Impl extends Component. Impl. Base implements Xml. Component. J { public Obs. Proposal create. Obs. Proposal() { Obs. Proposal obs. Prop = new Obs. Proposal(); obs. Prop. set. Performance. Goals(“whatever. "); return obs. Prop; } Garching, 23 June – 02 July 2003 ALMA Common Software course 10

Client side (components acting as clients, or non-component clients) ALMA Project Container. Services#get. Component

Client side (components acting as clients, or non-component clients) ALMA Project Container. Services#get. Component returns the „flat-XML“ interface org. omg. CORBA. Object comp. Obj = serv. get. Component("XMLCOMP 1"); Xml. Component xml. Comp = alma. demo. Xml. Component. Helper. narrow(comp. Obj); Wrap it using Container. Services#create. Xml. Binding. Wrapper(. . ): Xml. Component. J xml. Comp. J = (Xml. Component. J) cserv. create. Xml. Binding. Wrapper( Xml. Component. J. class, xml. Comp, Xml. Component. Operations. class); component reference 19. November 2002 “flat-XML” IF “transparent. XML” IF 11

Example: Makefile ALMA Project IDL compilation (as usual) IDL_FILES = Hello. Lamp Xml. Component

Example: Makefile ALMA Project IDL compilation (as usual) IDL_FILES = Hello. Lamp Xml. Component Triggers ACS-IDL compiler and maps IDL-typedefs to Java-XML binding classes XML_IDL= "Obs. Proposal=alma. xmljbind. test. obsproposal. Obs. Proposal; Sched. Block=alma. xmljbind. test. schedblock. Sched. Block“ No need for any XSDBIND since we reuse the binding classes from the module acstestentities, which are on the classpath. Garching, 23 June – 02 July 2003 ALMA Common Software course 12

define systementities. xml Common. Entity. xsd General. Includes. xsd xmlentity. idl systementities. jar Project

define systementities. xml Common. Entity. xsd General. Includes. xsd xmlentity. idl systementities. jar Project lib ALMA xmlentity. jar define/src/Makefile idl Inter-module referencing through INTROOT, ACSROOT idl lib <xsd: import > acstestentities acs. Test. Entities. xml Test. Obs. Project. xsd Test. Obs. Proposal. xsd Test. Sched. Block acs. Test. Entities. jar Schema-to-Java class mappings for imported schemas XSDBIND = systementities IDL_FILES = xmlentity acstestentities/src/Makefile XSDBIND = acs. Test. Entities XSDBIND_INCLUDE = systementities jcontexmpl idl Hello. Lamp. idl Xml. Component. idl lib Hello. Lamp. jar Xml. Component. jar IDL #include Inter-module referencing through INTROOT, ACSROOT jcontexmpl/src/Makefile IDL_FILES = Hello. Lamp Xml. Component XML_IDL = "Obs. Proposal=alma. xmljbind. test. obsproposal. Obs. Proposal; Sched. Block=alma. xmljbind. test. schedblock. Sched. Block” Connects IDL entity class references, e. g. the “Sched. Block” typedef xmlentity: : Xml. Entity. Struct Sched. Block; with the corresponding Java binding classes. 19. November 2002 13

Remarks ALMA Project • Transparent de-/serialisation works also for Java clients or components when

Remarks ALMA Project • Transparent de-/serialisation works also for Java clients or components when the other part is not Java; • Transport is done using plain CORBA – Stability – Accessible by any software even if it‘s not aware of binding classes • Using this transparent-XML mechanism is not mandatory. On both the client and server side of a component call, the entire interface or even individual methods can use unparsed XML: – Always if there‘s no binding class support for that language – To use a specific XML parser, or to just forward XML without parsing it at all 19. November 2002 14