Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Data Synchronization with SyncML* and sync4j Sean C. Sullivan <sean> at <seansullivan> <.com> Copyright © 2001 Sean C. Sullivan * Third party trademarks are property of their respective owners Agenda Data synchronization SyncML sync4j Q&A Copyright © 2001 Sean C. Sullivan * Third party trademarks are property of their respective owners What is data synchronization? Data synchronization “is the process of making two sets of data look identical” (syncml.org whitepaper) Copyright © 2001 Sean C. Sullivan * Third party trademarks are property of their respective owners Data Synchronization Datastore1 Datastore2 A A B C B C Data modifications Conflict resolution Copyright © 2001 Sean C. Sullivan * Third party trademarks are property of their respective owners What is a “data synchronization protocol”? Communication syntax and semantics for a data synchronization session Protocol includes: – naming and identification of records – common protocol commands – identification and resolution of synchronization conflicts Copyright © 2001 Sean C. Sullivan * Third party trademarks are property of their respective owners SyncML defined… “SyncML is a new industry initiative to develop and promote a single, common data synchronization protocol that can be used industry-wide.” (syncml.org) “SyncML is a specification for a common data synchronization framework and XML-based format […] for synchronizing data on networked devices.” (syncml.org) “SyncML is a […] protocol for conveying data synchronization operations.” (syncml.org) Copyright © 2001 Sean C. Sullivan * Third party trademarks are property of their respective owners SyncML sponsors Copyright © 2001 Sean C. Sullivan * Third party trademarks are property of their respective owners SyncML: clients & servers server modifications client modifications Copyright © 2001 Sean C. Sullivan SyncML server * Third party trademarks are property of their respective owners SyncML data identification Server Client LUID Data GUID Data GUID LUID 23 A 189 A 189 382 B 3982 B 3982 382 61 C 89 C 89 Copyright © 2001 Sean C. Sullivan 23 61 * Third party trademarks are property of their respective owners SyncML Synchronization Types Two-way sync Slow sync One-way sync from client only Refresh sync from client only Copyright © 2001 Sean C. Sullivan * Third party trademarks are property of their respective owners SyncML Synchronization Types (cont.) One-way sync from server only Refresh sync from server only Server alerted sync Copyright © 2001 Sean C. Sullivan * Third party trademarks are property of their respective owners SyncML features Synchronize any type of data Multiple protocol bindings – HTTP, WSP, OBEX Security Interoperability Copyright © 2001 Sean C. Sullivan * Third party trademarks are property of their respective owners SyncML terminology Message Package Command Status code Copyright © 2001 Sean C. Sullivan Datastore Device Info Meta Info Capabilities exchange * Third party trademarks are property of their respective owners SyncML and XML Abbreviated naming convention – Ex: ”protocol version” is <VerProto> XML prolog is not required WBXML – WAP Binary XML Copyright © 2001 Sean C. Sullivan * Third party trademarks are property of their respective owners SyncML documents <SyncML> DTD Meta info DTD Device info DTD Copyright © 2001 Sean C. Sullivan * Third party trademarks are property of their respective owners <SyncML> document “A SyncML Message is a well-formed, but not necessarily valid, XML document.” (syncml.org) Contains data synchronization commands (operations) Copyright © 2001 Sean C. Sullivan <?xml version="1.0"?> <!DOCTYPE … > <SyncML> <SyncHdr> … </SyncHdr> <SyncBody> … </SyncBody> </SyncML> * Third party trademarks are property of their respective owners <SyncHdr> element <SyncHdr> <VerDTD>1.0</VerDTD> <VerProto>1.0</VerProto> <SessionID>session41</SessionID> <MsgID>msg80386</MsgID> … </SyncHdr> Copyright © 2001 Sean C. Sullivan * Third party trademarks are property of their respective owners <SyncBody> element <SyncBody> <Delete> <CmdID>cmd80486</CmdID> … <Item>…</Item> </Delete> </SyncBody> Copyright © 2001 Sean C. Sullivan * Third party trademarks are property of their respective owners Meta Info document Contains sync session parameters Copyright © 2001 Sean C. Sullivan <MetInf> <Format>…</Format> <Type>…</Type> … <MaxMsgSize>586 </MaxMsgSize> … </MetInf> * Third party trademarks are property of their respective owners Device Info document Describes device capabilities For both client and server Copyright © 2001 Sean C. Sullivan <DevInf> … <SwV>0.99</SwV> <HwV>3.14</HwV> … <DevTyp>pda</DevTyp> … </DevInf> * Third party trademarks are property of their respective owners SyncML commands Add Alert Atomic Copy Delete Exec Get Map Copyright © 2001 Sean C. Sullivan Put Replace Results Search Sequence Status Sync * Third party trademarks are property of their respective owners sync4j Java implementation of SyncML protocol sync4j client & sync4j Server open source designed for J2SE platform http://sync4j.sourceforge.net Copyright © 2001 Sean C. Sullivan * Third party trademarks are property of their respective owners Open source licensing Licensing options: – – – – – – GPL? LGPL? BSD? Apache Public License? JDOM public license? Mozilla Public License (MPL)? sync4j license is virtually identical to JDOM license Copyright © 2001 Sean C. Sullivan * Third party trademarks are property of their respective owners sync4j audience developers who know Java but don’t know SyncML developers who know SyncML but may not know Java commercial application developers & open source application developers Copyright © 2001 Sean C. Sullivan * Third party trademarks are property of their respective owners API design ideas SAX API – standard set of interfaces – multiple implementations – usage model: callbacks JDOM API – concrete classes; single implementation – root Document object contains Element objects Copyright © 2001 Sean C. Sullivan * Third party trademarks are property of their respective owners API design ideas (cont.) Servlet API – usage model: developer builds a new servlet by subclassing HTTPServlet Auto-generate classes from DTD using an XML data-binding tool?? – Sun’s JAXB – Enhydra’s Zeus Copyright © 2001 Sean C. Sullivan * Third party trademarks are property of their respective owners Design goals Hide complexity of the SyncML specification from Java programmers – XML documents, XML parsing – multiple transport protocols A complete SyncML implementation Interoperability – with existing SyncML clients & servers Copyright © 2001 Sean C. Sullivan * Third party trademarks are property of their respective owners Design goals (cont.) API should be natural and familiar to Java programmers – direct object instantiation – exceptions – use Collection API / arrays, where appropriate – event notification via event listeners – familiar naming conventions Copyright © 2001 Sean C. Sullivan * Third party trademarks are property of their respective owners Design goals (cont.) API must be familiar to developers who already know the SyncML DTD’s API must enforce any restrictions that are defined in the SyncML specification Target platform: J2SE Copyright © 2001 Sean C. Sullivan * Third party trademarks are property of their respective owners Design goals (cont.) Modular design: – “core” protocol support – transport protocol libraries – extensible client framework – extensible server framework – client application – server application Copyright © 2001 Sean C. Sullivan * Third party trademarks are property of their respective owners sync4j implementation Immutable objects Exception class for each SyncML “status code” Declaration of constants – public final static variables Command object hierarchy Copyright © 2001 Sean C. Sullivan * Third party trademarks are property of their respective owners sync4j command hierarchy AbstractCommand RequestCommand AddCommand, DeleteCommand, ReplaceCommand, … Copyright © 2001 Sean C. Sullivan ResponseCommand ResultsCommand, StatusCommand, * Third party trademarks are property of their respective owners sync4j toolset Tool Jakarta Ant JDOM Apache Xerces-J CVS log4j JDK 1.3.1 JUnit SourceForge Copyright © 2001 Sean C. Sullivan URL jakarta.apache.org www.jdom.org xml.apache.org www.cygwin.com www.log4j.org java.sun.com www.junit.org www.sourceforge.net * Third party trademarks are property of their respective owners sync4j packages sync4j.core sync4j.client sync4j.server Copyright © 2001 Sean C. Sullivan sync4j.http sync4j.wsp sync4j.obex sync4j.tests * Third party trademarks are property of their respective owners sync4j key classes SyncMLMessage DeviceInfo MetaInfo Command classes: – AddCommand – DeleteCommand – ReplaceCommand Copyright © 2001 Sean C. Sullivan * Third party trademarks are property of their respective owners sync4j.core.SyncMLMessage Two ways to construct: – from a String of XML – from more basic sync4j objects Copyright © 2001 Sean C. Sullivan * Third party trademarks are property of their respective owners SyncMLMessage example 1 String strXML = “<SyncML> … </SyncML>”; SyncMLMessage msg; try { msg = new SyncMLMessage(strXML); } catch (InvalidSyncMLException ex) { } catch (XMLSyntaxException ex) { } Copyright © 2001 Sean C. Sullivan * Third party trademarks are property of their respective owners SyncMLMessage example 2 SyncHeader header = new SyncHeader(...); SyncBody body = new SyncBody(...); SyncMLMessage msg; msg = new SyncMLMessage(header, body); String strXML = msg.toXML(); Copyright © 2001 Sean C. Sullivan * Third party trademarks are property of their respective owners Algorithms Base64 – encode, decode WBXML – encode, decode MD5 – java.security.MessageDigest Copyright © 2001 Sean C. Sullivan * Third party trademarks are property of their respective owners sync4j future issues Compliance testing, interoperability tests move to JDK 1.4? – Assert facility – Java Logging API – New I/O classes: java.nio – SSL class library Copyright © 2001 Sean C. Sullivan * Third party trademarks are property of their respective owners Summary SyncML is both complex and powerful sync4j hides the complexity of SyncML from Java programmers The sync4j API is consistent with many familiar Java programming idioms http://sync4j.sourceforge.net/ Copyright © 2001 Sean C. Sullivan * Third party trademarks are property of their respective owners Data Synchronization with SyncML* and sync4j Sean C. Sullivan <sean> at <seansullivan> <.com> Copyright © 2001 Sean C. Sullivan * Third party trademarks are property of their respective owners The following slides are miscellaneous material. Copyright © 2001 Sean C. Sullivan * Third party trademarks are property of their respective owners SyncML authentication <Chal> <Cred> Authentication types: – basic – MD5 Copyright © 2001 Sean C. Sullivan * Third party trademarks are property of their respective owners