Confluence Docs 2.10 : Job Plugins
This page last changed on Dec 02, 2008 by smaddox.
Job plugin modules enable you to add repeatable tasks to Confluence, which are in turn scheduled by Trigger Plugins.
Job Plugin ModuleThe 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>
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 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 Dec 03, 2008 15:14 |