ObjectLifecyclePublisher

Responsible for collecting and then passing along changes (to the EntityChangeTracker, in persistence commons) so that they can be published; and is responsible for calling the various persistence call-back facets.

this interface should really have been called ObjectLifecycleSubscriber…​

API

ObjectLifecyclePublisher.java
interface ObjectLifecyclePublisher {
  void onPostCreate(ManagedObject domainObject)     (1)
  void onPostLoad(ManagedObject entity)     (2)
  void onPrePersist(Either<ManagedObject, ManagedObject> eitherWithOrWithoutOid)     (3)
  void onPostPersist(ManagedObject entity)     (4)
  void onPreUpdate(ManagedObject entity, Function<ManagedObject, Can<PropertyChangeRecord>> propertyChangeRecordSupplier)     (5)
  void onPostUpdate(ManagedObject entity)     (6)
  void onPreRemove(ManagedObject entity)     (7)
}
1 onPostCreate(ManagedObject)

Independent of the persistence stack, called when an object has been created in-memory, for example by FactoryService and internal ObjectManager .

2 onPostLoad(ManagedObject)

Called by the JPA object store, just after an object is retrieved from the database.

3 onPrePersist(Either)

Called by the JPA object store, just before an entity is inserted into the database.

4 onPostPersist(ManagedObject)

Called by the JPA object store, just after an entity has been inserted into the database.

5 onPreUpdate(ManagedObject, Function)

Called by the JPA object store, just before the object is about to be updated.

6 onPostUpdate(ManagedObject)

Called by the JPA object store, after an existing entity has been updated.

7 onPreRemove(ManagedObject)

Called by the JPA object store, just before an entity is deleted from the database.

Members

onPostCreate(ManagedObject)

Independent of the persistence stack, called when an object has been created in-memory, for example by FactoryService and internal ObjectManager .

Default implementation fires off callback/lifecycle events.

onPostLoad(ManagedObject)

Called by the JPA object store, just after an object is retrieved from the database.

Default implementation calls EntityChangeTracker#recognizeLoaded(ManagedObject) and fires off callback/lifecycle events.

onPrePersist(Either)

Called by the JPA object store, just before an entity is inserted into the database.

Default implementation fires callbacks (including emitting the PreStoreEvent , eg as subscribed) by the TimestampService .

onPostPersist(ManagedObject)

Called by the JPA object store, just after an entity has been inserted into the database.

Default implementation fires callbacks and enlists the entity within EntityChangeTracker for create/persist.

onPreUpdate(ManagedObject, Function)

Called by the JPA object store, just before the object is about to be updated.

Default implementation fires callbacks and enlists the entity within EntityChangeTracker for update.

onPostUpdate(ManagedObject)

Called by the JPA object store, after an existing entity has been updated.

Default implementation fires callbacks.

onPreRemove(ManagedObject)

Called by the JPA object store, just before an entity is deleted from the database.

Default implementation fires callbacks and enlists the entity within EntityChangeTracker for delete/remove.