SmartSync 1.1

li.netcat.smartsync
Class SmartSyncClient

java.lang.Object
  |
  +--li.netcat.smartsync.SmartSyncClient

public class SmartSyncClient
extends java.lang.Object

This is the main entry point to SmartSync from the clients point of view. To start a synchronization, construct a new instance of a SmartSyncClient, modify it's properties and call the synchronize(...) method. Example:

 
    SmartSyncClient client = new SmartSyncClient();
    client.setCompressionFlag(false);
    if (client.synchronize(new URL("http://localhost:8080/smartsync/SmartSyncServer"), new File("c:\\temp\\smartsync\\client"))) {
      System.out.printLn("update done");
    }
    else {
      System.out.printLn("no new update available");
    }
 

Author:
Arthur Marxer

Field Summary
static int MODE_ARCHIVE
          The archive mode causes the client to create a temporary directory for the update, and then rename the target directory to *_old and rename the temporary directory to the target.
static int MODE_DIRECT
          The direct mode causes the client to operate directly on the target directory
static int MODE_EXTERNAL
          This mode is used when the whole java virtual machine is also part of the target directory.
 
Constructor Summary
SmartSyncClient()
          Constructs a new instance of a SmartSyncClient and sets all properties to it's initial default.
 
Method Summary
 void addEventMonitor(EventMonitor monitor)
          Adds an event monitor to the list of monitors.
 boolean getCompressionFlag()
          Returns the compression flag.
 int getMode()
          Returns the operation mode of the client.
 boolean getTaskSummaryFlag()
          Returns the task summary flag.
 void removeEventMonitor(EventMonitor monitor)
          Removes an event monitor from the list of monitors.
 void setCompressionFlag(boolean flag)
          Sets the compression flag.
 void setMode(int mode)
          Sets the operation mode of the client.
 void setTaskSummaryFlag(boolean flag)
          Sets the task summary flag.
 boolean synchronize(java.net.URL remoteDirectory, java.io.File localDirectory)
          Synchronizes the given local directory with the given remote resource.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MODE_DIRECT

public static final int MODE_DIRECT
The direct mode causes the client to operate directly on the target directory

MODE_ARCHIVE

public static final int MODE_ARCHIVE
The archive mode causes the client to create a temporary directory for the update, and then rename the target directory to *_old and rename the temporary directory to the target.

MODE_EXTERNAL

public static final int MODE_EXTERNAL
This mode is used when the whole java virtual machine is also part of the target directory. In this mode, the client creates a temporary directory for the update, then renames it to *_new. A small external startup script or executable must be used for startup in this case. This script first has to check, wether there is a *_new directory. If it exists, it has to be renamed to the target directory before the application starts.
Constructor Detail

SmartSyncClient

public SmartSyncClient()
Constructs a new instance of a SmartSyncClient and sets all properties to it's initial default.
Method Detail

addEventMonitor

public void addEventMonitor(EventMonitor monitor)
Adds an event monitor to the list of monitors. A shallow copy of the list is used during a syncronisation process.
Parameters:
monitor - The monitor to be added, not null.

removeEventMonitor

public void removeEventMonitor(EventMonitor monitor)
Removes an event monitor from the list of monitors.
Parameters:
monitor - The monitor to be deleted.
Throws:
java.lang.IllegalArgumentException - If the monitor is not in the list of monitors.

getTaskSummaryFlag

public boolean getTaskSummaryFlag()
Returns the task summary flag.
Returns:
The task summary flag.

setTaskSummaryFlag

public void setTaskSummaryFlag(boolean flag)
Sets the task summary flag. If this flag is set, the server will add a detailed list of tasks to the header of the response. The benefit is having a list of all forthcoming tasks, the drawback is increased traffic.
This flag is turned on by default.
Parameters:
flag - The new value of the task summary flag. Specify false to omit the task summary.

getCompressionFlag

public boolean getCompressionFlag()
Returns the compression flag.
Returns:
The compression flag.

setCompressionFlag

public void setCompressionFlag(boolean flag)
Sets the compression flag. If this flag is set, the server will wrap a GZIP stream around the response stream. The benefit is reduced traffic, the drawback is increased cpu usage.
This flag is turned on by default.
Parameters:
flag - The new value of the compression flag. Specify false to turn off compression.

getMode

public int getMode()
Returns the operation mode of the client.
Returns:
One of the values MODE_*.

setMode

public void setMode(int mode)
Sets the operation mode of the client.
Parameters:
mode - One of the values MODE_*. The default is set to MODE_DIRECT.

synchronize

public boolean synchronize(java.net.URL remoteDirectory,
                           java.io.File localDirectory)
                    throws java.io.IOException
Synchronizes the given local directory with the given remote resource. After this operation, the local directory structure is equal to the remote resource and the remote resource remains unchanged.
Equal means, that the following data elements get updated: The following data elements get not updated: The remote resource is an instance of a SmartSyncServer (a servlet) that represents a directory structure.

This method does not create an own thread for communication.

Parameters:
remoteDirectory - A URL that points to the remote resource.
localDirectory - The local directory that gets updated.
Returns:
true, if an update occured, false otherwise.
Throws:
java.io.IOException - If an input/output problem occured.

SmartSync 1.1

Copyright © 2003 NetCat AG. All rights reserved. Feedback

keywords:java, net, servlet, synchronize, file, files, synchronize data, synchronize directory, synchronize files, synchronize files over HTTP, synchronize tree, file synchronizer, directory synchronizer, directory, directory structure, network, download, package, equalize, equalize, server, synchronise, file, files, synchronise data, synchronise directory, synchronise files, synchronise files over HTTP, synchronise tree, file synchroniser, file synchronisation, directory synchroniser, directory synchronisation, java, net, servlet, synchronize, file, files, synchronize data, synchronize directory, synchronize files, synchronize files over HTTP, synchronize tree, file synchronizer, directory synchronizer, directory, directory structure, network, download, package, equalize, equalize, server, synchronise, file, files, synchronise data, synchronise directory, synchronise files, synchronise files over HTTP, synchronise tree, file synchroniser, file synchronisation, directory synchroniser, directory synchronisation, java, net, servlet, synchronize, file, files, synchronize data, synchronize directory, synchronize files, synchronize files over HTTP, synchronize tree, file synchronizer, directory synchronizer, directory, directory structure, network, download, package, equalize, equalize, server, synchronise, file, files, synchronise data, synchronise directory, synchronise files, synchronise files over HTTP, synchronise tree, file synchroniser, file synchronisation, directory synchroniser, directory synchronisation