To replicate against VOD you need all the dependencies for VOD which also includes some native libraries. How can you avoid these extra dependencies?
Currently there is one work-around. You can start up a db4o server, which acts an intermediate replication server. The clients replicate against that db4o server and the server then replicates to the VOD server. These are the steps which you need to do:
The intermediate db4o server will act as replication server. It needs following dependencies:
From the VOD distribution
From the db4o / dRS distribution
After that you can start a db4o server. Note that it is a pure in memory server, since it does not act a persistent store. For more details take a look at the db4o reference documentation.
ServerConfiguration config = Db4oClientServer.newServerConfiguration(); config.file().generateUUIDs(ConfigScope.GLOBALLY); config.file().generateCommitTimestamps(true); config.file().storage(new PagingMemoryStorage()); config.common().reflectWith(new JdoReflector(Thread.currentThread().getContextClassLoader())); ObjectServer server = Db4oClientServer.openServer(config, "!In:Memory!", 8080); server.grantAccess("sa", "sa");
The next step is to setup periodic replication between the VOD server and the db4o server. Take a look at how to replicate against VOD here. The only difference is that it is executed periodically against the intermediate db4o server.
final Timer timer = new Timer(true); timer.schedule(new TimerTask() { @Override public void run() { runReplication(); } },0, TEN_SECONDS_IN_MILLISEC);
The replication against VOD is the same like here, but with a db4o client.
private void runReplication() { ClientConfiguration config = Db4oClientServer.newClientConfiguration(); config.common().reflectWith(new JdoReflector(Thread.currentThread().getContextClassLoader())); ObjectContainer intermediate = Db4oClientServer.openClient(config,"localhost",8080,"sa","sa"); ReplicationProvider mobileDatabase = new Db4oClientServerReplicationProvider(intermediate); // The rest is just the regular replication stuff
Now the client doesn't need any VOD dependencies, since we replicate via a db4o server. It needs these dependencies:
Additionally the client needs the classes of the stored objects, but the not enhanced version of the classes. So you have to make sure that you've the original classes on the client and the enhanced classes on the server.
After that the replication is very easy. You just connect to the db4o server and replicate the objects. See "Bidirectional Replication"
EmbeddedConfiguration config = Db4oEmbedded.newConfiguration(); config.file().generateUUIDs(ConfigScope.GLOBALLY); config.file().generateCommitTimestamps(true); ObjectContainer theMobileDatabase = Db4oEmbedded.openFile(config, "mobileDatabase.db4o"); ObjectContainer db4oServer = Db4oClientServer.openClient("localhost", 8080, "sa", "sa"); try { ReplicationProvider localProvider = new Db4oEmbeddedReplicationProvider(theMobileDatabase); ReplicationProvider remoteProvider = new Db4oClientServerReplicationProvider(db4oServer); final ReplicationSession replicationSession = Replication.begin(localProvider, remoteProvider); replicateAll(replicationSession,localProvider.objectsChangedSinceLastReplication()); replicateAll(replicationSession,remoteProvider.objectsChangedSinceLastReplication()); replicationSession.commit(); } catch (Exception e){ throw new RuntimeException(e); } finally{ db4oServer.close(); theMobileDatabase.close(); }