创建使用现有接口的运行时任务

本示例创建一个运行时任务。该任务使用已定义的接口,即,在客户机的本地文件系统中,有一个文件包含该接口的描述。

执行本任务的原因和时间

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

本任务的步骤

  1. 访问 ClientTaskFactory 并创建资源集以包含新任务模型的定义。
    ClientTaskFactory factory = ClientTaskFactory.newInstance(); 
    ResourceSet resourceSet = factory.createResourceSet();
  2. 访问 WSDL 定义和操作描述。

    接口描述的位置相对于代码的执行位置。

    Definition definition = factory.loadWSDLDefinition( 
                              resourceSet, "interface.wsdl"  );
    PortType portType = definition.getPortType( 
                         new QName( definition.getTargetNamespace(), "doItPT" ) );
    Operation operation = portType.getOperation("doIt", null, 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 接口来创建任务实例或任务模板。您必须提供包含数据类型定义的应用程序的名称,这样才能访问那些数据类型定义。该应用程序还必须包含一个哑任务或哑流程,这样业务流程编排器才能装入该应用程序。
    • 以下代码段创建任务实例:
      task.createTask( taskModel, "BOapplication", "HTM" );
    • 以下代码段创建任务模板:
      task.createTaskTemplate( taskModel, "BOapplication" );

结果

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


使用条款 |


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