この例では、インターフェースで複合タイプを使用するランタイム・タスクを作成します。複合タイプは既に定義されています。すなわち、クライアントのローカル・ファイル・システムには、複合タイプの記述を含む 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" );
ランタイム・タスク・インスタンスが作成された場合、それを始動することができます。ランタイム・タスク・テンプレートが作成された場合、そのテンプレートからタスク・インスタンスを作成できます。