Startseite / Plugin-Entwicklung / Server-Plugins / Auftragsaktionen / Ausführer

Executor

Executor Class

Interface: de.espirit.firstspirit.scheduling.ScheduleTaskExecutor
FirstSpirit Access API: ScheduleTaskExecutor <D extends ScheduleTaskData>

The executor class provides functionality used upon execution of the task. It supports actual execution as well as a validation run which may be used to implement functionality that tests the task configuration without producing any lasting effects. The class implementation of ScheduleTaskExecutor must be parameterized with the type of the custom data object.

Important The method validate(...) is intended for future use.
/**
* This class implements functionality that is used when the task is executed.
*/
public class MyScheduleTaskExecutor implements ScheduleTaskExecutor<MyScheduleTaskData> {

/**
* Execution method. This method logs certain interesting data about the task.
*/
@Override
public void execute(@NotNull final ScheduleTaskControl control,
@Nullable final MyScheduleTaskData myScheduleTaskData,
@NotNull final ScheduleTaskExecutionContext executionContext) {
final int myIndex = control.getIndex();
final String myName = control.getName();
final RunState myState = control.getState();
final boolean finished = control.getFinished();

executionContext.logInfo("---" + myName.toUppercase() + "---" +
"Index: " + String.valueOf(myIndex) + ", " +
"State: " + myState.toString() + ", " +
"Finished: " + String.valueOf(finished) +
(myScheduleTaskData.getText() != null ?
"Custom Text: " + myScheduleTaskData.getText() :
"No Custom Text")
);
}

/*
* Validation method. Since we're only logging data, this method simply inserts an additional
* text "VALIDATION RUN" in the logged output.
*/
@Override
public void validate(@NotNull final ScheduleTaskControl control,
@Nullable final MyScheduleTaskData myScheduleTaskData,
@NotNull final ScheduleTaskExecutionContext executionContext) {
final int myIndex = control.getIndex();
final String myName = control.getName();
final RunState myState = control.getState();
final boolean finished = control.getFinished();

executionContext.logInfo("---" + myName.toUppercase() + "---" +
"VALIDATION RUN - " +
"Index: " + String.valueOf(myIndex) + ", " +
"State: " + myState.toString() + ", " +
"Finished: " + String.valueOf(finished) +
(myScheduleTaskData.getText() != null ?
"Custom Text: " + myScheduleTaskData.getText() :
"No Custom Text")
);
}
}

Control Object

FirstSpirit Access API: ScheduleTaskControl

The control object provides access to run-time information of a task, such as state, finish status, current index in the schedule entry's task set, as well as name and description.

Aspects

The control object may provide aspect objects to indicate availability of task-specific functionality. Aspects for a single task may be obtained by calling the control object's getAspect method with the aspect interface's TYPE constant as a parameter; if the task supports the desired aspect, an object of this aspect type is returned.

  • Interface: de.espirit.firstspirit.scheduling.aspects.Generating
    FirstSpirit Access API: Generating

    This aspect is available on Execute Generation tasks (see Generation). The aspect object provides information about the number of pages generated by the task.

By using the ScheduleTaskControlsAgent (see below), a task executor class may poll the control objects of preceding tasks in the schedule entry. For example, a task implementing deployment functionality may check if a preceding task performed generation (i.e. a preceding task control object provides a Generating aspect object) and perform deployment only if the generation task resulted in at least one generated object.

Execution Context Object

FirstSpirit Access API: ScheduleTaskExecutionContext

This context object provides access to agents via the methods requestSpecialist(SpecialistType<S> type) and requireSpecialist(SpecialistType<S> type). For more information on obtaining agents, see the section "Obtaining Agents" in Accessing FirstSpirit Functionality.

Agents Available Via Execution Context Object

The following agents may be obtained via the execution context object:

  • GenerationAgent
    FirstSpirit Access API: GenerationAgent

    This agent provides functionality to handle generating tasks, such as creating a delta generation and retrieving a list of generated files.
  • JobAgent
    FirstSpirit Access API: JobAgent

    This agent provides run-time information about the schedule entry, such as access to variables and the file system path to the generation job directory. It also provides means to abort processing of the schedule entry and all currently executed tasks.
  • ScheduleTaskControlsAgent
    FirstSpirit Access API: ScheduleTaskControlsAgent

    This agent allows access to control objects of other tasks within the schedule entry.
  • SettingsAgent
    FirstSpirit Access API: SettingsAgent

    This agent allows the management of persistent information within the context of the schedule entry. This includes storing, reading, and discarding named data.

© 2005 - 2024 Crownpeak Technology GmbH | Alle Rechte vorbehalten. | FirstSpirit 2024.12 | Datenschutz