Confluence Docs 3.0 : Job Plugins This page last changed on Aug 11, 2009 by rodogu.
| Job plugin modules are available in Confluence 2.2 and later.
Job plugin modules enable you to add repeatable tasks to Confluence, which are in turn scheduled by Trigger Plugins. For more information about plugins in general, read Confluence Plugin Guide. To learn how to install and configure plugins (including macros), read Installing and Configuring Plugins Manually. For an introduction to writing your own plugins, read Writing Confluence Plugins ## Job Plugin Module The Job plugin module adds a simple reusable component within a plugin. At a minimum, the module class must implement Quartz's Job interface, but for access to Confluence's objects and database you should extend com.atlassian.quartz.jobs.AbstractJob. Jobs are scheduled with Trigger Plugins. Note that at the moment Jobs are not autowired by Spring. Here is an example `atlassian-plugin.xml` fragment containing a single Job module:
    <atlassian-plugin name="Sample Component" key="confluence.extra.component">
        ...
        <job key="myJob"
              name="My Job"
              class="com.example.myplugin.jobs.MyJob" />
        ...
    </atlassian-plugin>
the name attribute represents how this component will be referred to in the Confluence interface. the key attribute represents the internal, system name for your Job. This is what the Trigger will refer to. the class attribute represents the class of the Job to be created. The class must have a no-argument constructor, or it will not be able to be instantiated by Confluence. For examples of how to schedule Jobs to be run, see Trigger Plugins. Note that in Confluence 2.3 you can also use a Spring Plugin as a job. This allows you to inject other Spring components into the Job, via the "jobDataAsMap" property of the job. An example is shown below. You cannot do this in Confluence 2.2.
| Spring Job definition only supported with bundled plugins Plugins containing Spring JobDetailBeans can't be dynamcally loaded at present, due to classloading issues.
    <spring name="Space Cleaner Job" key="spaceCleanerJob" id="spaceCleanerJob" class="org.springframework.scheduling.quartz.JobDetailBean">
            <property name="name">
                <value>Space Cleaner Job</value>
            </property>
            <property name="jobClass">
                <value>com.atlassian.confluence.extras.spacecleaner.SpaceCleanerJob</value>
            </property>
            <property name="jobDataAsMap">
                <map>
                    <entry key="spaceManager"> <!-- these spring beans will be injected into the SpaceCleanerJob instance -->
                        <ref bean="spaceManager"/>
                    </entry>
                    <entry key="pageManager">
                        <ref bean="pageManager"/>
                    </entry>
                    <entry key="settingsManager">
                        <ref bean="settingsManager"/>
                    </entry>
                    <entry key="trashManager">
                        <ref bean="trashManager"/>
                    </entry>
                    <entry key="runOncePerCluster">
                         <value>true</value>
                     </entry>
                </map>
            </property>
        </spring>
        <trigger key="com.atlassian.confluence.extras.spacecleaner.SpaceCleanerJob.trigger" name="Space Cleaner Trigger">
            <job key="spaceCleanerJob" />
            <schedule cron-expression="0 * * * * ?" />
        </trigger>

Document generated by Confluence on Nov 05, 2009 23:34