本示例创建一个运行时任务,该任务的接口使用复杂类型。复杂类型是已定义的类型,即,在客户机的本地文件系统中,有一些 XSD 文件包含复杂类型的描述。
ClientTaskFactory factory = ClientTaskFactory.newInstance(); ResourceSet resourceSet = factory.createResourceSet();
factory.loadXSDSchema( resourceSet, "InputBO.xsd" ); factory.loadXSDSchema( resourceSet, "OutputBO.xsd" );
// 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 message is an InputBO and // the output message an OutputBO; // a fault message is not specified Operation operation = factory.createOperation ( definition, portType, "doIt", new QName( "http://Input", "InputBO" ), new QName( "http://Output", "OutputBO" ), null);
如果创建任务实例,则不需要“生效日”日期(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 );
此步骤使用缺省值来初始化任务模型的属性。
// 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);
TaskModel taskModel = ClientTaskFactory.createTaskModel( resourceSet );
ValidationProblem[] validationProblems = taskModel.validate();
task.createTask( taskModel, "BOapplication", "HTM" );
task.createTaskTemplate( taskModel, "BOapplication" );
如果创建了运行时任务实例,则现在可以启动它了。如果创建了运行时任务模板,则现在可以根据该模板创建任务实例了。