Skip to content

Commit

Permalink
Renamed PersistenceObjectCollector to PersistenceObjectRegistrationL…
Browse files Browse the repository at this point in the history
…istener
  • Loading branch information
hg-ms committed Dec 9, 2024
1 parent 67a905e commit 5a70354
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
20 changes: 10 additions & 10 deletions docs/modules/storage/pages/storing-data/best-practice.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,18 @@ Storing those with the provided xref:storing-data/transactions.adoc[convenience

Sometimes, it can be useful to get all objects and/or their assigned storage ID that are persisted by a store operation.

To do so, you can register a custom `PersistenceObjectCollector` implementation to a BinaryStorer to collect all objects registered by that storer instance.
To do so, you can register a custom `PersistenceObjectRegistrationListener` implementation to a BinaryStorer to collect all objects registered by that storer instance.

The default storer will call the `collect` method for each object registered to be stored during the store phase. Implementers should be aware that this has an impact on the storer's performance.
The default storer will call the `onObjectRegistration` method for each object registered to be stored during the store phase. Implementers should be aware that this has an impact on the storer's performance.

[source, java, title="PersistenceObjectCollectorImpl:"]
[source, java, title="PersistenceObjectRegistrationListenerImpl:"]
----
public static class PersistenceObjectCollectorImpl implements PersistenceObjectCollector {
public static class PersistenceObjectRegistrationListenerImpl implements PersistenceObjectRegistrationListener {
private Hashtable<Long, Object> persistenceObjects = new Hashtable<Long, Object>();
@Override
public void collect(long objectID, Object object) {
public void onObjectRegistration(long objectID, Object object) {
this.persistenceObjects.put(objectID, object);
}
Expand All @@ -71,17 +71,17 @@ public static class PersistenceObjectCollectorImpl implements PersistenceObjectC
//create a storer
BinaryStorer storer = (Default) storage.createStorer();
//register PersistenceObjectCollector implementation
PersistenceObjectCollectorImpl collector = new PersistenceObjectCollectorImpl();
storer.registerObjectCollector(collector);
//register PersistenceObjectRegistrationListenerImpl implementation
PersistenceObjectRegistrationListenerImpl registrationListener = new PersistenceObjectRegistrationListenerImpl();
storer.registerRegistrationListener(registrationListener);
//store some data
storer.store(...);
storer.commit();
//get and process persisted objects
collector.get().forEach(...);
registrationListener.get().forEach(...);
//clean up
collector.clear();
registrationListener.clear();
----
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

import org.eclipse.serializer.persistence.types.PersistenceCommitListener;
import org.eclipse.serializer.persistence.types.PersistenceObjectCollector;
import org.eclipse.serializer.persistence.types.PersistenceObjectRegistrationListener;
import org.eclipse.serializer.persistence.types.PersistenceStorer;

/**
Expand Down Expand Up @@ -129,9 +129,9 @@ public void registerCommitListener(final PersistenceCommitListener listener)
}

@Override
public void registerObjectCollector(PersistenceObjectCollector collector)
public void registerRegistrationListener(PersistenceObjectRegistrationListener collector)
{
this.delegate.registerObjectCollector(collector);
this.delegate.registerRegistrationListener(collector);
}


Expand Down

0 comments on commit 5a70354

Please sign in to comment.