Adding a Scheduled Task
OpenCms provides a mechanism, similar to cron in UNIX, for running particular tasks at an appointed time. The primary user interface to this tool is in the 'scheduled tasks' section of the administration view. In this section, we will create a new task to convert batches of XML to HTML using the CmsXslTransformer
class we created earlier.
To accomplish our task, we will need to create two classes—one to do the batch transforming and one to implement the com.opencms.core.I_CmsCronJob
interface. Technically, these could be merged into one class, but since we may want to reuse the batch transformation code elsewhere, it is good to keep functionality split.
The BatchTransformer Class
The first class, BatchTransformer
, will be responsible for transforming a directory of files using a single stylesheet, and then writing the resulting files to another directory.
package com.example.genericxml.xslt; import com.opencms.core.CmsException; import com.opencms.core.A_OpenCms; import...