Studio Developer Manual / Version 2401
Table Of ContentsA remote job is executed within the Studio backend and can be triggered and monitored by the Studio client. The client can pass parameters to the job and will receive the progress of the job's execution and the result, once the job is finished.
Caution
You should use this framework for any backend calls that need some time to deliver their result, in order to prevent timeouts for your request.
Defining a Remote Job in the Studio Backend
In order to define a remote job you need to implement the interface com.coremedia.rest.cap.jobs.JobFactory
. The implementation
has to be defined as a bean within the studio-lib
extension.
The method accepts
needs to define for which job type the factory will return a Job
object.
The method createJob
has to return an implementation of com.coremedia.rest.cap.jobs.Job
.
Within the implementation of your Job
class you can perform your execution and return the result within the call
method.
If you want to pass parameters from the Studio client to your job implementation, you need to define those parameters as local variables and define setters for them.
Together with that setter, you need to annotate the variables with @JsonProperty("variableName")
with a variable name that matches the
parameter key, passed to the job from the Studio client.
You may also leave the @JsonProperty
annotation, if your setters are named correctly: variableName => setVariableName
If you want to send the progress of your job to the Studio client, you need to call the method notifyProgress
of the JobContext
Object with a value between 0 and 1. You get the JobContext
instance
within the call
method of your Job
object.
A job can be aborted by the client. You can use the result of the method isAbortRequested
of the JobContext
object as a break condition within your execution in order to react
to the abortion of your job.
Defining a RemoteJob in Studio Client
If you want to execute your remote job, you need to create a job in the Studio client that extends the class RemoteJobBase
.
Your extension has to override the method getJobType
and return the value that has to match the jobType
within the
accepts
method in your JobFactory
in the Studio backend.
In addition, you can override the method getParams
. The object you return in this method will be passed as parameters in your job implementation in the Studio backend. Note that the
keys in your parameters object have to match the value that you defined within your backend job via the annotation @JsonProperty("variableName")
.