Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Renamed PersistenceObjectCollector to PersistenceObjectRegistrationL… #347

Merged
merged 3 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 listener)
{
this.delegate.registerObjectCollector(collector);
this.delegate.registerRegistrationListener(listener);
}


Expand Down
Loading