andi-huber commented on code in PR #1044:
URL: https://github.com/apache/isis/pull/1044#discussion_r938415467
##########
core/transaction/src/main/java/org/apache/isis/core/transaction/changetracking/EntityChangeTracker.java:
##########
@@ -26,53 +31,68 @@
*
* @since 1.x but renamed/refactored for v2 {@index}
*/
-public interface EntityChangeTracker {
+public interface EntityChangeTracker extends DisposableBean {
+
+ /**
+ * Provided primarily for testing, but also used in cases where an attempt
is made to resolve a bean but
+ * there is no active interaction.
+ */
+ EntityChangeTracker NOOP = new EntityChangeTracker() {
+ @Override public void destroy() throws Exception {}
+ @Override public void enlistCreated(ManagedObject entity) {}
+ @Override public void enlistUpdating(ManagedObject entity,
Can<PropertyChangeRecord> propertyChangeRecords) {}
+ @Override public void enlistDeleting(ManagedObject entity) {}
+ @Override public void incrementLoaded(ManagedObject entity) {}
+ };
/**
* Publishing support: for object stores to enlist an object that has just
been created,
* capturing a dummy value <tt>'[NEW]'</tt> for the pre-modification value.
- * <p>
- * Fires the appropriate event and lifecycle callback: {@literal PERSISTED}
+ *
* <p>
* The post-modification values are captured when the transaction commits.
+ * </p>
*/
void enlistCreated(ManagedObject entity);
- /**
- * Publishing support: for object stores to enlist an object that is about
to be deleted,
- * capturing the pre-deletion value of the properties of the {@link
ManagedObject}.
- * <p>
- * Fires the appropriate event and lifecycle callback: {@literal REMOVING}
- * <p>
- * The post-modification values are captured when the transaction
commits. In the case of deleted objects, a
- * dummy value <tt>'[DELETED]'</tt> is used as the post-modification value.
- */
- void enlistDeleting(ManagedObject entity);
-
/**
* Publishing support: for object stores to enlist an object that is about
to be updated,
* capturing the pre-modification values of the properties of the {@link
ManagedObject}.
- * <p>
- * Fires the appropriate event and lifecycle callback: {@literal UPDATING}
+ *
* <p>
* The post-modification values are captured when the transaction commits.
+ *
+ * <p>
+ * Overload as an optimization for ORMs (specifically, JPA) where already
have access to the changed records by
+ * accessing the ORM-specific data structures
(<code>EntityManager</code>'s unit-of-work).
+ *
+ * </p>
+ *
+ * @param entity
+ * @param propertyChangeRecords - optional parameter (as a performance
optimization) to provide the pre-computed {@link PropertyChangeRecord}s from
the ORM. JPA does this, JDO does not.
*/
- void enlistUpdating(ManagedObject entity);
+ void enlistUpdating(ManagedObject entity, @Nullable
Can<PropertyChangeRecord> propertyChangeRecords);
Review Comment:
TODO: Can like Optional should never be nullable ... use Can.emtpy() instead
of null
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]