You are here: Advanced Replication Strategies > Events

Events

Often you need more information about the replication process or even need to intervene it. dRS allows the registration of a event listener in order to perform such tasks.

When you create the replication session you can pass such a listener instance. The listener will be called for each object which is replicated.

ReplicationSession replicationSession = Replication.begin(providerA, providerB,
        new ReplicationEventListener() {
            public  void onReplicate(ReplicationEvent replicationEvent) {
                ObjectState stateInDesktop = replicationEvent.stateInProviderA();
                if (stateInDesktop.isNew()) {
                    System.out.println("Object '"
                            + stateInDesktop.getObject()
                            + "' is new on desktop database");
                }
                if (stateInDesktop.wasModified()) {
                    System.out.println("Object '"
                            + stateInDesktop.getObject()
                            + "' was modified on desktop database");
                }
            }
        });
AdvancedReplicationExamples.java: Register a listener for information about the replication process