com.funambol.syncclient.spds
Class SyncManager

java.lang.Object
  extended by com.funambol.syncclient.spds.SyncManager
All Implemented Interfaces:
SyncTransportListener

public class SyncManager
extends java.lang.Object
implements SyncTransportListener

The SyncManager is the contact point between a host application and the synchronization engine. It is designed to hidden as much as possible the details of the synchronization logic, protocol, communication and so on; the simplest way to use it is to get an instance of the SyncManager and call its sync() method, as in the examples below:

    SyncManager syncManager = SyncManager.getSyncManager("test");

    syncManager.sync();
 
    SyncManager syncManager = SyncManager.getSyncManager("test", runtimeProperties);

    syncManager.sync();
 
getSyncManager() is a factory method that creates a new SyncManager bound to the given application URI. The application URI is an application identifier that must be unique amongst all the SyncPlatform-enabled applications running on the device. It is intended for future use.
runtimeProperties are properties set in runtime and not load by Device Management, may be:
  username
  password
  device-id
  url
  
The information required by the synchronization engine for initialization and to kick off a data synchronization session is stored in the device management configuration tree and can be manipulated by the means of the SyncPlatform Device Management API. See Funambol SyncClient API 2.0 Programmer Guide for more information.

Version:
$Id: SyncManager.java,v 1.4 2008-05-15 20:42:20 stefano_fornari Exp $

Field Summary
static java.lang.String AUTHENTICATION_BASIC
           
static java.lang.String AUTHENTICATION_CLEAR
           
static java.lang.String CONTEXT_SOURCES
          Configuration context for sync sources
static java.lang.String CONTEXT_SYNCAGENT
          Configuration context for the SyncML agent
static java.lang.String DEFAULT_MESSAGE_ENC
           
static java.lang.String DEFAULT_MESSAGETYPE
           
static java.lang.String MIMETYPE_SYNCMLDS_WBXML
           
static java.lang.String MIMETYPE_SYNCMLDS_XML
           
static java.lang.String PROP_APPLICATION_DISPLAY_NAME
           
static java.lang.String PROP_APPLICATION_SUPPORT_MAIL
           
static java.lang.String PROP_APPLICATION_SUPPORT_URL
           
static java.lang.String SESSION_ID
           
static java.lang.String STATUS_COMMAND_CHANGE
           
static java.lang.String STATUS_COMMAND_NEW
           
static java.lang.String SYNC_NONE
          Synchronization modes
static java.lang.String SYNC_ONEWAY
           
static java.lang.String SYNC_ONEWAYCLIENT
           
static java.lang.String SYNC_REFRESH
           
static java.lang.String SYNC_REFRESHCLIENT
           
static java.lang.String SYNC_SLOW
           
static java.lang.String SYNC_TWOWAY
           
static java.lang.String TAG_ALERT
           
static java.lang.String TAG_CMD
           
static java.lang.String TAG_DATA
           
static java.lang.String TAG_ITEM
           
static java.lang.String TAG_LOCALURI
           
static java.lang.String TAG_STATUS
           
static java.lang.String TAG_SYNCBODY
           
static java.lang.String TAG_SYNCHDR
           
static java.lang.String TAG_SYNCML
           
static java.lang.String TAG_TARGET
           
static java.lang.String WBXML_SYNCML_CLIENT
           
static java.lang.String XML_SYNCML_CLIENT
           
 
Constructor Summary
  SyncManager(java.lang.String appURI)
          Creates a SyncManager bound to a specific application.
protected SyncManager(java.lang.String appURI, java.util.Properties runtimeProperties)
          Creates a SyncManager bound to a specific application.
 
Method Summary
 void addSyncItemListener(SyncItemListener listener)
          Register a new SyncItemListener.
 void addSyncListener(SyncListener listener)
          Register a new SyncListener.
 void addSyncSourceListener(SyncSourceListener listener)
          Register a new SyncSourceListener.
 void addSyncStatusListener(SyncStatusListener listener)
          Register a new SyncStatusListener.
 void addSyncTransportListener(SyncTransportListener listener)
          Register a new SyncTransportListener.
 void dataReceived(SyncTransportEvent syncTransportEvent)
          Send syncTransportEvent to syncTransportListeners on dataReceived method.
static SyncManager getSyncManager(java.lang.String appURI)
          This is a factory method for SyncManager instances.
static SyncManager getSyncManager(java.lang.String appURI, java.util.Properties runtimeProperties)
          This is a factory method for SyncManager instances.
 void receiveDataBegin(SyncTransportEvent syncTransportEvent)
          Send syncTransportEvent to syncTransportListeners on receiveDataBegin method.
 void receiveDataEnd(SyncTransportEvent syncTransportEvent)
          Send syncTransportEvent to syncTransportListeners on receiveDataEnd method.
 void removeSyncItemListener(SyncItemListener listener)
          Remove the specified SyncItemListener.
 void removeSyncListener(SyncListener listener)
          Remove the specified SyncListener.
 void removeSyncSourceListener(SyncSourceListener listener)
          Remove the specified SyncSourceListener.
 void removeSyncStatusListener(SyncStatusListener listener)
          Remove the specified SyncStatusListener.
 void removeSyncTransportListener(SyncTransportListener listener)
          Remove the specified SyncTransportListener.
 void sendDataBegin(SyncTransportEvent syncTransportEvent)
          Send syncTransportEvent to syncTransportListeners on sendDataBegin method.
 void sendDataEnd(SyncTransportEvent syncTransportEvent)
          Send syncTransportEvent to syncTransportListeners on sendDataEnd method.
 void sync()
          Synchronize all registered synchronization sources.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONTEXT_SOURCES

public static final java.lang.String CONTEXT_SOURCES
Configuration context for sync sources

See Also:
Constant Field Values

CONTEXT_SYNCAGENT

public static final java.lang.String CONTEXT_SYNCAGENT
Configuration context for the SyncML agent

See Also:
Constant Field Values

SYNC_NONE

public static final java.lang.String SYNC_NONE
Synchronization modes

See Also:
Constant Field Values

SYNC_SLOW

public static final java.lang.String SYNC_SLOW
See Also:
Constant Field Values

SYNC_TWOWAY

public static final java.lang.String SYNC_TWOWAY
See Also:
Constant Field Values

SYNC_ONEWAY

public static final java.lang.String SYNC_ONEWAY
See Also:
Constant Field Values

SYNC_REFRESH

public static final java.lang.String SYNC_REFRESH
See Also:
Constant Field Values

SYNC_REFRESHCLIENT

public static final java.lang.String SYNC_REFRESHCLIENT
See Also:
Constant Field Values

SYNC_ONEWAYCLIENT

public static final java.lang.String SYNC_ONEWAYCLIENT
See Also:
Constant Field Values

TAG_ALERT

public static final java.lang.String TAG_ALERT
See Also:
Constant Field Values

TAG_CMD

public static final java.lang.String TAG_CMD
See Also:
Constant Field Values

TAG_DATA

public static final java.lang.String TAG_DATA
See Also:
Constant Field Values

TAG_ITEM

public static final java.lang.String TAG_ITEM
See Also:
Constant Field Values

TAG_LOCALURI

public static final java.lang.String TAG_LOCALURI
See Also:
Constant Field Values

TAG_STATUS

public static final java.lang.String TAG_STATUS
See Also:
Constant Field Values

TAG_SYNCBODY

public static final java.lang.String TAG_SYNCBODY
See Also:
Constant Field Values

TAG_SYNCHDR

public static final java.lang.String TAG_SYNCHDR
See Also:
Constant Field Values

TAG_SYNCML

public static final java.lang.String TAG_SYNCML
See Also:
Constant Field Values

TAG_TARGET

public static final java.lang.String TAG_TARGET
See Also:
Constant Field Values

PROP_APPLICATION_DISPLAY_NAME

public static final java.lang.String PROP_APPLICATION_DISPLAY_NAME
See Also:
Constant Field Values

PROP_APPLICATION_SUPPORT_URL

public static final java.lang.String PROP_APPLICATION_SUPPORT_URL
See Also:
Constant Field Values

PROP_APPLICATION_SUPPORT_MAIL

public static final java.lang.String PROP_APPLICATION_SUPPORT_MAIL
See Also:
Constant Field Values

AUTHENTICATION_BASIC

public static final java.lang.String AUTHENTICATION_BASIC
See Also:
Constant Field Values

AUTHENTICATION_CLEAR

public static final java.lang.String AUTHENTICATION_CLEAR
See Also:
Constant Field Values

SESSION_ID

public static final java.lang.String SESSION_ID
See Also:
Constant Field Values

MIMETYPE_SYNCMLDS_XML

public static final java.lang.String MIMETYPE_SYNCMLDS_XML
See Also:
Constant Field Values

MIMETYPE_SYNCMLDS_WBXML

public static final java.lang.String MIMETYPE_SYNCMLDS_WBXML
See Also:
Constant Field Values

XML_SYNCML_CLIENT

public static final java.lang.String XML_SYNCML_CLIENT
See Also:
Constant Field Values

WBXML_SYNCML_CLIENT

public static final java.lang.String WBXML_SYNCML_CLIENT
See Also:
Constant Field Values

DEFAULT_MESSAGETYPE

public static final java.lang.String DEFAULT_MESSAGETYPE
See Also:
Constant Field Values

STATUS_COMMAND_NEW

public static final java.lang.String STATUS_COMMAND_NEW
See Also:
Constant Field Values

STATUS_COMMAND_CHANGE

public static final java.lang.String STATUS_COMMAND_CHANGE
See Also:
Constant Field Values

DEFAULT_MESSAGE_ENC

public static final java.lang.String DEFAULT_MESSAGE_ENC
See Also:
Constant Field Values
Constructor Detail

SyncManager

