At this point, there is no URI assigned to this SyncUnit. Since the SyncUnit object returned is a template, we need to fill in the template with its appropriate properties, such as the local file location, and the target server. Once this template is filled in, then we need to call the SyncManager to add a concrete instance of the SyncUnit based upon our completed template.
Continuing on with the sample from above, we have the next statements:
template.setLocalFile( "c:\\sync\\file1" );
template.setTargetServer( "http://my.filesyncserver.com" );
FileSyncUnit file1Instance = (FileSyncUnit)sm.add( template );
When this concrete instance of the FileSyncUnit is returned, it will have a valid URI assigned. So how did this happen ?
- The SyncManager will locate the SyncService responsible for the com.ibm.filesync type.
- The SyncManager will call SyncService.addSyncData( SUSyncData ) with the default sync data object created above.
- The addSyncData method is expected to do the following:
The SyncManager will locate the TypeService responsible for the com.ibm.filesync type
The SyncManager will call the TypeService.createSyncUnit( "com.ibm.filesync", SyncUnitCore ) method to create a new instance of the FileSyncUnit. (The SyncUnitCore will contain among other things a reference to the specific SUSyncData just created above for this SyncService)
The SyncManager will register this new instance as something to be synced
The SyncManager will return this new instance to the caller.
- Return a non-null SUSyncData instance
- Return a copy/clone of the default SUSyncData instance passed in (if this is not done, the SyncManager will currently clone it for you)
- Assign an new URI to the returned SUSyncData instance
- Throw an exception if the URI has already been given out (in the case of a SyncService managed URI model) or already exists (dynamic URI model)
Parent topic: Implementing SyncService