com.funambol.syncml.spds
Class SyncManager

java.lang.Object
  extended by com.funambol.syncml.spds.SyncManager

public class SyncManager
extends java.lang.Object

The SyncManager is the engine of the synchronization process on the client library. It initializes the sync, checks the server responses and communicate with the SyncSource, which is the client-specific source of data. A client developer must prepare a SyncConfig to istantiate a SyncManager, and then can sync its sources calling the sync() method. By default the SyncManager uses an HttpTransportAgent to communicate with the server, but the interface allows clients to specify their own transport agent.


Field Summary
protected  int alertCode
           
protected  SyncSource source
           
 
Constructor Summary
SyncManager(SyncConfig conf)
          SyncManager constructor
 
Method Summary
 void cancel()
          This method cancels the current sync.
 void enableMappingTest(boolean isMappingTestDisabled)
          Enable or disable the mappings for test purposes only
 java.lang.String getNextCmdID()
           
 SyncReport getSyncReport()
          This method returns the sync report of the last sync performed.
 boolean isBusy()
          Checks if the manager is currently busy performing a synchronization.
protected  boolean processModifications(ChunkedString modifications)
          Processes the modifications from the received response from server
 void setCmdProcessingOrder(java.lang.String[] newOrder)
          Defines the order in which incoming items are processed by the engine.
 void setFlagSendDevInf()
          To be invoked by every change of the device configuration and if the serverUrl is a new one (i.e., not already on the list lastServerUrl
 void setTransportAgent(TransportAgent ta)
          Sets the transport agent to be used for the next message to be sent.
 void sync(SyncSource source)
          Synchronizes synchronization source, using the preferred sync mode defined for that SyncSource.
 void sync(SyncSource source, boolean askServerDevInf)
          Synchronizes synchronization source, using the preferred sync mode defined for that SyncSource.
 void sync(SyncSource src, int syncMode)
          Synchronizes synchronization source
 void sync(SyncSource src, int syncMode, boolean askServerDevInf)
          Synchronizes synchronization source
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

source

protected SyncSource source

alertCode

protected int alertCode
Constructor Detail

SyncManager

public SyncManager(SyncConfig conf)
SyncManager constructor

Parameters:
conf - is the configuration data filled by the client
Method Detail

sync

public void sync(SyncSource source)
          throws SyncException
Synchronizes synchronization source, using the preferred sync mode defined for that SyncSource.

Parameters:
source - the SyncSource to synchronize
Throws:
SyncException - If an error occurs during synchronization

sync

public void sync(SyncSource source,
                 boolean askServerDevInf)
          throws SyncException
Synchronizes synchronization source, using the preferred sync mode defined for that SyncSource.

Parameters:
source - the SyncSource to synchronize
askServerDevInf - forces the sync to query for server device information. The information is returned to the client via the SyncListener (@see SyncListener.startSyncing)
Throws:
SyncException - If an error occurs during synchronization

sync

public void sync(SyncSource src,
                 int syncMode)
          throws SyncException
Synchronizes synchronization source

Parameters:
source - the SyncSource to synchronize
syncMode - the sync mode
Throws:
SyncException - If an error occurs during synchronization

sync

public void sync(SyncSource src,
                 int syncMode,
                 boolean askServerDevInf)
          throws SyncException
Synchronizes synchronization source

Parameters:
source - the SyncSource to synchronize
syncMode - the sync mode
askServerDevInf - forces the sync to query for server device information. The information is returned to the client via the SyncListener (@see SyncListener.startSyncing)
Throws:
SyncException - If an error occurs during synchronization

cancel

public void cancel()
This method cancels the current sync. The sync is interrupted once the engine reaches the next check point (in other words the termination is not immediate). When a sync is interrupted, a SyncException with code CANCELLED is thrown. This exception will be thrown by the thread running the synchronization itself, not by this method. This method is non blocking, it marks the sync as to be cancelled and returns, without waiting for the sync to be really cancelled. If this SyncManager is performing more syncs cuncurrently, then all of them are cancelled.


setFlagSendDevInf

public void setFlagSendDevInf()
To be invoked by every change of the device configuration and if the serverUrl is a new one (i.e., not already on the list lastServerUrl


isBusy

public boolean isBusy()
Checks if the manager is currently busy performing a synchronization.

Returns:
true if a sync is currently on going

setTransportAgent

public void setTransportAgent(TransportAgent ta)
Sets the transport agent to be used for the next message to be sent. If this method is invoked in the middle of a sync, it changes the connection method for that very sync. This is a possible behavior, but it is very uncommon. Users should make sure no sync is in progress when the transport agent is changed. Typically the transport agent is changed before the first sync and not changed aterward.

Parameters:
ta - the transport agent
Throws:
java.lang.IllegalArgumentException - if the give transport agent is null

getSyncReport

public SyncReport getSyncReport()
This method returns the sync report of the last sync performed. This information is valid until a new sync is fired.


setCmdProcessingOrder

public void setCmdProcessingOrder(java.lang.String[] newOrder)
Defines the order in which incoming items are processed by the engine.

Parameters:
newOrder - an array of three items whose values must be one of: SyncML.TAG_ADD, SyncML.TAG_REPLACE, SyncML.TAG_DELETE

processModifications

protected boolean processModifications(ChunkedString modifications)
                                throws SyncException
Processes the modifications from the received response from server

Parameters:
modifications - The modification message from server
Returns:
true if a response message is required, false otherwise
Throws:
SyncException

getNextCmdID

public java.lang.String getNextCmdID()

enableMappingTest

public void enableMappingTest(boolean isMappingTestDisabled)
Enable or disable the mappings for test purposes only



Copyright © 2001-2009 Funambol.