Difference between revisions of "Documentation/DevGuide/WritingUNO/Jobs/Configuration"

From Apache OpenOffice Wiki
Jump to: navigation, search
m (Robot: Changing Category:Documentation/Developers Guide/Writing UNO Components)
(5 intermediate revisions by 3 users not shown)
Line 5: Line 5:
 
|PrevPage=Documentation/DevGuide/WritingUNO/Jobs/Returning Results
 
|PrevPage=Documentation/DevGuide/WritingUNO/Jobs/Returning Results
 
|NextPage=Documentation/DevGuide/WritingUNO/Jobs/Installation
 
|NextPage=Documentation/DevGuide/WritingUNO/Jobs/Installation
}}
+
}} {{Documentation/DevGuideLanguages|Documentation/DevGuide/WritingUNO/Jobs/{{SUBPAGENAME}}}} {{DISPLAYTITLE:Configuration}}  
{{DISPLAYTITLE:Configuration}}
+
 
Although jobs that are called through a ''vnd.sun.star.jobs:'' URL by their implementation name do not require it, a job usually has configuration data. The configuration package ''org.openoffice.Office.Jobs'' contains all necessary information:
+
Although jobs that are called through a ''vnd.sun.star.jobs:'' URL by their implementation name do not require it, a job usually has configuration data. The configuration package ''org.openoffice.Office.Jobs'' contains all necessary information:  
  
 
   <source lang="xml"><?xml version="1.0" encoding="UTF-8"?>
 
   <source lang="xml"><?xml version="1.0" encoding="UTF-8"?>
 
   <!DOCTYPE oor:component-schema SYSTEM "../../../../component-schema.dtd">
 
   <!DOCTYPE oor:component-schema SYSTEM "../../../../component-schema.dtd">
   <oor:component-schema xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" oor:name="Jobs" oor:package="org.openoffice.Office" xml:lang="en-US">
+
   <oor:component-schema xmlns:oor="http://openoffice.org/2001/registry"  
 +
                        xmlns:xs="http://www.w3.org/2001/XMLSchema"  
 +
                        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
 +
                        oor:name="Jobs"  
 +
                        oor:package="org.openoffice.Office"  
 +
                        xml:lang="en-US">
 
       <templates>
 
       <templates>
 
           <group oor:name="Job">
 
           <group oor:name="Job">
Line 31: Line 36:
 
   </oor:component-schema></source>
 
   </oor:component-schema></source>
  
The Job template contains all properties that describe a job component. Instances of this template are located inside the configuration set Jobs.
+
The Job template contains all properties that describe a job component. Instances of this template are located inside the configuration set Jobs.  
  
{|border="1" cellpadding=4 style="border-collapse:collapse;"
+
{| border="1" cellpadding="4" style="border-collapse:collapse;"
|-bgcolor=#EDEDED
+
|- bgcolor="#EDEDED"
!colspan="2"|Properties of the Job template  
+
! colspan="2" | Properties of the Job template
 
|-
 
|-
|<code>Alias</code>  
+
| <code>Alias</code>  
|string. This property is declared as the name of the corresponding set node inside the configuration set <code>Jobs</code>. It must be a unique name, which represents the structured information of a job. In the example ''.xcu'' file below its value is "<code>SyncJob</code>". In the job execution arguments this property is passed as <code>Config - Alias</code>
+
| string. This property is declared as the name of the corresponding set node inside the configuration set <code>Jobs</code>. It must be a unique name, which represents the structured information of a job. In the example ''.xcu'' file below its value is "<code>SyncJob</code>". In the job execution arguments this property is passed as <code>Config - Alias</code>
 
|-
 
|-
|<code>Service</code>  
+
| <code>Service</code>  
|string. Represents the UNO implementation name of the job component. In the job execution arguments this property is passed as <code>Config - Service</code>
+
| string. Represents the UNO implementation name of the job component. In the job execution arguments this property is passed as <code>Config - Service</code>
 
|-
 
|-
|<code>Arguments</code>  
+
| <code>Arguments</code>  
|set of any entries. This list can be filled with any values and represents the private set of configuration data for this job. In the job execution arguments this property is passed as <code>JobConfig</code>
+
| set of any entries. This list can be filled with any values and represents the private set of configuration data for this job. In the job execution arguments this property is passed as <code>JobConfig</code>
 
|}
 
|}
  
