Database Reference
In-Depth Information
To deploy the
StatsSystemTask
to eXist, you need to create the collection
/db/stats
(the permissions are not important, as each system task will be executed as the
SYS
TEM
user), stop eXist, and copy all of the files from
scheduler-java-job/stats-system-
task-example/target/stats-system-task-example-1.0-assembly
to
$EXIST_HOME/lib/
user
. You can then schedule the
StatsSystemTask
class to run hourly in
$EXIST_HOME/conf.xml
by adding the following job definition to the scheduler con‐
figuration before restarting eXist:
<job
type=
"system"
class=
"exist.book.example.scheduler.system.StatsSystemTask"
name=
"hourly-stats"
cron-trigger=
"0 0 0/1 * * ?"
>
<parameter
name=
"stats-collection"
value=
"/db/stats"
/>
</job>
As an alternative to adding the
StatsSystemTask
to eXist's configuration file, while
you cannot schedule immediately using the XQuery
scheduler
extension module,
you can instead trigger the system task for almost immediate execution by using the
system:trigger-system-task
function from the XQuery
system
extension module
(see
system
):
system:trigger-system-task
(
"exist.book.example.scheduler.system.StatsSystemTask"
,
<parameters>
<param
name
=
"
stats-collection
"
value
=
"
/db/stats
"
/>
</parameters>
)
While you cannot directly schedule a system task for execution
from XQuery, a possible workaround is to create a stub XQuery in
the database that simply calls
system:trigger-task
, and then
schedule
the
execution
of
that
XQuery
using
either
scheduler:schedule-xquery-cron-job
or
schedule-xquery-
periodic-job
.
Startup Triggers
Startup triggers are a very simple mechanism that enable you to implement a Java
class that has
exclusive
access to the database during the database's startup process. A
startup trigger is executed as the final phase, after the database server has initialized
but before it is made available for general use.
You may be wondering what you would use a startup trigger for. Typically, they are
used for performing computed configuration or adjustments to the database when it
is started. To illustrate their use, let's briefly look at the three startup triggers that
eXist provides for use during normal database startup:
Search WWH ::
Custom Search