Using the Object Model

This section demonstrates the use of the XLANG Scheduler Engine object model described in earlier sections.

The code example enumerates all the currently configured group managers. It locates and lists running schedule instances. It also locates instances derived from a schedule named MySchedule. The schedule MySchedule is assumed to contain a port called MyPort; the example prints the port name for this port.

The example is written in VB Script. You do not need to compile this script; you may run this script directly using the following command line in a command prompt window:

CSript ListSchedules.vbs 

On the preceding command line, the name of the script file is ListSchedules.vbs. This script file contains the code shown in Listing 11.1. The code contains three object variables, oMgr, oGrp, and oInst. In VB Script, the variables cannot be data type specific; however, if you were to use a type-aware language, such as Visual Basic, the data types would be as follows:

Dim oMgr As SYSMGRLib.SysMgr 
Dim oGrp As COMRUNTIME.IWFGroupAdmin
Dim oInst As COMRUNTIME.IWFWorkflowInstance

You can recognize the data types from the earlier description of the object model. The variable oMgr holds a reference to the System Manager object, the variable oGrp holds a reference to a group manager, and the variable oInst holds a reference to a running schedule instance. The script code is shown in Listing 11.1.

Note

You can also access this script in the ListSchedules.vbs file from the publisher's Web site.


Listing 11.1. ListSchedules.vbs Script
Dim oMgr, oGrp, oInst
Set oMgr = GetObject("sked://")
WScript.Echo "System manager moniker = " & oMgr.FullyQualifiedName
WScript.Echo "Number of group managers = " & oMgr.Count
For Each oGrp In oMgr
    WScript.Echo "Group manager moniker = " & oGrp.FullyQualifiedName
    WScript.Echo "Name = " & oGrp.Name & ", number of instances = " & CStr(oGrp.Count) & "
, is workflow host = " & CStr  (oMgr.IsWorkflowHost(oGrp.Name))
For Each oInst In oGrp
        WScript.Echo "Schedule instance moniker = " & oInst.FullyQualifiedName
        WScript.Echo "Module name = " & oInst.ModuleName & ",Module ID = " & oInst.ModuleId
        WScript.Echo "Instance ID = " & oInst.InstanceId
        If oInst.ModuleName = "MySchedule" Then
            WScript.Echo "MyPort port name = " & oInst.FullPortName("MyPort")
        End If
    Next
Next

The code first acquires a reference to the System Manager object using the moniker string sked://. The next two lines print the moniker for the System Manager and the number of configured group managers on the server.

The first For loop iterates through each of the group managers on the server. For each group manager, it displays the moniker, its name, and the number of instances running in it. It also shows whether the group manager is currently an XLANG Scheduler Engine host.

The second, inner, For loop iterates over all instances in the group manager selected in the outer loop. For each instance found, the script lists the moniker, the name, the module identity, and the instance identity. If the schedule name is recognized as MySchedule, the script also prints the full port name for the port MyPort.

Listing 11.2 shows the sample output from this script.

Listing 11.2. Sample Output of the ListSchedules.vbs Script
System manager moniker = sked://bztk.bztkdom.omicron.com
Number of group managers = 3
Group manager moniker = sked://bztk.bztkdom.omicron.com!XLANG Scheduler
Name = XLANG Scheduler, number of instances = 2, is workflow host = True
Schedule instance moniker = sked://bztk.bztkdom.omicron.com!XLANG Scheduler/{CCE
 5B532-5534-4329-B13A-58A7FF7C61F8}
Module name = SchedOne, Module ID = 77E34546-A1C9-4818-98D8-DC58F54C3597
Instance ID = {CCE5B532-5534-4329-B13A-58A7FF7C61F8}
Schedule instance moniker = sked://bztk.bztkdom.omicron.com!XLANG Scheduler/{453
 095D9-92D3-4A6F-BF71-67621C8C0AEA}
Module name = MySchedule, Module ID = C65A7337-A07A-49A9-AEED-4C8295D5B967
Instance ID = {453095D9-92D3-4A6F-BF71-67621C8C0AEA}
MyPort port name = sked://bztk.bztkdom.omicron.com!XLANG Scheduler/{453095D9-92D
 3-4A6F-BF71-67621C8C0AEA}/MyPort
Group manager moniker = sked://bztk.bztkdom.omicron.com!TestApp
Name = TestApp, number of instances = 1, is workflow host = True
Schedule instance moniker = sked://bztk.bztkdom.omicron.com!TestApp/{34DC7015-45
 09-4720-BF53-AD2256DE5368}
Module name = SchedOne, Module ID = 77E34546-A1C9-4818-98D8-DC58F54C3597
Instance ID = {34DC7015-4509-4720-BF53-AD2256DE5368}
Group manager moniker = sked://bztk.bztkdom.omicro
n.com!XLANG Two
Name = XLANG Two, number of instances = 0, is workflow host = False

The sample output shows that there are three group managers; however, only two are enabled for hosting schedules. The group manager named XLANG Two is currently disabled from running schedule instances. The group manager XLANG Scheduler contains two running schedule instances. The modules associated with these instances are respectively SchedOne and MySchedule. The monikers are shown for the System Manager, the group managers, and the running schedule instances. The full port name for MyPort is also listed.

This wraps the discussion of the object model itself. We now look at the events generated when the engine runs.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset