Package org.drools.spi

Examples of org.drools.spi.Action


        }
    return knowledgeHelper;
  }
 
  protected void executeAction(DroolsAction droolsAction, KnowledgeHelper knowledgeHelper) {
    Action action = (Action) droolsAction.getMetaData("Action");
    ProcessContext context = new ProcessContext();
    context.setNodeInstance(this);
    try {
      action.execute(knowledgeHelper, ((ProcessInstance) getProcessInstance()).getWorkingMemory(), context);
    } catch (Exception exception) {
      String exceptionName = exception.getClass().getName();
      ExceptionScopeInstance exceptionScopeInstance = (ExceptionScopeInstance)
        resolveContextInstance(ExceptionScope.EXCEPTION_SCOPE, exceptionName);
      if (exceptionScopeInstance == null) {
View Full Code Here


    public void internalTrigger(final NodeInstance from, String type) {
        if (!org.drools.workflow.core.Node.CONNECTION_DEFAULT_TYPE.equals(type)) {
            throw new IllegalArgumentException(
                "An ActionNode only accepts default incoming connections!");
        }
    Action action = (Action) getActionNode().getAction().getMetaData("Action");
    try {
        KnowledgeHelper knowledgeHelper = createKnowledgeHelper();
        ProcessContext context = new ProcessContext();
        context.setNodeInstance(this);
          action.execute(knowledgeHelper, ((ProcessInstance) getProcessInstance()).getWorkingMemory(), context);       
    } catch (Exception e) {
        throw new RuntimeException("unable to execute Action", e);
    }
      triggerCompleted();
    }
View Full Code Here

        }
    return knowledgeHelper;
  }
 
  protected void executeAction(DroolsAction droolsAction, KnowledgeHelper knowledgeHelper) {
    Action action = (Action) droolsAction.getMetaData("Action");
    ProcessContext context = new ProcessContext();
    context.setNodeInstance(this);
    try {
      action.execute(knowledgeHelper, ((ProcessInstance) getProcessInstance()).getWorkingMemory(), context);
    } catch (Exception exception) {
      exception.printStackTrace();
      String exceptionName = exception.getClass().getName();
      ExceptionScopeInstance exceptionScopeInstance = (ExceptionScopeInstance)
        resolveContextInstance(ExceptionScope.EXCEPTION_SCOPE, exceptionName);
View Full Code Here

  private static final long serialVersionUID = 510l;

  public void handleException(ExceptionHandler handler, String exception, Object params) {
   
    if (handler instanceof ActionExceptionHandler) {
      Action action = (Action) ((ActionExceptionHandler) handler).getAction().getMetaData("Action");
      try {
          KnowledgeHelper knowledgeHelper = createKnowledgeHelper();
          ProcessContext context = new ProcessContext();
          ProcessInstance processInstance = getProcessInstance();
          ContextInstanceContainer contextInstanceContainer = getContextInstanceContainer();
          if (contextInstanceContainer instanceof NodeInstance) {
            context.setNodeInstance((NodeInstance) contextInstanceContainer);
          } else {
            context.setProcessInstance(processInstance);
          }
          String faultVariable = handler.getFaultVariable();
          if (faultVariable != null) {
            context.setVariable(faultVariable, params);
          }
            action.execute(knowledgeHelper, ((ProcessInstance) processInstance).getWorkingMemory(), context);
      } catch (Exception e) {
          throw new RuntimeException("unable to execute Action", e);
      }
    } else {
      throw new IllegalArgumentException("Unknown exception handler " + handler);
View Full Code Here

        }
    return knowledgeHelper;
  }
 
  protected void executeAction(DroolsAction droolsAction, KnowledgeHelper knowledgeHelper) {
    Action action = (Action) droolsAction.getMetaData("Action");
    ProcessContext context = new ProcessContext();
    context.setNodeInstance(this);
    try {
      action.execute(knowledgeHelper, ((ProcessInstance) getProcessInstance()).getWorkingMemory(), context);
    } catch (Exception exception) {
      exception.printStackTrace();
      String exceptionName = exception.getClass().getName();
      ExceptionScopeInstance exceptionScopeInstance = (ExceptionScopeInstance)
        resolveContextInstance(ExceptionScope.EXCEPTION_SCOPE, exceptionName);
View Full Code Here

       
        final List<String> myList = new ArrayList<String>();
        ActionNode actionNode = new ActionNode();
        actionNode.setName("Print child");
        DroolsAction action = new DroolsConsequenceAction("java", null);
        action.setMetaData("Action", new Action() {
            public void execute(KnowledgeHelper knowledgeHelper, WorkingMemory workingMemory, ProcessContext context) throws Exception {
              System.out.println("Executed action for child " + ((Person) context.getVariable("child")).getName());
                myList.add("Executed action");
            }
        });
View Full Code Here

        process.addNode(startNode);
       
        ActionNode actionNode = new ActionNode();
        actionNode.setName("Print");
        DroolsAction action = new DroolsConsequenceAction("java", null);
        action.setMetaData("Action", new Action() {
      public void execute(KnowledgeHelper knowledgeHelper,
          org.drools.WorkingMemory workingMemory,
          ProcessContext context) throws Exception {
              System.out.println("Executed action");
      }
View Full Code Here

        endNode.setId(2);
        process.addNode(endNode);
        ActionNode actionNode = new ActionNode();
        actionNode.setName("Action");
        DroolsAction action = new DroolsConsequenceAction("java", null);
        action.setMetaData("Action", new Action() {
            public void execute(KnowledgeHelper knowledgeHelper, WorkingMemory workingMemory, ProcessContext context) throws Exception {
              System.out.println("Executed action");
              executed = true;
            }
        });
View Full Code Here

       
        final List<String> myList = new ArrayList<String>();
        ActionNode actionNode = new ActionNode();
        actionNode.setName("Print");
        DroolsAction action = new DroolsConsequenceAction("java", null);
        action.setMetaData("Action", new Action() {
            public void execute(KnowledgeHelper knowledgeHelper, WorkingMemory workingMemory, ProcessContext context) throws Exception {
              System.out.println("Detected event for person " + ((Person) context.getVariable("event")).getName());
                myList.add("Executed action");
            }
        });
View Full Code Here

       
        final List<String> myList = new ArrayList<String>();
        ActionNode actionNode = new ActionNode();
        actionNode.setName("Print");
        DroolsAction action = new DroolsConsequenceAction("java", null);
        action.setMetaData("Action", new Action() {
            public void execute(KnowledgeHelper knowledgeHelper, WorkingMemory workingMemory, ProcessContext context) throws Exception {
              System.out.println("Detected event for person " + ((Person) context.getVariable("event")).getName());
                myList.add("Executed action");
            }
        });
View Full Code Here

TOP

Related Classes of org.drools.spi.Action

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.