Sun Java System Mobile Enterprise Platform 1.0 Developer's Guide for Client Applications

The SyncManager Class

Table 4–8 lists the constructors and methods belonging to the SyncManager class. This class is responsible for managing synchronizations with the Gateway Engine for a particular kind of BusinessObject (classified by a particular extension). There is a one-to-one mapping between SyncManager and kinds of BusinessObject instances. If you have an application that deals with two different BusinessObject types, then you would have an instance of SyncManager for each type.

You must specify a unique extension for your BusinessObject when you construct this class. The name field in the BusinessObject, combined with the extension, will determine the entire name of the file on the device's filesystem. For example, you might pass the string ".act" for account or ".ord" for orders, but it can be anything legally allowed in a file name.

You may optionally specify a simple alphanumeric pin which will be used to encrypt any data stored locally on the device.

When you invoke the sync(SyncType) method, this will initiate a synchronization session with the Gateway Engine. During this session, only BusinessObject instances whose extension fields match will be synchronized.

Table 4–8 Class com.sun.mep.client.api.SyncManager

Method 

Description 

public SyncManager(java.lang.String extension)

Constructor that creates a new SyncManager for the specified business object type (extension) with no SecurityManager. This method is the equivalent of calling new SyncManager(extension, null).

public SyncManager(java.lang.String extension, SecurityManager sm)

Constructor that creates a new SyncManager for the specified business object type (extension) and uses the specified SecurityManager.

public void enableLogging(boolean value)

Enables or disables debug logging in the MEP client APIs. If enabled, the MEP implementation library writes logging information to stdout and also to a log file (named meplog.txt) on the device. Logging is disabled by default.

public BusinessObjectStorage getBusinessObjectStorage()

Returns the BusinessObjectStorage manager associated with this SyncManager. There is a strict 1:1 relationship between SyncManager and BusinessObjectStorage.

public EncodingType getEncoding()

Returns the current transport encoding type. 

public java.lang.String getExtension()

Returns the extension type associated with this SyncManager.

public static final SecurityManager getSecurityManager()

Returns a reference to the security manager, or null if one has not been set. 

public SyncResults getSyncResults()

Returns the sync results for the latest successful sync. 

public long getTimeOfLastSync()

Returns a time stamp of the last successful sync. This time stamp is recorded by calling System.currentTimeMillis(), so it is an offset from January 1, 1970 UTC. If a sync has not been performed yet, the method returns a negative value.

public void setCredentials(java.lang.String username, java.lang.String password, java.lang.String url)

Sets the credentials used during the synchronization process. 

public void setEncoding(EncodingType encoding)

Sets the transport encoding type. 

public void sync(SyncType syncType)

Performs the specified type of synchronization.