mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
Fix beanchange deser (#1178)
Fix / support JSON marshalling of BeanChange + add changeLogAsync option to ServerConfig
This commit is contained in:
committed by
Rob Bygrave
parent
2263d31f46
commit
6ac146cabe
@@ -368,6 +368,8 @@ public class ServerConfig {
|
||||
|
||||
private ChangeLogRegister changeLogRegister;
|
||||
|
||||
private boolean changeLogAsync;
|
||||
|
||||
private ReadAuditLogger readAuditLogger;
|
||||
|
||||
private ReadAuditPrepare readAuditPrepare;
|
||||
@@ -970,6 +972,20 @@ public class ServerConfig {
|
||||
this.changeLogIncludeInserts = changeLogIncludeInserts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true (default) if the changelog should be written async.
|
||||
*/
|
||||
public boolean isChangeLogAsync() {
|
||||
return changeLogAsync;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets if the changelog should be written async (default = true).
|
||||
*/
|
||||
public void setChangeLogAsync(boolean changeLogAsync) {
|
||||
this.changeLogAsync = changeLogAsync;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the ReadAuditLogger to use.
|
||||
*/
|
||||
|
||||
@@ -8,37 +8,43 @@ public class BeanChange {
|
||||
/**
|
||||
* The underling base table name.
|
||||
*/
|
||||
private final String type;
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* The tenantId value.
|
||||
*/
|
||||
private final Object tenantId;
|
||||
private Object tenantId;
|
||||
|
||||
/**
|
||||
* The id value.
|
||||
*/
|
||||
private final Object id;
|
||||
private Object id;
|
||||
|
||||
/**
|
||||
* The INSERT, UPDATE or DELETE change type.
|
||||
*/
|
||||
private final ChangeType event;
|
||||
private ChangeType event;
|
||||
|
||||
/**
|
||||
* The time the bean change was created.
|
||||
*/
|
||||
private final long eventTime;
|
||||
private long eventTime;
|
||||
|
||||
/**
|
||||
* The change in JSON form.
|
||||
*/
|
||||
private final String data;
|
||||
private String data;
|
||||
|
||||
/**
|
||||
* The change in JSON form.
|
||||
*/
|
||||
private final String oldData;
|
||||
private String oldData;
|
||||
|
||||
/**
|
||||
* Constructor for JSON tools.
|
||||
*/
|
||||
public BeanChange() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct with change as JSON.
|
||||
|
||||
@@ -95,6 +95,11 @@ public class TransactionManager {
|
||||
*/
|
||||
private final ChangeLogListener changeLogListener;
|
||||
|
||||
/**
|
||||
* Use Background executor to perform change-logging
|
||||
*/
|
||||
private final boolean changeLogAsync;
|
||||
|
||||
protected final boolean localL2Caching;
|
||||
|
||||
protected final boolean viewInvalidation;
|
||||
@@ -119,6 +124,7 @@ public class TransactionManager {
|
||||
this.viewInvalidation = options.descMgr.requiresViewEntityCacheInvalidation();
|
||||
this.changeLogPrepare = options.descMgr.getChangeLogPrepare();
|
||||
this.changeLogListener = options.descMgr.getChangeLogListener();
|
||||
this.changeLogAsync = options.config.isChangeLogAsync();
|
||||
this.clusterManager = options.clusterManager;
|
||||
this.serverName = options.config.getName();
|
||||
this.backgroundExecutor = options.backgroundExecutor;
|
||||
@@ -388,8 +394,12 @@ public class TransactionManager {
|
||||
// can set userId, userIpAddress & userContext if desired
|
||||
if (changeLogPrepare.prepare(changeSet)) {
|
||||
|
||||
// call the log method in background
|
||||
backgroundExecutor.execute(() -> changeLogListener.log(changeSet));
|
||||
if (changeLogAsync) {
|
||||
// call the log method in background
|
||||
backgroundExecutor.execute(() -> changeLogListener.log(changeSet));
|
||||
} else {
|
||||
changeLogListener.log(changeSet);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user