protected SyncManager(java.lang.String appURI,
                      java.util.Properties runtimeProperties)
               throws SyncException
Creates a SyncManager bound to a specific application. The application is identified by the application URI parameter, which must be unique between applications running in the same JVM.

Parameters:
appURI - The unique application URI
runtimeProperties - are properties set in runtime and not load by Device Management, may be:
  username
  password
  device-id
 
Throws:
SyncException - in case an error occurs during initialization

SyncManager

public SyncManager(java.lang.String appURI)
            throws SyncException
Creates a SyncManager bound to a specific application. The application is identified by the application URI parameter, which must be unique between applications running in the same JVM.

Parameters:
appURI - The unique application URI
Throws:
SyncException
Method Detail

getSyncManager

public static SyncManager getSyncManager(java.lang.String appURI)
                                  throws SyncException,
                                         DMException
This is a factory method for SyncManager instances. It creates a SyncManager bound to a specific application. The application is identified by the application URI parameter, which must be unique between applications running in the same JVM.

Parameters:
appURI - The unique application URI
Returns:
a new SyncManager instance for the givven application
Throws:
SyncException - in case of a synchronization engine related error
DMException - in case of a configuration error

getSyncManager

public static SyncManager getSyncManager(java.lang.String appURI,
                                         java.util.Properties runtimeProperties)
                                  throws SyncException,
                                         DMException
This is a factory method for SyncManager instances. It creates a SyncManager bound to a specific application. The application is identified by the application URI parameter, which must be unique between applications running in the same JVM.

Parameters:
appURI - The unique application URI
runtimeProperties - are properties set in runtime and not load by Device Management, may be:
  username
  password
  device-id
 
Returns:
a new SyncManager instance for the givven application
Throws:
SyncException - in case of a synchronization engine related error
DMException - in case of a configuration error

sync

public void sync()
          throws SyncException,
                 AuthenticationException,
                 UpdateException
Synchronize all registered synchronization sources.

Throws:
SyncException - if an error occurs during synchronization
UpdateException - if an error occurs during an update on server
AuthenticationException - if the server responded with "non authorized" return code

addSyncListener

public void addSyncListener(SyncListener listener)
Register a new SyncListener.

Parameters:
listener -

removeSyncListener

public void removeSyncListener(SyncListener listener)
Remove the specified SyncListener.

Parameters:
listener -

addSyncTransportListener

public void addSyncTransportListener(SyncTransportListener listener)
Register a new SyncTransportListener.

Parameters:
listener -

removeSyncTransportListener

public void removeSyncTransportListener(SyncTransportListener listener)
Remove the specified SyncTransportListener.

Parameters:
listener -

addSyncSourceListener

public void addSyncSourceListener(SyncSourceListener listener)
Register a new SyncSourceListener.

Parameters:
listener -

removeSyncSourceListener

public void removeSyncSourceListener(SyncSourceListener listener)
Remove the specified SyncSourceListener.

Parameters:
listener -

addSyncItemListener

public void addSyncItemListener(SyncItemListener listener)
Register a new SyncItemListener.

Parameters:
listener -

removeSyncItemListener

public void removeSyncItemListener(SyncItemListener listener)
Remove the specified SyncItemListener.

Parameters:
listener -

addSyncStatusListener

public void addSyncStatusListener(SyncStatusListener listener)
Register a new SyncStatusListener.

Parameters:
listener -

removeSyncStatusListener

public void removeSyncStatusListener(SyncStatusListener listener)
Remove the specified SyncStatusListener.

Parameters:
listener -

sendDataBegin

public void sendDataBegin(SyncTransportEvent syncTransportEvent)
Send syncTransportEvent to syncTransportListeners on sendDataBegin method.

Specified by:
sendDataBegin in interface SyncTransportListener
Parameters:
syncTransportEvent -

sendDataEnd

public void sendDataEnd(SyncTransportEvent syncTransportEvent)
Send syncTransportEvent to syncTransportListeners on sendDataEnd method.

Specified by:
sendDataEnd in interface SyncTransportListener
Parameters:
syncTransportEvent -

receiveDataBegin

public void receiveDataBegin(SyncTransportEvent syncTransportEvent)
Send syncTransportEvent to syncTransportListeners on receiveDataBegin method.

Specified by:
receiveDataBegin in interface SyncTransportListener
Parameters:
syncTransportEvent -

dataReceived

public void dataReceived(SyncTransportEvent syncTransportEvent)
Send syncTransportEvent to syncTransportListeners on dataReceived method.

Specified by:
dataReceived in interface SyncTransportListener
Parameters:
syncTransportEvent -

receiveDataEnd

public void receiveDataEnd(SyncTransportEvent syncTransportEvent)
Send syncTransportEvent to syncTransportListeners on receiveDataEnd method.

Specified by:
receiveDataEnd in interface SyncTransportListener
Parameters:
syncTransportEvent -


Copyright © 2010 Funambol. All Rights Reserved.