This server will be upgraded at 3pm Sydney time on December 3rd (December 2nd, 8pm PST) and will be down for up to 30 minutes.
This documentation relates to an early version of Confluence.
View this page in the current documentation or visit the current documentation home.

Job Plugins

All Versions
Click for all versions
Confluence 2.0 to 2.5 Documentation

Index

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.

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.

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>
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.