Package com.sun.jini.thread

Examples of com.sun.jini.thread.TaskManager$Task


    /**
     * Schedule two tasks.  The first task throws an exception.  Verify that
     * the second task is run.
     */
    public void run() throws Exception {
        TaskManager manager = new TaskManager();
        long badTaskTime = System.currentTimeMillis() + (10*1000);
        long goodTaskTime = badTaskTime + (10*1000);
        ArrayList taskList = new ArrayList();
        taskList.add(0, new Task() {
            public boolean runAfter(List tasks, int size){
                return false;

            }
            public void run() {
                throw new RuntimeException("Expected Exception");
            }
        });
        final boolean result[] = new boolean[]{false};
        taskList.add(1, new Task() {
            public boolean runAfter(List tasks, int size){
                return (tasks.size()>1);
            }
            public void run() {
                result[0] = true;
            }
        });
        manager.addAll(taskList);
        Thread.sleep(10 * 1000);
        if (!result[0]) {
            throw new TestException("A task that throws a runtime exception"
                + " prevents other tasks from running");
        }
View Full Code Here


        try {
            taskMgr = (TaskManager)config.getEntry(COMPONENT_NAME,
                                                   "taskManager",
                                                   TaskManager.class);
        } catch(NoSuchEntryException e) { /* use default */
            taskMgr = new TaskManager(MAX_N_TASKS,(15*1000),1.0f);
        }
        /* Wakeup manager */
        try {
            wakeupMgr = (WakeupManager)config.getEntry(COMPONENT_NAME,
                                                       "wakeupManager",
View Full Code Here

   
    public void run() throws Exception {
  RestoreContextForTasks.DangerousTask t =
    new RestoreContextForTasks.DangerousTask();
  // Ok now get the task manager
  TaskManager tm = (TaskManager) config.getEntry(
      LDCOMP,
      "taskManager", TaskManager.class);
  tm.add(t);
  synchronized (t) {
      while (!t.done) {
    t.wait();
      }
  }
View Full Code Here

        Bpmn2JsonUnmarshaller unmarshaller = new Bpmn2JsonUnmarshaller();
        Definitions definitions = ((Definitions) unmarshaller.unmarshall(getTestJsonFile("sequenceFlow.json"), "").getContents().get(0));
        assertTrue(definitions.getRootElements().size() == 1);
        Process process = getRootProcess(definitions);
        assertTrue(process.getFlowElements().get(0) instanceof Task);
        Task task = (Task) process.getFlowElements().get(0);
        assertEquals("task1", task.getName());
        Task task2 = (Task) process.getFlowElements().get(1);
        assertEquals("task2", task2.getName());
        SequenceFlow flow = (SequenceFlow) process.getFlowElements().get(2);
        assertEquals("seqFlow", flow.getName());
        assertEquals(task, flow.getSourceRef());
        assertEquals(task2, flow.getTargetRef());
        definitions.eResource().save(System.out, Collections.emptyMap());
View Full Code Here

    public void testAssociationUnmarshalling() throws Exception {
        Bpmn2JsonUnmarshaller unmarshaller = new Bpmn2JsonUnmarshaller();
        Definitions definitions = ((Definitions) unmarshaller.unmarshall(getTestJsonFile("association.json"), "").getContents().get(0));
        assertTrue(definitions.getRootElements().size() == 1);
        Process process = getRootProcess(definitions);
        Task g = (Task) process.getFlowElements().get(0);
        assertEquals("task", g.getName());
        TextAnnotation textA = (TextAnnotation) process.getArtifacts().get(0);
        Association association = (Association) process.getArtifacts().get(1);
        assertEquals(g, association.getSourceRef());
        assertEquals(textA, association.getTargetRef());
        assertEquals(AssociationDirection.NONE, association.getAssociationDirection());
View Full Code Here

    @Test
    public void testAssociationUnidirectionalUnmarshalling() throws Exception {
        Bpmn2JsonUnmarshaller unmarshaller = new Bpmn2JsonUnmarshaller();
        Definitions definitions = ((Definitions) unmarshaller.unmarshall(getTestJsonFile("associationOne.json"), "").getContents().get(0));
        Process process = getRootProcess(definitions);
        Task g = (Task) process.getFlowElements().get(0);
        assertEquals("task", g.getName());
        TextAnnotation textA = (TextAnnotation) process.getArtifacts().get(0);
        Association association = (Association) process.getArtifacts().get(1);
        assertEquals(g, association.getSourceRef());
        assertEquals(textA, association.getTargetRef());
        assertEquals(AssociationDirection.ONE, association.getAssociationDirection());
View Full Code Here

    @Test
    public void testAssociationBidirectionalUnmarshalling() throws Exception {
        Bpmn2JsonUnmarshaller unmarshaller = new Bpmn2JsonUnmarshaller();
        Definitions definitions = ((Definitions) unmarshaller.unmarshall(getTestJsonFile("associationBoth.json"), "").getContents().get(0));
        Process process = getRootProcess(definitions);
        Task g = (Task) process.getFlowElements().get(0);
        assertEquals("task", g.getName());
        TextAnnotation textA = (TextAnnotation) process.getArtifacts().get(0);
        Association association = (Association) process.getArtifacts().get(1);
        assertEquals(g, association.getSourceRef());
        assertEquals(textA, association.getTargetRef());
        assertEquals(AssociationDirection.BOTH, association.getAssociationDirection());
View Full Code Here

    private void updateTaskDataInputs(FlowElementsContainer container, Definitions def) {
        List<FlowElement> flowElements = container.getFlowElements();
        for(FlowElement fe : flowElements) {
            if(fe instanceof Task && !(fe instanceof UserTask)) {
                Task task = (Task) fe;
                boolean foundReadOnlyServiceTask = false;
                Iterator<FeatureMap.Entry> iter = task.getAnyAttribute().iterator();
                while(iter.hasNext()) {
                    FeatureMap.Entry entry = iter.next();
                    if(entry.getEStructuralFeature().getName().equals("taskName")) {
                        if(entry.getValue().equals("ReadOnlyService")) {
                            foundReadOnlyServiceTask = true;
                        }
                    }
                }

                if(foundReadOnlyServiceTask) {
                    if(task.getDataInputAssociations() != null) {
                        List<DataInputAssociation> dataInputAssociations = task.getDataInputAssociations();
                        for(DataInputAssociation dia : dataInputAssociations) {
                            if(dia.getTargetRef().getId().endsWith("TaskNameInput")) {
                                ((FormalExpression) dia.getAssignment().get(0).getFrom()).setBody("ReadOnlyService");
                            }
                        }
View Full Code Here

            if (result == null)
                result = defaultCase(theEObject);
            return result;
        }
        case Bpmn2Package.TASK: {
            Task task = (Task) theEObject;
            T result = caseTask(task);
            if (result == null)
                result = caseActivity(task);
            if (result == null)
                result = caseInteractionNode(task);
View Full Code Here

   * @param flowElements
   */
  public static void nodeHasPoint2StartEvent(List<FlowElement> flowElements,StringBuffer sb) {
    for (FlowElement flowElement : flowElements) {
      if (flowElement instanceof Task) {
        Task task = (Task) flowElement;
        for (SequenceFlow sequenceFlow : task.getOutgoing()) {
          if (sequenceFlow.getTargetRef() instanceof StartEvent) {
            sb.append("连接线不允许指向开始节点;");
          }
        }
      }
View Full Code Here

TOP

Related Classes of com.sun.jini.thread.TaskManager$Task

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.