[Minor] Changed TX to not first validate all commands executing them, but validate then do each.
This commit is contained in:
parent
d5fd5018cd
commit
11c2268b9a
|
@ -1400,7 +1400,6 @@ public abstract class AbstractTransaction implements StrolchTransaction {
|
||||||
public void flush() {
|
public void flush() {
|
||||||
try {
|
try {
|
||||||
addModelChangeCommands();
|
addModelChangeCommands();
|
||||||
validateCommands();
|
|
||||||
doCommands();
|
doCommands();
|
||||||
writeChanges();
|
writeChanges();
|
||||||
clearCache();
|
clearCache();
|
||||||
|
@ -1421,13 +1420,11 @@ public abstract class AbstractTransaction implements StrolchTransaction {
|
||||||
this.txResult.setState(TransactionState.COMMITTING);
|
this.txResult.setState(TransactionState.COMMITTING);
|
||||||
|
|
||||||
addModelChangeCommands();
|
addModelChangeCommands();
|
||||||
validateCommands();
|
|
||||||
doCommands();
|
doCommands();
|
||||||
|
|
||||||
// do it twice, since some commands might generate new model changes
|
// do it twice, since some commands might generate new model changes
|
||||||
if (this.objectFilter != null && !this.objectFilter.isEmpty()) {
|
if (this.objectFilter != null && !this.objectFilter.isEmpty()) {
|
||||||
addModelChangeCommands();
|
addModelChangeCommands();
|
||||||
validateCommands();
|
|
||||||
doCommands();
|
doCommands();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1855,16 +1852,6 @@ public abstract class AbstractTransaction implements StrolchTransaction {
|
||||||
return audit;
|
return audit;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Calls {@link Command#validate()} on all registered command. This is done before we perform any commands and thus
|
|
||||||
* no rollback needs be done due to invalid input for a command
|
|
||||||
*/
|
|
||||||
private void validateCommands() {
|
|
||||||
for (Command command : this.commands) {
|
|
||||||
command.validate();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calls {@link Command#doCommand()} on all registered commands. This is done after the commands have been validated
|
* Calls {@link Command#doCommand()} on all registered commands. This is done after the commands have been validated
|
||||||
* so chance of a runtime exception should be small
|
* so chance of a runtime exception should be small
|
||||||
|
@ -1880,6 +1867,7 @@ public abstract class AbstractTransaction implements StrolchTransaction {
|
||||||
ListIterator<Command> iter = commands.listIterator();
|
ListIterator<Command> iter = commands.listIterator();
|
||||||
while (iter.hasNext()) {
|
while (iter.hasNext()) {
|
||||||
Command command = iter.next();
|
Command command = iter.next();
|
||||||
|
command.validate();
|
||||||
this.flushedCommands.add(command);
|
this.flushedCommands.add(command);
|
||||||
command.doCommand();
|
command.doCommand();
|
||||||
iter.remove();
|
iter.remove();
|
||||||
|
|
Loading…
Reference in New Issue