创建使用简单 Java 类型的运行时任务

本示例创建一个运行时任务,该任务的接口只使用简单 Java 类型(例如 String 对象)。

执行本任务的原因和时间

本示例仅在已装入资源的调用企业应用程序的上下文中运行。

本任务的步骤

  1. 访问 ClientTaskFactory 并创建资源集以包含新任务模型的定义。
    ClientTaskFactory factory = ClientTaskFactory.newInstance(); 
    ResourceSet resourceSet = factory.createResourceSet();
  2. 创建 WSDL 定义并添加操作描述。
    // create the WSDL interface
    Definition definition = factory.createWSDLDefinition
             ( resourceSet, new QName( "http://www.ibm.com/task/test/", "test" ) );
        
    // create a port type
    PortType portType = factory.createPortType( definition, "doItPT" );
    
    // create an operation; the input and output messages are of type String: 
    // a fault message is not specified
    Operation operation = factory.createOperation
            ( definition, portType, "doIt", 
              new QName( "http://www.w3.org/2001/XMLSchema", "string" ),
              new QName( "http://www.w3.org/2001/XMLSchema", "string" ), 
              null);
  3. 创建新人员任务的 EMF 模型。

    如果创建任务实例,则不需要“生效日”日期(UTCDate)。

    TTask humanTask = factory.createTTask( resourceSet, 
                                           TTaskKinds.HTASK_LITERAL, 
                                           "TestTask", 
                                           new UTCDate( "2005-01-01T00:00:00" ), 
                                           "http://www.ibm.com/task/test/", 
                                           portType, 
                                           operation );

    此步骤使用缺省值来初始化任务模型的属性。

  4. 修改人员任务模型的属性。
    // use the methods from the com.ibm.wbit.tel package, for example,
    humanTask.setBusinessRelevance( TBoolean, YES_LITERAL );
    
    // retrieve the task factory to create or modify composite task elements
    TaskFactory taskFactory = factory.getTaskFactory();
    
    // specify escalation settings
    TVerb verb = taskFactory.createTVerb();
    verb.setName("John");
    
    // create escalationReceiver and add verb
    TEscalationReceiver escalationReceiver = 
                        taskFactory.createTEscalationReceiver();
    escalationReceiver.setVerb(verb);
    
    // create escalation and add escalation receiver 
    TEscalation escalation = taskFactory.createTEscalation();
    escalation.setEscalationReceiver(escalationReceiver);
  5. 创建包含所有资源定义的任务模型。
    TaskModel taskModel = ClientTaskFactory.createTaskModel( resourceSet );
  6. 验证任务模型并更正找到的验证问题。
    ValidationProblem[] validationProblems = taskModel.validate();
  7. 创建运行时任务实例或模板。
    使用 HumanTaskManagerService 接口来创建任务实例或任务模板。由于此应用程序仅使用简单 Java 类型,所以不需要指定应用程序名。
    • 以下代码段创建任务实例:
      task.createTask( taskModel, null, "HTM" );
    • 以下代码段创建任务模板:
      task.createTaskTemplate( taskModel, null );

结果

如果创建了运行时任务实例,则现在可以启动它了。如果创建了运行时任务模板,则现在可以根据该模板创建任务实例了。


使用条款 |


(c) Copyright IBM Corporation 2005, 2006.
本信息中心基于 Eclipse 技术(http://www.eclipse.org)。