[New] Added StrolchPolicy.isTxOpen()

This commit is contained in:
Robert von Burg 2023-10-30 12:04:42 +01:00
parent 857affbdea
commit 8e7ee2341a
Signed by: eitch
GPG Key ID: 75DB9C85C74331F7
1 changed files with 10 additions and 2 deletions

View File

@ -15,8 +15,6 @@
*/
package li.strolch.policy;
import static li.strolch.model.StrolchModelConstants.PolicyConstants.PARAM_ORDER;
import li.strolch.agent.api.ComponentContainer;
import li.strolch.agent.api.StrolchAgent;
import li.strolch.agent.api.StrolchComponent;
@ -27,6 +25,8 @@ import li.strolch.service.api.Command;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static li.strolch.model.StrolchModelConstants.PolicyConstants.PARAM_ORDER;
/**
* Interface for all Strolch policies, which are instantiated by the {@link PolicyHandler}
*
@ -103,6 +103,14 @@ public abstract class StrolchPolicy {
return this.tx;
}
/**
* Returns true if this TX is still open, or committing, and thus can still be used
* @return true if this TX is still open, or committing, and thus can still be used
*/
protected boolean isTxOpen() {
return this.tx.isOpen() || this.tx.isCommitting();
}
protected Order getOrder(IActivityElement element) {
return tx().getOrderByRelation(element.getRootElement(), PARAM_ORDER, true);
}