[Minor] Added simpler constructor to Command class

This commit is contained in:
Robert von Burg 2018-11-17 16:49:47 +01:00
parent fefa23b62c
commit 09bcdfd772
1 changed files with 77 additions and 69 deletions

View File

@ -15,9 +15,6 @@
*/
package li.strolch.service.api;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import li.strolch.agent.api.ComponentContainer;
import li.strolch.agent.api.StrolchComponent;
import li.strolch.model.PolicyContainer;
@ -33,11 +30,13 @@ import li.strolch.privilege.model.Restrictable;
import li.strolch.runtime.StrolchConstants;
import li.strolch.runtime.privilege.PrivilegedRunnable;
import li.strolch.runtime.privilege.PrivilegedRunnableWithResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* <p>
* Implementation of the Command Pattern to create re-usable components which are performed during
* {@link StrolchTransaction StrolchTransactions} as part of the execution of {@link Service Services}
* Implementation of the Command Pattern to create re-usable components which are performed during {@link
* StrolchTransaction StrolchTransactions} as part of the execution of {@link Service Services}
* </p>
*
* <p>
@ -54,11 +53,23 @@ public abstract class Command implements Restrictable {
private final StrolchTransaction tx;
/**
* Instantiate a new {@link Command}
* Instantiate a new command
*
* @param tx
* the transaction
*/
public Command(StrolchTransaction tx) {
this.container = tx.getContainer();
this.tx = tx;
}
/**
* Instantiate a new command
*
* @param container
* the {@link ComponentContainer} to access components at runtime
* @param tx
* the transaction
*/
public Command(ComponentContainer container, StrolchTransaction tx) {
this.container = container;
@ -66,8 +77,7 @@ public abstract class Command implements Restrictable {
}
/**
* Allows the concrete {@link Command} implementation access to {@link StrolchComponent StrolchComponents} at
* runtime
* Allows the concrete command implementation access to {@link StrolchComponent StrolchComponents} at runtime
*
* @param clazz
* the type of component to be returned
@ -93,9 +103,7 @@ public abstract class Command implements Restrictable {
*
* @param policyClass
* the policy type to return. The simple name of the class determines the type of Policy to return.
* @param policyDefs
* the policy defs from which to get the policy by using the simple name of the policy class to determine
* the type of policy to return
* @param policyContainer the container
*
* @return the policy
*/
@ -199,8 +207,8 @@ public abstract class Command implements Restrictable {
}
/**
* Performs the given {@link PrivilegedRunnable} as the privileged system user
* {@link StrolchConstants#SYSTEM_USER_AGENT}
* Performs the given {@link PrivilegedRunnable} as the privileged system user {@link
* StrolchConstants#SYSTEM_USER_AGENT}
*
* @param action
* the action to perform
@ -212,8 +220,8 @@ public abstract class Command implements Restrictable {
}
/**
* Performs the given {@link PrivilegedRunnableWithResult} as the privileged system user
* {@link StrolchConstants#SYSTEM_USER_AGENT}
* Performs the given {@link PrivilegedRunnableWithResult} as the privileged system user {@link
* StrolchConstants#SYSTEM_USER_AGENT}
*
* @param action
* the action to perform
@ -264,8 +272,8 @@ public abstract class Command implements Restrictable {
*
* <p>
* <b>Note:</b> Do not call this method directly, this method is called by the {@link StrolchTransaction} when the
* transaction is committed. Add this {@link Command} to the transaction by calling
* {@link StrolchTransaction#addCommand(Command)}
* transaction is committed. Add this {@link Command} to the transaction by calling {@link
* StrolchTransaction#addCommand(Command)}
* </p>
*/
public abstract void doCommand();