How Job Handlers are Loaded

The following is a description of how the Job Processor loads Job Handlers (both Autodesk's and Third Party's) on start-up:

  1. Load all Third Party Job Handlers from the Extension folder
  2. Read in the Job Handler configuration information.
  3. Load Autodesk's Job Handlers.
  4. Associate Job Types with Job Handlers and check if each Job Handler is enabled.
  2012 2013 2014
Autodesk Vault Basic    
Autodesk Vault Workgroup
Autodesk Vault Collaboration
Autodesk Vault Professional

Third Party Job Handler Extensions

Each third party extension should exist in its own folder in the Extension Directory:

%allusersprofile%\Autodesk\Vault 2012\Extensions\

So, for example, if we had a job handler extension called "JobHandlerSample", it could reside in the directory %allusersprofile%\Autodesk\Vault 2013\Extensions\JobHandlerSample.

For each folder within Extension Directory, the Job Processor checks for a configuration file.  The configuration file is a plain text file that can be named anything, but must end with the extension .vcet.config.  If the configuration file does not exist, the extension will fail to load.  Here are the contents of a sample config file, JobHandlerSample.vcet.config:

<configuration>
    <connectivity.ExtensionSettings2>
         <assembly>JobHandlerSample</assembly>
         <extensionType>JobProcessor</extensionType>
    </connectivity.ExtensionSettings2>
</configuration>

The assembly element specifies the name of the extension dll.  So, in our sample above, the extension dll is named JobHandlerSample.dll.  The extension type of JobProcessor indicates that this is an extension for the job processor (other extension types can also live in this directory: WebService and VaultClient).

The extension assembly (in our sample, JobHandlerSample.dll) is now loaded.  Upon loading the following checks are done:

  1. The references of the assembly dll are checked to ensure that it doesn't link against any of the vault dlls (those starting with "Connectivity" In their name.  If an extension assembly links to one of these dlls (either directly or indirectly), it will fail to load.
  2. The assembly is checked for a single exported type that implements the IJobHandler interface.  In our JobHandlerSample example, within our assembly's project we could have the following C# class to implement the IJobHandler interface:
    namespace JobHandlerSample
    {
        public class JobHandlerSample : IJobHandler
         {
             public bool CanProcess(string strJobType)
              {
                 return strJobType.Equals("jobhandlersample");
              }
    
              public JobOutcome Execute(IJobProcessorServices context, IJob job)
               {
                  return JobOutcome.Success;
               }
          }
    }         

    There must be exactly one public type in the assembly that implements IJobHandler.  If this is not the case, then the extension will fail to load.  An instance of this type is instantiated.

  3. The assembly is checked for certain required assembly attributes. Specifically,
    1. ApiVersion:  An attribute of type Autodesk.Connectivity.Extensibility.Framework.ApiVersionAttribute which specifies the version of the API that this extension was written for.  If the version does match the current version of the Vault API, the extension will fail to load.
    2. Company, Description, ProductName: Attributes from the namespace System.Reflection of types AssemblyCompanyAttribute, AssemblyDescriptionAttribute, AssemblyProductAttribute are required and must not be empty strings.  If these do not exist or are empty, the extension will fail to load.
    3. ExtensionId : An attribute of type Autodesk.Connectivity.Extensibility.Framework.ExtensionIdAttribute which specifies a unique Id as a string (in Guid form).  If this attribute does not exist or is empty, the extension will fail to load.

Job Handler Configuration

The Job Handler configuration file is an xml file containing configuration information for the Job Processor.  It is located in the same directory as the JobProcessor.exe (usually C:\Program Files\Autodesk\Vault Professional [year]\Explorer) and is named JobProcessor.exe.config.  The relevant section for configuration of Job Handlers is under configuration\connectivityExplorer\jobHandlers.  In this xml section, each jobHandler element represents one Job Handler.  The jobHandler xml elements are of the following form:

<jobHandler class="jobType" handler="NameOfTypeImplementingIJobHandler"/>

Where:

  1. the class represents the Job Type.  When a Job is added to the Job Server queue, the Job Type is specified and this unique string is used to decide which Job Handler will process that Job.
  2. the handlerrepresents the name of the type within the assembly that implements IJobHandler.  This can be specified in various ways.  You need to specify a string that when passed to System.Type.GetType(string) (see http://msdn.microsoft.com/en-us/library/w3f99sx1.aspx) will return the type of the object in your assembly that implements IJobHandler.

Thus, a valid jobHandler elment for our sample extension would be:

<jobHandler class="jobhandlersample" handler="JobHandlerSample.JobHandlerSample, JobHandlerSample"/>

In the JobProcessor.exe.config file, you'll notice that there is already a jobHandler entry for each of Autodesk's built-in Job Handlers.  The built-in Job Handlers only get loaded in if there is an jobHandler entry existing for them.  The built-in Job Handler dlls are located in the same directory as the JobProcessor.exe.

Check if Job Handlers are enabled

The configuration information above is used to associate a Job Type with a specific Job Handler.  Once that is done, each Job Handler is asked if it can process it's specific Job Type.  The Job Handler answers this question by implementing the interface method IJobHandler.CanProcess.  It is at this time that the Job Handler should check if it has everything it needs to be able to process Jobs of its type (for example, some of the dwf creation job handlers check if Inventor is installed). 

When you check which Job Types are currently processed by a Job Processor (by using the menu Administation->Job Types...), each entry listed means that a Job Handler for that Job Type loaded successfully.  If the entry is checked, it indicates that the Job Handler is enabled (that is, it returned "true" from its IJobHandler.CanProcess implementation).  In order to have the Job Processor re-ask a Job Handler if it "can process", the user would need to exit the Job Processor and start it up again.

Once all the Job Handlers have been loaded and queried, the Job Processor is ready to begin pulling jobs of the queue and processing them.

Sample Job Handler

Attached (below) is a sample Job Handler written in C#.  It doesn't do anything useful (it pops up dialogs when the CanProcess and Execute methods are called), but can be used as a template for creating Job Handlers.