jSyncManager

org.jSyncManager.API.Threads
Class Synchronizer

java.lang.Object
  |
  +--org.jSyncManager.API.Threads.Synchronizer
All Implemented Interfaces:
ConduitManager, java.lang.Runnable

public class Synchronizer
extends java.lang.Object
implements java.lang.Runnable, ConduitManager

This class encapsulates the jSyncManagers synchronization engine as a seperate Runnable class, allowing it to be incorporated into multithreaded applications which listen to multiple synchronization ports at once.

Version:
$Revision: 2.100 $
Author:
Brad BARCLAY <bbarclay@jsyncmanager.org>
Last modified by: $Author: yaztromo $ on $Date: 2003/05/01 05:48:04 $.

Inner Class Summary
(package private)  class Synchronizer.ConduitList
           
 
Field Summary
static java.lang.String author
          This class variable holds the name and e-mail address of the Synchronization engine author.
static int BACKUP_SYNC
          Denotes the Backup sync type.
 java.io.PrintWriter logStream
          This variable hold the reference to the PrintWriter to be used for writing log messages.
static int NORMAL_SYNC
          Denotes the "Normal" jConduit sync type.
static int RESTORE_SYNC
          Denotes the Restore sync type.
 boolean running
          This variable hold the run state of the sync engine.
protected static java.lang.String state
          This class variable holds the state of this Synchronizer engine.
 java.io.PrintWriter statusStream
          This variable hold the reference to the PrintWriter to be used for writing status messages.
protected static java.lang.String version
          This class variable holds the version of this Synchronizer Engine.
 
Constructor Summary
protected Synchronizer()
          Basic class Constructor.
  Synchronizer(SLPTransportInterface transport, SynchronizerListener listener)
          Creates a new instance of the Synchronization engine.
 
Method Summary
 void appendToPalmSyncLog(java.lang.String text)
          Appends a string of text to the handhelds synchronization log.
protected  void finalize()
          Code to perform when this object is garbage collected.
 java.util.Vector getDBInfo()
          Retrieves a vector containing all the database info objects collected by this Synchronizer.
 DLPDatabaseInfo getDBInfo(java.lang.String s)
          Retrieves the database info for the named database.
 DLPVersion getDLPVersion()
          Returns the DLP version for the synchronizing device.
static java.lang.String getHomeDirectory()
          Retrieves the jSyncManager Home directory.
 boolean getPopupState()
          Returns wether or not popups are allowed by jConduits.
 DLPStorageInfo getStorageInfo()
          Retrieves the storage info for the synchronizing device.
 DLPSystemInfo getSystemInfo()
          Retrieves the system info for the synchronizing device.
 DLPUserInfo getUserInfo()
          Retrieves the user info for the synchronizing device.
static java.lang.String getVersion()
          Retrieves the version of this Synchronizer implementation.
 boolean isModemListener()
          This method is used to determine if this jSyncManager instance is listening to a serial port with a cradle, or a serial port with a modem attached.
 void postToLog(java.lang.String s)
          This method is called to post text information to the log stream.
 void run()
          Used by java.lang.Thread to start executing the Synchronization engine.
 void setLogStream(java.io.PrintStream stream)
          Sets the PrintSteam object that all logging information should be posted to.
 void setLogStream(java.io.PrintWriter stream)
          Sets the PrintWriter object that all logging information should be posted to.
 void setStatus(java.lang.String s)
          Writes a line of text to the status stream.
 void setStatusStream(java.io.PrintStream stream)
          Sets the PrintSteam object that all sync status information should be posted to.
 void setStatusStream(java.io.PrintWriter stream)
          Sets the PrintWriter object that all sync status information should be posted to.
 void stopSync()
          Requests a stop to the synchronization engine.
 
Methods inherited from class java.lang.Object
, clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NORMAL_SYNC

public static final int NORMAL_SYNC
Denotes the "Normal" jConduit sync type.

BACKUP_SYNC

public static final int BACKUP_SYNC
Denotes the Backup sync type.

RESTORE_SYNC

public static final int RESTORE_SYNC
Denotes the Restore sync type.

version

protected static final java.lang.String version
This class variable holds the version of this Synchronizer Engine.

author

public static final java.lang.String author
This class variable holds the name and e-mail address of the Synchronization engine author.

state

protected static final java.lang.String state
This class variable holds the state of this Synchronizer engine.

statusStream

public java.io.PrintWriter statusStream
This variable hold the reference to the PrintWriter to be used for writing status messages.

logStream

public java.io.PrintWriter logStream
This variable hold the reference to the PrintWriter to be used for writing log messages.

running

public volatile boolean running
This variable hold the run state of the sync engine. true denotes that the engine is running, false denotes that it is no longer running.
Constructor Detail

Synchronizer

protected Synchronizer()
Basic class Constructor. Only accessible by this class and it's subclasses.

Synchronizer

public Synchronizer(SLPTransportInterface transport,
                    SynchronizerListener listener)