The job property <code>Alias</code> was created to provide you with more flexibility for a developing components. You can use the same UNO implementation, but register it with different Aliases. At runtime the job instance will be initialized with its own configuration data and can detect which representation is used.
+
The job property <code>Alias</code> was created to provide you with more flexibility for a developing components. You can use the same UNO implementation, but register it with different Aliases. At runtime the job instance will be initialized with its own configuration data and can detect which representation is used.  
  
{{Documentation/Caution|You cannot use the generic UNO service names <idl>com.sun.star.task.Job</idl> or <idl>com.sun.star.task.AsyncJob</idl> for the <tt>Service</tt> job property, because the job executor cannot identify the correct job implementation. To avoid ambiguities, it is necessary to use the UNO implementation name of the component.}}
+
{{Warn|You cannot use the generic UNO service names <idl>com.sun.star.task.Job</idl> or <idl>com.sun.star.task.AsyncJob</idl> for the <tt>Service</tt> job property, because the job executor cannot identify the correct job implementation. To avoid ambiguities, it is necessary to use the UNO implementation name of the component.}}  
  
Every job instance can be bound to multiple events. An event indicates a special office state, which can be detected at runtime (for example, <code>OnFirstVisibleTask</code> ), and which can be triggered by a call to the job executor when the first document window is displayed.
+
Every job instance can be bound to multiple events. An event indicates a special office state, which can be detected at runtime (for example, <code>OnFirstVisibleTask</code> ), and which can be triggered by a call to the job executor when the first document window is displayed.  
  
{|border="1" cellpadding=4 style="border-collapse:collapse;"
+
{| border="1" cellpadding="4" style="border-collapse:collapse;"
|-bgcolor=#EDEDED
+
|- bgcolor="#EDEDED"
!colspan="2"|Properties of the Event template  
+
! colspan="2" | Properties of the Event template
 
|-
 
|-
|<code>EventName</code>  
+
| <code>EventName</code>  
|string. This property is declared as the name of the corresponding set node inside the configuration set <code>Events</code>. It must be a unique name, which describes a functional state. In the example ''.xcu'' file below its value is "<code>onFirstVisibleTask</code>".
+
| string. This property is declared as the name of the corresponding set node inside the configuration set <code>Events</code>. It must be a unique name, which describes a functional state. In the example ''.xcu'' file below its value is "<code>onFirstVisibleTask</code>".  
 
+
 
Section [[Documentation/DevGuide/WritingUNO/Jobs/List of Supported Events|List of Supported Events]] summarizes the events currently triggered by the office. In addition, developers can use arbitrary event strings with the ''vnd.sun.star.jobs:'' URL or in calls to <code>trigger()</code> at the <idl>com.sun.star.task.JobExecutor</idl> service.  
 
Section [[Documentation/DevGuide/WritingUNO/Jobs/List of Supported Events|List of Supported Events]] summarizes the events currently triggered by the office. In addition, developers can use arbitrary event strings with the ''vnd.sun.star.jobs:'' URL or in calls to <code>trigger()</code> at the <idl>com.sun.star.task.JobExecutor</idl> service.  
 +
 
|-
 
|-
|<code>JobList</code>  
+
| <code>JobList</code>  
|set of <code>TimeStamp</code> entries. This set contains a list of all <code>Alias</code> names of jobs that are bound to this event. Every job registration can be combined with time stamp values. Please refer to the description of the template <code>TimeStamp</code> below for details  
+
| set of <code>TimeStamp</code> entries. This set contains a list of all <code>Alias</code> names of jobs that are bound to this event. Every job registration can be combined with time stamp values. Please refer to the description of the template <code>TimeStamp</code> below for details
 
|}
 
|}
  
As an optional feature, every job registration that is bound to an event can be enabled or disabled by two time stamp values. In a shared installation of {{PRODUCTNAME}}, an administrator can use the <code>AdminTime</code> value to reactivate jobs for every newly started user office instance; regardless of earlier executions of these jobs. That can be useful, for example, for updating user installations if new functions have been added to the shared installation.
+
As an optional feature, every job registration that is bound to an event can be enabled or disabled by two time stamp values. In a shared installation of {{PRODUCTNAME}}, an administrator can use the <code>AdminTime</code> value to reactivate jobs for every newly started user office instance; regardless of earlier executions of these jobs. That can be useful, for example, for updating user installations if new functions have been added to the shared installation.  
  
{|border="1" cellpadding=4 style="border-collapse:collapse;"
+
{| border="1" cellpadding="4" style="border-collapse:collapse;"
|-bgcolor=#EDEDED
+
|- bgcolor="#EDEDED"
!colspan="2"|Properties of the TimeStamp template  
+
! colspan="2" | Properties of the TimeStamp template
 
|-
 
|-
|<code>AdminTime</code>
+
| <code>AdminTime</code>  
|string. This value must be formatted according to the ISO 8601. It contains the time stamp, which can only be adjusted by an administrator, to reactivate this job.  
+
| string. This value must be formatted according to the ISO 8601. It contains the time stamp, which can only be adjusted by an administrator, to reactivate this job.
 
|-
 
|-
|<code>UserTime</code>  
+
| <code>UserTime</code>  
|string. This value must be formatted according to the ISO 8601. It contains the time, when this job was finished successfully last time upon the configured event.  
+
| string. This value must be formatted according to the ISO 8601. It contains the time, when this job was finished successfully last time upon the configured event.
 
|}
 
|}
  
Using this time stamp feature can sometimes be complicated. For example, assume that there is a job that was installed using the Extension Manager. The job is enabled for a registered event by default, but after the first execution it is disabled. By default, both values (<code>AdminTime</code> and <code>UserTime</code>) do not exist for a configured event. A ''Jobs.xcu'' fragment, as part of the extension, must also not contain the <code>AdminTime</code> and <code>UserTime</code> entries. Because both values are not there, no check can be made and the job is enabled. A job can be deactivated by the global job executor once it has finished its work successfully (depending on the <code>Deactivate</code> return value). In that case, the <code>UserTime</code> entry is generated and set to the current time. An administrator can set a newer and valid <code>AdminTime</code> value in order to reactivate the job again, or the user can remove his <code>UserTime</code> entry manually from the configuration file of the user installation.
+
Using this time stamp feature can sometimes be complicated. For example, assume that there is a job that was installed using the Extension Manager. The job is enabled for a registered event by default, but after the first execution it is disabled. By default, both values (<code>AdminTime</code> and <code>UserTime</code>) do not exist for a configured event. A ''Jobs.xcu'' fragment, as part of the extension, must also not contain the <code>AdminTime</code> and <code>UserTime</code> entries. Because both values are not there, no check can be made and the job is enabled. A job can be deactivated by the global job executor once it has finished its work successfully (depending on the <code>Deactivate</code> return value). In that case, the <code>UserTime</code> entry is generated and set to the current time. An administrator can set a newer and valid <code>AdminTime</code> value in order to reactivate the job again, or the user can remove his <code>UserTime</code> entry manually from the configuration file of the user installation.  
  
The following ''Jobs.xcu'' file shows an example job configuration:
+
The following ''Jobs.xcu'' file shows an example job configuration:  
  
 
   <source lang="xml"><?xml version="1.0" encoding="UTF-8"?>
 
   <source lang="xml"><?xml version="1.0" encoding="UTF-8"?>
 
   <!DOCTYPE oor:component-data SYSTEM "../../../../component-update.dtd">
 
   <!DOCTYPE oor:component-data SYSTEM "../../../../component-update.dtd">
   <oor:component-data oor:name="Jobs" oor:package="org.openoffice.Office" xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+
   <oor:component-data oor:name="Jobs"  
 +
                      oor:package="org.openoffice.Office"  
 +
                      xmlns:oor="http://openoffice.org/2001/registry"  
 +
                      xmlns:xs="http://www.w3.org/2001/XMLSchema"  
 +
                      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 
       <node oor:name="Jobs">
 
       <node oor:name="Jobs">
 
           <node oor:name="SyncJob" oor:op="replace">
 
           <node oor:name="SyncJob" oor:op="replace">
Line 107: Line 116:
 
   </oor:component-data></source>
 
   </oor:component-data></source>
  
This example job has the following characteristics:
+
This example job has the following characteristics:  
  
* Its alias name is "<code>SyncJob</code>"  
+
*Its alias name is "<code>SyncJob</code>"  
* The UNO implementation name of the component is <code>com.sun.star.comp.framework.java.services.SyncJob</code>.
+
*The UNO implementation name of the component is <code>com.sun.star.comp.framework.java.services.SyncJob</code>.  
* The job has its own set of configuration data with one item. It is a string, its name is <code>arg_1</code> and its value is "<code>val_1</code>".
+
*The job has its own set of configuration data with one item. It is a string, its name is <code>arg_1</code> and its value is "<code>val_1</code>".  
* The job is bound to the global event <code>onFirstVisibleTask</code>, which is triggered when the first document window of a new {{PRODUCTNAME}} instance is displayed. The next execution of this job is guaranteed, because there are no time stamp values present.
+
*The job is bound to the global event <code>onFirstVisibleTask</code>, which is triggered when the first document window of a new {{PRODUCTNAME}} instance is displayed. The next execution of this job is guaranteed, because there are no time stamp values present.
  
When specifying the event to which the job is bound (<code>onFirstVisibleTask</code> in the above example), it is important to use <code>oor:op="fuse"</code>, so that multiple ''Jobs.xcu'' particles merge losslessly. but note that <code>oor:op="fuse"</code> is only available since OpenOffice.org 2.0.3, and that a ''Jobs.xcu'' file that uses it cannot be used with older versions of OpenOffice.org. With older versions of OpenOffice.org, it was common to use <code>oor:op="replace"</code> instead of <code>oor:op="fuse"</code>, which potentially caused event bindings to get lost when multiple ''Jobs.xcu'' particles were merged.
+
When specifying the event to which the job is bound (<code>onFirstVisibleTask</code> in the above example), it is important to use <code>oor:op="fuse"</code>, so that multiple ''Jobs.xcu'' particles merge losslessly. but note that <code>oor:op="fuse"</code> is only available since OpenOffice.org 2.0.3, and that a ''Jobs.xcu'' file that uses it cannot be used with older versions of OpenOffice.org. With older versions of OpenOffice.org, it was common to use <code>oor:op="replace"</code> instead of <code>oor:op="fuse"</code>, which potentially caused event bindings to get lost when multiple ''Jobs.xcu'' particles were merged.  
  
{{Documentation/Caution|A job is not executed when it has deactivated itself and is called afterwards by a <tt><nowiki>vnd.sun.star.jobs:event=...</nowiki></tt> command URL. This can be confusing to users, especially with add-ons, since it would seem that the customized UI items do not function.}}
+
{{Warn|A job is not executed when it has deactivated itself and is called afterwards by a <tt><nowiki>vnd.sun.star.jobs:event=...</nowiki></tt> command URL. This can be confusing to users, especially with add-ons, since it would seem that the customized UI items do not function.}}  
  
{{PDL1}}
+
{{PDL1}}  
  
[[Category:Documentation/Developer's Guide/Writing UNO Components]]
+
[[Category:Documentation/Developer's_Guide/Writing_UNO_Components]]

Revision as of 08:00, 12 July 2018



Although jobs that are called through a vnd.sun.star.jobs: URL by their implementation name do not require it, a job usually has configuration data. The configuration package org.openoffice.Office.Jobs contains all necessary information:

<?xml version="1.0" encoding="UTF-8"?>
  <!DOCTYPE oor:component-schema SYSTEM "../../../../component-schema.dtd">
  <oor:component-schema xmlns:oor="http://openoffice.org/2001/registry" 
                        xmlns:xs="http://www.w3.org/2001/XMLSchema" 
                        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
                        oor:name="Jobs" 
                        oor:package="org.openoffice.Office" 
                        xml:lang="en-US">
      <templates>
          <group oor:name="Job">
              <prop oor:name="Service" oor:type="xs:string"/>
              <group oor:name="Arguments" oor:extensible="true"/>
          </group>
          <group oor:name="TimeStamp">
              <prop oor:name="AdminTime" oor:type="xs:string"/>
              <prop oor:name="UserTime" oor:type="xs:string"/>
          </group>
          <group oor:name="Event">
              <set oor:name="JobList" oor:node-type="TimeStamp"/>
          </group>
      </templates>
      <component>
          <set oor:name="Jobs" oor:node-type="Job"/>
          <set oor:name="Events" oor:node-type="Event"/>
      </component>
  </oor:component-schema>

The Job template contains all properties that describe a job component. Instances of this template are located inside the configuration set Jobs.

Properties of the Job template
Alias string. This property is declared as the name of the corresponding set node inside the configuration set Jobs. It must be a unique name, which represents the structured information of a job. In the example .xcu file below its value is "SyncJob". In the job execution arguments this property is passed as Config - Alias
Service string. Represents the UNO implementation name of the job component. In the job execution arguments this property is passed as Config - Service
Arguments set of any entries. This list can be filled with any values and represents the private set of configuration data for this job. In the job execution arguments this property is passed as JobConfig

The job property Alias was created to provide you with more flexibility for a developing components. You can use the same UNO implementation, but register it with different Aliases. At runtime the job instance will be initialized with its own configuration data and can detect which representation is used.

Documentation caution.png You cannot use the generic UNO service names com.sun.star.task.Job or com.sun.star.task.AsyncJob for the Service job property, because the job executor cannot identify the correct job implementation. To avoid ambiguities, it is necessary to use the UNO implementation name of the component.

Every job instance can be bound to multiple events. An event indicates a special office state, which can be detected at runtime (for example, OnFirstVisibleTask ), and which can be triggered by a call to the job executor when the first document window is displayed.

Properties of the Event template
EventName string. This property is declared as the name of the corresponding set node inside the configuration set Events. It must be a unique name, which describes a functional state. In the example .xcu file below its value is "onFirstVisibleTask".

Section List of Supported Events summarizes the events currently triggered by the office. In addition, developers can use arbitrary event strings with the vnd.sun.star.jobs: URL or in calls to trigger() at the com.sun.star.task.JobExecutor service.

JobList set of TimeStamp entries. This set contains a list of all Alias names of jobs that are bound to this event. Every job registration can be combined with time stamp values. Please refer to the description of the template TimeStamp below for details

As an optional feature, every job registration that is bound to an event can be enabled or disabled by two time stamp values. In a shared installation of OpenOffice.org, an administrator can use the AdminTime value to reactivate jobs for every newly started user office instance; regardless of earlier executions of these jobs. That can be useful, for example, for updating user installations if new functions have been added to the shared installation.

Properties of the TimeStamp template
AdminTime string. This value must be formatted according to the ISO 8601. It contains the time stamp, which can only be adjusted by an administrator, to reactivate this job.
UserTime string. This value must be formatted according to the ISO 8601. It contains the time, when this job was finished successfully last time upon the configured event.

Using this time stamp feature can sometimes be complicated. For example, assume that there is a job that was installed using the Extension Manager. The job is enabled for a registered event by default, but after the first execution it is disabled. By default, both values (AdminTime and UserTime) do not exist for a configured event. A Jobs.xcu fragment, as part of the extension, must also not contain the AdminTime and UserTime entries. Because both values are not there, no check can be made and the job is enabled. A job can be deactivated by the global job executor once it has finished its work successfully (depending on the Deactivate return value). In that case, the UserTime entry is generated and set to the current time. An administrator can set a newer and valid AdminTime value in order to reactivate the job again, or the user can remove his UserTime entry manually from the configuration file of the user installation.

The following Jobs.xcu file shows an example job configuration:

<?xml version="1.0" encoding="UTF-8"?>
  <!DOCTYPE oor:component-data SYSTEM "../../../../component-update.dtd">
  <oor:component-data oor:name="Jobs" 
                      oor:package="org.openoffice.Office" 
                      xmlns:oor="http://openoffice.org/2001/registry" 
                      xmlns:xs="http://www.w3.org/2001/XMLSchema" 
                      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <node oor:name="Jobs">
          <node oor:name="SyncJob" oor:op="replace">
              <prop oor:name="Service">
                  <value>com.sun.star.comp.framework.java.services.SyncJob</value>
              </prop>
              <node oor:name="Arguments">
                  <prop oor:name="arg_1" oor:type="xs:string" oor:op="replace">
                      <value>val_1</value>
                  </prop>
              </node>
          </node>
      </node>
      <node oor:name="Events">
          <node oor:name="onFirstVisibleTask" oor:op="fuse">
              <node oor:name="JobList">
                  <node oor:name="SyncJob" oor:op="replace"/>
              </node>
          </node>
      </node>
  </oor:component-data>

This example job has the following characteristics:

  • Its alias name is "SyncJob"
  • The UNO implementation name of the component is com.sun.star.comp.framework.java.services.SyncJob.
  • The job has its own set of configuration data with one item. It is a string, its name is arg_1 and its value is "val_1".
  • The job is bound to the global event onFirstVisibleTask, which is triggered when the first document window of a new OpenOffice.org instance is displayed. The next execution of this job is guaranteed, because there are no time stamp values present.

When specifying the event to which the job is bound (onFirstVisibleTask in the above example), it is important to use oor:op="fuse", so that multiple Jobs.xcu particles merge losslessly. but note that oor:op="fuse" is only available since OpenOffice.org 2.0.3, and that a Jobs.xcu file that uses it cannot be used with older versions of OpenOffice.org. With older versions of OpenOffice.org, it was common to use oor:op="replace" instead of oor:op="fuse", which potentially caused event bindings to get lost when multiple Jobs.xcu particles were merged.

Documentation caution.png A job is not executed when it has deactivated itself and is called afterwards by a vnd.sun.star.jobs:event=... command URL. This can be confusing to users, especially with add-ons, since it would seem that the customized UI items do not function.
Content on this page is licensed under the Public Documentation License (PDL).
Personal tools
In other languages