In previous versions of the JobScheduler, jobs were created using a Scripting Engine and the code (text) of the scripts (VBScript, JScript, PerlScript) were directly entered in the <script> element.
A JobScheduler job can also be implemented as a com class. This class can be implemented in every language which supports com, such as C#, C++, Delphi and VisualBasic (VB6 or VB.net). The com class can, however, also be implemented with VBScript, JScript und PerlScript using the "Windows Script Component".
This class allows use of job, thread script or JobScheduler script methods as follows:
spooler_init()
spooler_exit()
spooler_open()
spooler_close()
spooler_process()
spooler_on_success()
spooler_on_error()
Each method is optional. Should a method not be implemented, then the existing JobScheduler script procedure will be followed.
In addition, this class should provide a method with which the JobScheduler context can be assigned:
spooler_set_context(context)
This context is a com object (IDispatch) with the following properties:
log
JobScheduler
job
task
These properties deliver the spooler_log, spooler_task, spooler_job and JobScheduler objects, known from the JobScheduler-Script.
Similarities between script in the Scripting Engine und the com class:
Differences between Script in the Scripting Engine and the com class:
Skript using the Scripting Engine |
COM Class |
|
Source code is included in the configuaration (or externally using <include>). |
Implementation is independent of the JobScheduler. Any language which generates COM classes with late binding (IDispatch) can be used. |
|
The context makes the following predefined variables available to the script: spooler_log, JobScheduler, spooler_job and spooler_task. |
The JobScheduler makes the spooler_set_context() method of the com object available. |
|
A script can be used reused by way of <include> at different stages when it is saved as a file |
The class can be used at different stages. Seperate class objects are made. |
Declaration in the JobScheduler Configuration
A job registered with a com class
can be addressed by its class name:
<job name="delphijob">
<script com_class="my_spooler_job_class"/>
</job>
The unique clSID can be specified instead of the class name:
<job name="delphijob">
<script com_class="{F44FF458-D4DE-4cef-AA1A-CCC507346581}"/>
</job>
Direct DLL Specification
When a DLL requires a further DLL which cannot be loaded, then Windows stops the JobScheduler with a message box. The JobScheduler continues only after the ok button is clicked. Specification of the DLL is therefore not suitable for unsupervised use.
Should the com class not be registered, then the DLL can be directly specified. The class is then defined as a hexadecimal CLSID.
<job name="delphijob">
<script com_class="{xxxx-xx-...}" filename="my_delphi.dll"/>
</job>
Example:
The com class is specified using the "Windows Script Component". The source is:
<?XML version="1.0"?>
<component>
<registration
progid = "Joacim.Component"
classid = "{F44FF458-D4DE-4cef-AA1A-CCC507346581}"
description = "Joacims Script Component"
version = "1"
/>
<public>
<method name="spooler_set_context"/>
<method name="spooler_init"/>
<method name="spooler_exit"/>
<method name="spooler_open"/>
<method name="spooler_process"/>
</public>
<script language="VBScript">
<![CDATA[
dim spooler_log
dim spooler_task
dim i
function spooler_set_context(c)
set spooler_log = c.log
set spooler_task = c.task
spooler_log "Script component spooler_set_context"
end function
function spooler_init
spooler_log "Script component spooler_init"
end function
function spooler_exit
spooler_log "Script component spooler_exit"
end function
function spooler_open
spooler_log "Script component spooler_open"
i = 3
end function
function spooler_process
spooler_log "Script component spooler_process i=" & i
i = i - 1
spooler_process = i > 0
end function
]]>
</script>
</component>
This source code is written in the job.wsc file and
registered as a COM-Server with the following command:
regsvr32 job.wsc
The server can be specified in the JobScheduler configuration with its class name:
<job name="component">
<script com_class="Joacim.Component"/>
<run_time once="yes"/>
</job>
or with its unique CLSID:
<job name="component">
<script com_class="{F44FF458-D4DE-4cef-AA1A-CCC507346581}"/>
<run_time once="yes"/>
</job>
Unix
Building a Unix port is possible in principle, despite com. The early binding would be used instead of the late binding through the IDispatch interface. This means that: