Data Synchronization with SyncML * and sync4j
description
Transcript of Data Synchronization with SyncML * and sync4j
Copyright © 2001 Sean C. Sullivan * Third party trademarks are property of their respective owners
Data Synchronization with Data Synchronization with SyncMLSyncML** and sync4j 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
Conflict resolution
Datastore1
Data modifications
Datastore2
A CB C A BA CB
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
SyncMLserver
server modifications
client modifications
Copyright © 2001 Sean C. Sullivan * Third party trademarks are property of their respective owners
SyncML data identification
LUID Data
23 A
382 B
61 C
GUID Data
189 A
3982 B
89 C
Client Server
GUID LUID
189 23
3982 382
89 61
Copyright © 2001 Sean C. Sullivan * 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
Datastore Device Info Meta Info Capabilities
exchange
Copyright © 2001 Sean C. Sullivan * 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<?xml version="1.0"?><!DOCTYPE … ><SyncML><SyncHdr>…</SyncHdr><SyncBody>…</SyncBody></SyncML>
“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 * 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
<MetInf><Format>…</Format><Type>…</Type>…<MaxMsgSize>586</MaxMsgSize>…</MetInf>
Copyright © 2001 Sean C. Sullivan * Third party trademarks are property of their respective owners
Device Info document
Describes device capabilities
For both client and server
<DevInf>
…
<SwV>0.99</SwV>
<HwV>3.14</HwV>
…
<DevTyp>pda</DevTyp>
…
</DevInf>
Copyright © 2001 Sean C. Sullivan * Third party trademarks are property of their respective owners
SyncML commands Add Alert Atomic Copy Delete Exec Get Map
Put Replace Results Search Sequence Status Sync
Copyright © 2001 Sean C. Sullivan * 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 hierarchyAbstractCommand
ResponseCommandRequestCommand
AddCommand, DeleteCommand,
ReplaceCommand,…
ResultsCommand,StatusCommand,
Copyright © 2001 Sean C. Sullivan * Third party trademarks are property of their respective owners
sync4j toolsetTool URL
Jakarta Ant jakarta.apache.org
JDOM www.jdom.org
Apache Xerces-J xml.apache.org
CVS www.cygwin.com
log4j www.log4j.org
JDK 1.3.1 java.sun.com
JUnit www.junit.org
SourceForge www.sourceforge.net
Copyright © 2001 Sean C. Sullivan * Third party trademarks are property of their respective owners
sync4j packages
sync4j.core sync4j.client sync4j.server
sync4j.http sync4j.wsp sync4j.obex sync4j.tests
Copyright © 2001 Sean C. Sullivan * 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 1String 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 2SyncHeader 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 Data Synchronization with SyncMLSyncML** and sync4j 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