[aerogear-dev] how about this API for sync?

Erik Jan de Wit edewit at redhat.com
Wed Dec 4 04:09:30 EST 2013


Just to get some discussions going and have something to talk about I’ve drafted some API, so what do you think?

// [option 1 fully automatic we create a pipe and add the posibilty to add a store for failover and sync just happens at on- and offline events]
// and because merging can fail users can add a conflict handlers
 
Builder builder = Builder.createPipe(pipeConfig).addFailoverStore(storeConfig);
Pipe<Car> pipe = builder.pipe(Car.class);
 
pipe.addConfictHandler(new ConflictHandler() {
	public void conflict(Field originalField, Field newField) {
		// user interaction
	}
});
 
// [option 2 explicit let the user specify when to sync and what to sync]
SyncedPipe pipe = SyncPipeBuilder.build(options); // SyncPipe Store and Pipe togheter
 
// or we only use a store to sync and tell the sync manager where to sync to
SyncManager syncManager = new SyncManger();
syncManger.filter(readFilter); // maybe we don't want to sync all data but just some part
 
syncManager.addConnectionHandler(new ConnectionHandler() {
	public void onConnection() {
	  syncManger.sync(pipe);
	}
});
 
syncManger.addConfictHandler(new ConflictHandler() {
	public void conflict(Field original, Field new) {
		// user interaction
	}
});

Cheers,
	Erik Jan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/aerogear-dev/attachments/20131204/8b237919/attachment.html 


More information about the aerogear-dev mailing list