Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "ESO - Garching 23 June – 02 July, 2003 ACS Course Transparent XML De-/Serialization in Java H. Sommer."— Presentation transcript:

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

2 ALMA Project 2Garching, 23 June – 02 July 2003ALMA Common Software course XML Invisible container Comp container Comp XML Comp Flat-XML API seen from outside: XmlEntityStruct Transparent-XML API implemented by component: SchedBlock De-/Serialization layer (dynamic) XML

3 ALMA Project 3Garching, 23 June – 02 July 2003ALMA Common Software course XML Invisible easy programming 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. XmlEntityStruct) It’s still possible to use the plain CORBA component interface, e.g. from a client that’s not written in Java

4 ALMA Project 4Garching, 23 June – 02 July 2003ALMA Common Software course XML Invisible how it works Custom IDL compiler recognizes XML-entity typedefs in IDL and constructs “inner” interface that uses binding classes instead of XmlEntityStructs. Container can map between the CORBA-IF and the inner IF at runtime, by serializing and deserializing binding objects to/from XmlEntityStructs Communication between components inside a container can be optimized to cut out XML serialization completely – binding objects are passed in memory.

5 ALMA Project 5Garching, 23 June – 02 July 2003ALMA Common Software course Schema + IDL Implementation code sees only binding classes SchedBlock XML document Client component Server component “SchedBlock.xsd” <xsd:element name=“SchedBlock”> meta level instance level typedef XmlEntityStruct SchedBlock; void takeSchedBlock( SchedBlock sb ) Complex data type defined as XML schema implements Operation defined in CORBA IDL ref 1..n 0..1

6 ALMA Project 6Garching, 23 June – 02 July 2003ALMA Common Software course Custom IDL compiler ACS IDL compiler Makefile mapping info: “ObsProject” -> alma.data.ObsProject Transparent-XML “MyInterfaceJ” alma.data.ObsProject getObsProject() CORBA IDL compiler typedef xmlstring ObsProject; … ObsProject getObsProject() IDL IF Flat-XML “MyInterface” XmlEntityStruct getObsProject() together in one JAR file

7 ALMA Project 7Garching, 23 June – 02 July 2003ALMA Common Software course Example: IDL from jcontexmpl/idl/XmlComponent.idl typedef xmlentity::XmlEntityStruct ObsProposal; typedef xmlentity::XmlEntityStruct SchedBlock; typedef sequence SchedBlockSeq; interface XmlComponent { ObsProposal createObsProposal(); SchedBlockSeq getAllSchedBlocks(); void xmlInOutMethod(in ObsProposal opsPropIn, out SchedBlock schedBlockOut); … }

8 ALMA Project 8Garching, 23 June – 02 July 2003ALMA Common Software course Example: XmlComponent IF created by the CORBA IDL compiler public interface XmlComponentOperations { alma.xmlentity.XmlEntityStruct createObsProposal(); alma.xmlentity.XmlEntityStruct[] getAllSchedBlocks(); void xmlInOutMethod(alma.xmlentity.XmlEntityStruct opsPropIn, alma.xmlentity.XmlEntityStructHolder schedBlockOut); }

9 ALMA Project 9Garching, 23 June – 02 July 2003ALMA Common Software course Example: XmlComponent IF created by the ACS IDL compiler public interface XmlComponentJ { public alma.xmljbind.test.obsproposal.ObsProposal createObsProposal(); public alma.xmljbind.test.schedblock.SchedBlock[] getAllSchedBlocks(); public void xmlInOutMethod(alma.xmljbind.test.obsproposal.ObsProp osal opsPropIn, alma.demo.SchedBlockHolder schedBlockOut); ACS IDL compiler adds a “J”

10 ALMA Project 10Garching, 23 June – 02 July 2003ALMA Common Software course Example: Component Implementation package alma.demo.XmlComponentImpl; public class XmlComponentImpl extends ComponentImplBase implements XmlComponentJ { public ObsProposal createObsProposal() { ObsProposal obsProp = new ObsProposal(); obsProp.setPerformanceGoals(“whatever."); return obsProp; }

11 ALMA Project 11Garching, 23 June – 02 July 2003ALMA Common Software course Client side (components acting as clients, or non-component clients) ContainerServices#getComponent returns the „flat-XML“ interface org.omg.CORBA.Object compObj = serv.getComponent("XMLCOMP1"); XmlComponent xmlComp = alma.demo.XmlComponentHelper.narrow(compObj); Wrap it using ContainerServices#createXmlBindingWrapper(..): XmlComponentJ xmlCompJ = (XmlComponentJ) cserv.createXmlBindingWrapper( XmlComponentJ.class, xmlComp, XmlComponentOperations.class); “flat-XML” IF component reference “transparent- XML” IF

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

13 ALMA Project 13Garching, 23 June – 02 July 2003ALMA Common Software course define/src/Makefile XSDBIND = systementities IDL_FILES = xmlentity acstestentities/src/Makefile XSDBIND = acsTestEntities XSDBIND_INCLUDE = systementities define idl lib systementities.xml CommonEntity.xsd GeneralIncludes.xsd xmlentity.idl systementities.jar xmlentity.jar acstestentities idl lib acsTestEntities.xml TestObsProject.xsd TestObsProposal.xsd TestSchedBlock acsTestEntities.jar jcontexmpl/src/Makefile IDL_FILES = HelloLamp XmlComponent XML_IDL = \ "ObsProposal=alma.xmljbind.test.obsproposal.ObsProposal; \ SchedBlock=alma.xmljbind.test.schedblock.SchedBlock” jcontexmpl idl lib HelloLamp.idl XmlComponent.idl HelloLamp.jar XmlComponent.jar IDL #include Inter-module referencing through INTROOT, ACSROOT Schema-to-Java class mappings for imported schemas Connects IDL entity class references, e.g. the “SchedBlock” typedef typedef xmlentity::XmlEntityStruct SchedBlock; with the corresponding Java binding classes.

14 ALMA Project 14Garching, 23 June – 02 July 2003ALMA Common Software course Remarks 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


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

Similar presentations


Ads by Google