Creates a new instance of the Synchronization engine. The Synchronization engine requires callbacks to the implementing application. The implementing application must thus implement the SynchronizerListener interface to provide these callbacks.
Parameters:
transport - an instance of the Transport to use.
syncSpeed - the synchronization speed to use (for dock and modem sync).
listener - a handle to the class that implements SynchronizationListener.
See Also:
SynchronizerListener
Method Detail

appendToPalmSyncLog

public void appendToPalmSyncLog(java.lang.String text)
Appends a string of text to the handhelds synchronization log.
Specified by:
appendToPalmSyncLog in interface ConduitManager
Parameters:
text - the text to append to the handhelds sync log.

finalize

protected void finalize()
                 throws java.lang.Throwable
Code to perform when this object is garbage collected. When finalized, the communications system is also properly closed down.
Overrides:
finalize in class java.lang.Object

getDBInfo

public java.util.Vector getDBInfo()
Retrieves a vector containing all the database info objects collected by this Synchronizer.
Specified by:
getDBInfo in interface ConduitManager
Returns:
a vector containing all of the DLPDatabaseInfo objects collected by the Synchronizer.

getDBInfo

public DLPDatabaseInfo getDBInfo(java.lang.String s)
                          throws DatabaseNotFoundException
Retrieves the database info for the named database.
Specified by:
getDBInfo in interface ConduitManager
Parameters:
s - the name of the database to retreive the info object for.
Returns:
the DLPDatabaseInfo object for the requested database.
Throws:
throws - a DatabaseNotFoundException if the database named doesn't exist.

getDLPVersion

public DLPVersion getDLPVersion()
Returns the DLP version for the synchronizing device.
Specified by:
getDLPVersion in interface ConduitManager
Returns:
the DLPVersion object for the synchronizing device.

getPopupState

public boolean getPopupState()
Returns wether or not popups are allowed by jConduits. This is hard-coded to disallow popups. This should either be changed or removed in a future release.
Specified by:
getPopupState in interface ConduitManager
Returns:
true if popups should be allowed, false otherwise.

getStorageInfo

public DLPStorageInfo getStorageInfo()
Retrieves the storage info for the synchronizing device.
Specified by:
getStorageInfo in interface ConduitManager
Returns:
The DLPStorageInfo for the synchronizing device.

getSystemInfo

public DLPSystemInfo getSystemInfo()
Retrieves the system info for the synchronizing device.
Specified by:
getSystemInfo in interface ConduitManager
Returns:
The DLPSystemInfo for the synchronizing device.

getUserInfo

public DLPUserInfo getUserInfo()
Retrieves the user info for the synchronizing device.
Specified by:
getUserInfo in interface ConduitManager
Returns:
The DLPUserInfo for the synchronizing device.

isModemListener

public boolean isModemListener()
This method is used to determine if this jSyncManager instance is listening to a serial port with a cradle, or a serial port with a modem attached.
Specified by:
isModemListener in interface ConduitManager
Returns:
true if the attached serial device is a modem, false otherwise.

postToLog

public void postToLog(java.lang.String s)
This method is called to post text information to the log stream.
Specified by:
postToLog in interface ConduitManager
Parameters:
s - the text to post to the log stream.

run

public void run()
Used by java.lang.Thread to start executing the Synchronization engine. This class implements Runnable, and is intended to be put inside a new Thread object. To start the sync engine, call you Thread objects "start()" method.
Specified by:
run in interface java.lang.Runnable

setLogStream

public void setLogStream(java.io.PrintStream stream)
Sets the PrintSteam object that all logging information should be posted to.
Parameters:
stream - the PrintSteam object that all logging information should be posted to.

setLogStream

public void setLogStream(java.io.PrintWriter stream)
Sets the PrintWriter object that all logging information should be posted to.
Parameters:
stream - the PrintWriter object that all logging information should be posted to.

setStatus

public void setStatus(java.lang.String s)
Writes a line of text to the status stream. Note that text sent via this method to the status stream will also automatically be posted to the logging stream as well.
Specified by:
setStatus in interface ConduitManager
Parameters:
s - the text to post to the status stream.

setStatusStream

public void setStatusStream(java.io.PrintStream stream)
Sets the PrintSteam object that all sync status information should be posted to.
Parameters:
stream - the PrintSteam object that all sync status information should be posted to.

setStatusStream

public void setStatusStream(java.io.PrintWriter stream)
Sets the PrintWriter object that all sync status information should be posted to.
Parameters:
stream - the PrintWriter object that all sync status information should be posted to.

stopSync

public void stopSync()
Requests a stop to the synchronization engine. Note that calling this method merely flags the synchronization engine to force it to stop after the end of the next synchronization. For a more immediate (but still controlled) end to the sync engine, interrupt it's thread.

getVersion

public static java.lang.String getVersion()
Retrieves the version of this Synchronizer implementation.
Returns:
String the version of this Synchronizers implementation.

getHomeDirectory

public static java.lang.String getHomeDirectory()
Retrieves the jSyncManager Home directory. This method returns the user.home directory. However, the user may override this using the jsyncman.home property.
Returns:
the jSyncManager Home directory.

jSyncManager

Copyright (c) 1999 - 2003 Brad BARCLAY and others. All Rights Reserved.