[New] Added StrolchPolicy.getAgent()
This commit is contained in:
parent
57821adb88
commit
b46a9882da
|
@ -18,6 +18,7 @@ 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;
|
||||
import li.strolch.model.Order;
|
||||
import li.strolch.model.activity.IActivityElement;
|
||||
|
@ -35,24 +36,28 @@ public abstract class StrolchPolicy {
|
|||
|
||||
protected static final Logger logger = LoggerFactory.getLogger(StrolchPolicy.class);
|
||||
|
||||
private final StrolchAgent agent;
|
||||
private final ComponentContainer container;
|
||||
private final StrolchTransaction tx;
|
||||
|
||||
/**
|
||||
* Instantiate a new {@link StrolchPolicy}
|
||||
*
|
||||
* @param tx the transaction for this policy
|
||||
* @param tx
|
||||
* the transaction for this policy
|
||||
*/
|
||||
public StrolchPolicy(StrolchTransaction tx) {
|
||||
this.agent = tx.getAgent();
|
||||
this.container = tx.getContainer();
|
||||
this.tx = tx;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns true if the given component is registered on th container
|
||||
*
|
||||
* @param clazz the type of component to check for
|
||||
* @param clazz
|
||||
* the type of component to check for
|
||||
*
|
||||
* @return true if the component is available
|
||||
*/
|
||||
public boolean hasComponent(Class<?> clazz) {
|
||||
|
@ -63,9 +68,13 @@ public abstract class StrolchPolicy {
|
|||
* Allows the concrete {@link Command} implementation access to {@link StrolchComponent StrolchComponents} at
|
||||
* runtime
|
||||
*
|
||||
* @param clazz the type of component to be returned
|
||||
* @param clazz
|
||||
* the type of component to be returned
|
||||
*
|
||||
* @return the component with the given {@link Class} which is registered on the {@link ComponentContainer}
|
||||
* @throws IllegalArgumentException if the component with the given class does not exist
|
||||
*
|
||||
* @throws IllegalArgumentException
|
||||
* if the component with the given class does not exist
|
||||
*/
|
||||
protected <V> V getComponent(Class<V> clazz) throws IllegalArgumentException {
|
||||
return this.container.getComponent(clazz);
|
||||
|
@ -78,6 +87,13 @@ public abstract class StrolchPolicy {
|
|||
return this.container;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the container
|
||||
*/
|
||||
protected StrolchAgent getAgent() {
|
||||
return this.agent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the {@link StrolchTransaction} bound to this {@link Command}'s runtime
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue