From 801f7927710356bc212ab653d0571a3915164fde Mon Sep 17 00:00:00 2001 From: Robert von Burg Date: Wed, 29 Mar 2017 14:14:25 +0200 Subject: [PATCH] [Minor] Added StrolchComponent.openTx() methods --- .../strolch/agent/api/StrolchComponent.java | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/li.strolch.agent/src/main/java/li/strolch/agent/api/StrolchComponent.java b/li.strolch.agent/src/main/java/li/strolch/agent/api/StrolchComponent.java index ee80841be..f6042080b 100644 --- a/li.strolch.agent/src/main/java/li/strolch/agent/api/StrolchComponent.java +++ b/li.strolch.agent/src/main/java/li/strolch/agent/api/StrolchComponent.java @@ -23,9 +23,11 @@ import java.util.Properties; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import li.strolch.persistence.api.StrolchTransaction; import li.strolch.privilege.base.PrivilegeException; import li.strolch.privilege.handler.SystemAction; import li.strolch.privilege.handler.SystemActionWithResult; +import li.strolch.privilege.model.Certificate; import li.strolch.runtime.StrolchConstants; import li.strolch.runtime.configuration.ComponentConfiguration; import li.strolch.runtime.privilege.PrivilegedRunnable; @@ -313,6 +315,48 @@ public class StrolchComponent { return this.container.getPrivilegeHandler().runAsAgentWithResult(runnable); } + /** + * Opens a {@link StrolchTransaction} for the default realm and certificate + * + * @param cert + * the certificate authorizing the transaction + * + * @return the newly created transaction + */ + protected StrolchTransaction openTx(Certificate cert) { + return getContainer().getRealm(cert).openTx(cert, this.getClass()); + } + + /** + * Opens a {@link StrolchTransaction} for the given realm and certificate + * + * @param realm + * the name of the realm in which to open the transaction + * @param cert + * the certificate authorizing the transaction + * + * @return the newly created transaction + */ + protected StrolchTransaction openTx(String realm, Certificate cert) { + return getContainer().getRealm(realm).openTx(cert, this.getClass()); + } + + /** + * Opens a {@link StrolchTransaction} for the given realm and certificate + * + * @param realm + * the name of the realm in which to open the transaction + * @param cert + * the certificate authorizing the transaction + * @param clazz + * the clazz describing the transaction context + * + * @return the newly created transaction + */ + protected StrolchTransaction openTx(String realm, Certificate cert, Class clazz) { + return getContainer().getRealm(realm).openTx(cert, clazz); + } + /** * Returns the version of this component. The version should be stored in the file * {@link #COMPONENT_VERSION_PROPERTIES}. See {@link ComponentVersion} for more information