Package org.drools.spi

Examples of org.drools.spi.ProcessContext


       
        MVELDialectRuntimeData data = (MVELDialectRuntimeData) pkgBuilder.getPackage().getDialectRuntimeRegistry().getDialectData( "mvel");
       
        ((MVELAction) actionNode.getAction().getMetaData("Action")).compile( data );
       
        ProcessContext processContext = new ProcessContext( ((InternalWorkingMemory) wm).getKnowledgeRuntime() );
        ((Action) actionNode.getAction().getMetaData("Action")).execute( processContext );
       
        assertEquals("hello world", list.get(0) );
    }   
View Full Code Here


        final WorkingMemory wm = ruleBase.newStatefulSession();

        List<String> list = new ArrayList<String>();
        wm.setGlobal( "list", list );       
       
        ProcessContext processContext = new ProcessContext( ((InternalWorkingMemory) wm).getKnowledgeRuntime() );
        ((Action) actionNode.getAction().getMetaData("Action")).execute( processContext );
      
        assertEquals("hello world", list.get(0) );
    }   
View Full Code Here

        List<String> list = new ArrayList<String>();
        wm.setGlobal( "list", list );       
       
        MVELDialectRuntimeData data = (MVELDialectRuntimeData) pkgBuilder.getPackage().getDialectRuntimeRegistry().getDialectData( "mvel");
       
        ProcessContext processContext = new ProcessContext( ((InternalWorkingMemory) wm).getKnowledgeRuntime() );
        ((MVELAction) actionNode.getAction().getMetaData("Action")).compile( data );
        ((Action)actionNode.getAction().getMetaData("Action")).execute( processContext );
       
        assertEquals("hello world", list.get(0) );
    }   
View Full Code Here

    public boolean evaluate(SplitInstance instance,
                            Connection connection,
                            Constraint constraint) {
        Object value;
        try {
            ProcessContext context = new ProcessContext(instance.getProcessInstance().getKnowledgeRuntime());
            context.setNodeInstance( instance );
            value = this.evaluator.evaluate( context );
        } catch ( Exception e ) {
            throw new RuntimeException( "unable to execute ReturnValueEvaluator",
                                        e );
        }
View Full Code Here

    }
  }
 
  protected void executeAction(DroolsAction droolsAction) {
    Action action = (Action) droolsAction.getMetaData("Action");
    ProcessContext context = new ProcessContext(getProcessInstance().getKnowledgeRuntime());
    context.setNodeInstance(this);
    try {
      action.execute(context);
    } catch (Exception exception) {
      exception.printStackTrace();
      String exceptionName = exception.getClass().getName();
View Full Code Here

   
    if (handler instanceof ActionExceptionHandler) {
      Action action = (Action) ((ActionExceptionHandler) handler).getAction().getMetaData("Action");
      try {
          ProcessInstance processInstance = getProcessInstance();
          ProcessContext processContext = new ProcessContext(processInstance.getKnowledgeRuntime());
          ContextInstanceContainer contextInstanceContainer = getContextInstanceContainer();
          if (contextInstanceContainer instanceof NodeInstance) {
            processContext.setNodeInstance((NodeInstance) contextInstanceContainer);
          } else {
            processContext.setProcessInstance(processInstance);
          }
          String faultVariable = handler.getFaultVariable();
          if (faultVariable != null) {
            processContext.setVariable(faultVariable, params);
          }
            action.execute(processContext);
      } catch (Exception e) {
          throw new RuntimeException("unable to execute Action", e);
      }
View Full Code Here

    }

    private void handleAssignment(Assignment assignment) {
      AssignmentAction action = (AssignmentAction) assignment.getMetaData("Action");
    try {
        ProcessContext context = new ProcessContext(getProcessInstance().getKnowledgeRuntime());
        context.setNodeInstance(this);
          action.execute(getWorkItem(), context);       
    } catch (Exception e) {
        throw new RuntimeException("unable to execute Assignment", e);
    }
    }
View Full Code Here

  public void executeWorkItem(WorkItem workItem, WorkItemManager manager) {
    String className = (String) workItem.getParameter("Class");
    try {
      Class<JavaHandler> c = (Class<JavaHandler>) Class.forName(className);
      JavaHandler handler = c.newInstance();
      ProcessContext kcontext = new ProcessContext(ksession);
      WorkflowProcessInstance processInstance = (WorkflowProcessInstance)
        ksession.getProcessInstance(workItem.getProcessInstanceId());
      kcontext.setProcessInstance(processInstance);
      WorkItemNodeInstance nodeInstance = findNodeInstance(workItem.getId(), processInstance);
      kcontext.setNodeInstance(nodeInstance);
      Map<String, Object> results = handler.execute(kcontext);
            manager.completeWorkItem(workItem.getId(), results);
        return;
        } catch (ClassNotFoundException e) {
            System.err.println(e);
View Full Code Here

            throw new IllegalArgumentException(
                "An ActionNode only accepts default incoming connections!");
        }
    Action action = (Action) getActionNode().getAction().getMetaData("Action");
    try {
        ProcessContext context = new ProcessContext(getProcessInstance().getKnowledgeRuntime());
        context.setNodeInstance(this);
          action.execute(context);       
    } catch (Exception e) {
        throw new RuntimeException("unable to execute Action", e);
    }
      triggerCompleted();
View Full Code Here

                "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

TOP

Related Classes of org.drools.spi.ProcessContext

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.