Package org.drools.runtime.process

Examples of org.drools.runtime.process.WorkItemHandler


    public void internalAbortWorkItem(long id) {
        WorkItemImpl workItem = (WorkItemImpl) workItems.get(new Long(id));
        // work item may have been aborted
        if (workItem != null) {
            WorkItemHandler handler = (WorkItemHandler) this.workItemHandlers.get(workItem.getName());
            if (handler != null) {
                handler.abortWorkItem(workItem, this);
            } else {
                System.err.println("Could not find work item handler for " + workItem.getName());
            }
            workItems.remove(workItem.getId());
        }
View Full Code Here


        if (coverage != null) {
            workingMemory.addEventListener(coverage);
        }

        //Add stub Work Item Handlers
        WorkItemHandler workItemHandlerStub = getWorkItemHandlerStub();
        for (PortableWorkDefinition portableWorkDefinition : workItemService.loadWorkItemDefinitions(item.getUUID())) {
            workingMemory.getWorkItemManager().registerWorkItemHandler(
                    portableWorkDefinition.getName(),
                    workItemHandlerStub);
        }
View Full Code Here

    //Creates a stub Work Item Handler that does nothing. A problem is that if the *real* Work Item Handler
    //sets a Result Parameter that is used in other rules the results of running the Test Scenario could (or
    //more likely would) be different than those expected. We can't use the *real* Work Item Handler as we
    //have no control what code it executes unless we look into using SecurityManagers...
    private WorkItemHandler getWorkItemHandlerStub() {
        return new WorkItemHandler() {

            public void executeWorkItem(WorkItem workItem,
                                        WorkItemManager manager) {
                //Does absolute nothing, however could log execution if needed
            }
View Full Code Here

    }

    public void internalExecuteWorkItem(WorkItem workItem) {
        ((WorkItemImpl) workItem).setId(workItemCounter.incrementAndGet());
        internalAddWorkItem(workItem);
        WorkItemHandler handler = this.workItemHandlers.get(workItem.getName());
        if (handler != null) {
            handler.executeWorkItem(workItem, this);
        } else throw new WorkItemHandlerNotFoundException( "Could not find work item handler for " + workItem.getName(),
                                                    workItem.getName() );
    }
View Full Code Here

    public void internalAbortWorkItem(long id) {
        WorkItemImpl workItem = (WorkItemImpl) workItems.get(new Long(id));
        // work item may have been aborted
        if (workItem != null) {
            WorkItemHandler handler = this.workItemHandlers.get(workItem.getName());
            if (handler != null) {
                handler.abortWorkItem(workItem, this);
            } else {
                workItems.remove( workItem.getId() );
                throw new WorkItemHandlerNotFoundException( "Could not find work item handler for " + workItem.getName(),
                                                                 workItem.getName() );
            }
View Full Code Here

        );
       
        ruleBase.addProcess(process);
       
        InternalWorkingMemory workingMemory = new ReteooWorkingMemory(1, ruleBase);
        workingMemory.getWorkItemManager().registerWorkItemHandler("MyWork", new WorkItemHandler() {
      public void executeWorkItem(WorkItem workItem, WorkItemManager manager) {
        System.out.println("Executing work item");
        SubProcessTest.this.workItem = workItem;
      }
      public void abortWorkItem(WorkItem workItem, WorkItemManager manager) {
View Full Code Here

    if (this.workItems == null) {
          this.workItems = new HashMap<Long, WorkItemInfo>();
        }
    workItems.put(workItem.getId(), workItemInfo);
       
        WorkItemHandler handler = (WorkItemHandler) this.workItemHandlers.get(workItem.getName());
      if (handler != null) {
          handler.executeWorkItem(workItem, this);
      } else {
          System.err.println("Could not find work item handler for " + workItem.getName());
      }
  }
View Full Code Here

     
        WorkItemInfo workItemInfo = em.find(WorkItemInfo.class, id);
        // work item may have been aborted
        if (workItemInfo != null) {
          WorkItemImpl workItem = (WorkItemImpl) workItemInfo.getWorkItem();
            WorkItemHandler handler = (WorkItemHandler) this.workItemHandlers.get(workItem.getName());
            if (handler != null) {
                handler.abortWorkItem(workItem, this);
            } else {
                System.err.println("Could not find work item handler for " + workItem.getName());
            }
            workItems.remove(id);
            em.remove(workItemInfo);
View Full Code Here

    if (this.workItems == null) {
          this.workItems = new HashMap<Long, WorkItemInfo>();
        }
    workItems.put(workItem.getId(), workItemInfo);
       
        WorkItemHandler handler = (WorkItemHandler) this.workItemHandlers.get(workItem.getName());
      if (handler != null) {
          handler.executeWorkItem(workItem, this);
      } else {
          throwWorkItemNotFoundException( workItem );
      }
  }
View Full Code Here

       
        WorkItemInfo workItemInfo = context.findWorkItemInfo( id );
        // work item may have been aborted
        if (workItemInfo != null) {
            WorkItemImpl workItem = (WorkItemImpl) workItemInfo.getWorkItem(env);
            WorkItemHandler handler = (WorkItemHandler) this.workItemHandlers.get(workItem.getName());
            if (handler != null) {
                handler.abortWorkItem(workItem, this);
            } else {
                if ( workItems != null ) {
                    workItems.remove( id );
                    throwWorkItemNotFoundException( workItem );
                }
View Full Code Here

TOP

Related Classes of org.drools.runtime.process.WorkItemHandler

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.