ome.api
Interface JobHandle

All Superinterfaces:
ServiceInterface, StatefulServiceInterface
All Known Implementing Classes:
JobBean

public interface JobHandle
extends StatefulServiceInterface

Allows submission of asynchronous jobs.

NOTE: The calling order for the service is as follows:

  1. submit(Job) or attach(long)
  2. any of the other methods
  3. close()

Calling close() does not cancel or otherwise change the Job state. See cancelJob().

Since:
3.0-Beta2
Author:
Josh Moore, josh at glencoesoftware.com

Field Summary
static String CANCELLED
           
static String ERROR
           
static String FINISHED
           
static String QUEUED
           
static String REQUEUED
           
static String RESUBMITTED
           
static String RUNNING
           
static String SUBMITTED
           
static String WAITING
           
 
Method Summary
 ome.model.jobs.JobStatus attach(long jobId)
           
 void cancelJob()
          Marks a job for cancellation.
 ome.model.jobs.Job getJob()
           
 boolean jobError()
          Returns true if the Job has thrown an error.
 Timestamp jobFinished()
           
 String jobMessage()
           
 boolean jobRunning()
          Returns true if the Job is running, i.e. has an attached Process.
 ome.model.jobs.JobStatus jobStatus()
           
 String setMessage(String message)
          Sets the job's message string, and returns the previous value.
 String setStatus(String status)
          Updates the JobStatus for the current job.
 String setStatusAndMessage(String status, String message)
          Like setStatus(String) but also sets the message.
 long submit(ome.model.jobs.Job job)
          Submits a Job and returns its database id.
 
Methods inherited from interface ome.api.StatefulServiceInterface
activate, close, getCurrentEventContext, passivate
 

Field Detail

SUBMITTED

static final String SUBMITTED
See Also:
Constant Field Values

RESUBMITTED

static final String RESUBMITTED
See Also:
Constant Field Values

QUEUED

static final String QUEUED
See Also:
Constant Field Values

REQUEUED

static final String REQUEUED
See Also:
Constant Field Values

RUNNING

static final String RUNNING
See Also:
Constant Field Values

ERROR

static final String ERROR
See Also:
Constant Field Values

WAITING

static final String WAITING
See Also:
Constant Field Values

FINISHED

static final String FINISHED
See Also:
Constant Field Values

CANCELLED

static final String CANCELLED
See Also:
Constant Field Values
Method Detail

submit

long submit(ome.model.jobs.Job job)
Submits a Job and returns its database id. The only fields directly on status which are editable are message, scheduledFor and status. The latter two must be sensible.

Parameters:
job - Not null
Returns:
id

attach

ome.model.jobs.JobStatus attach(long jobId)
                                throws ome.conditions.ApiUsageException
Returns:
the current JobStatus for the id
Throws:
ome.conditions.ApiUsageException - if the id does not exist.

getJob

ome.model.jobs.Job getJob()
Returns:
the current Job

jobStatus

ome.model.jobs.JobStatus jobStatus()
Returns:
the current JobStatus. Will never return null.

jobFinished

Timestamp jobFinished()
Returns:
null if the Job is not finished, otherwise the Timestamp for when it completed.

jobMessage

String jobMessage()
Returns:
current message for job. May be set during processing.

jobRunning

boolean jobRunning()
Returns true if the Job is running, i.e. has an attached Process.


jobError

boolean jobError()
Returns true if the Job has thrown an error.


cancelJob

void cancelJob()
Marks a job for cancellation. Not every processor will check for the cancelled flag for a running job, but no non-running job will start if it has been cancelled.


setStatus

String setStatus(String status)
Updates the JobStatus for the current job. The previous status is returned as a string. If the status is CANCELLED, this method is equivalent to cancelJob().


setStatusAndMessage

String setStatusAndMessage(String status,
                           String message)
Like setStatus(String) but also sets the message.


setMessage

String setMessage(String message)
Sets the job's message string, and returns the previous value.

Parameters:
message -
Returns:


OmeroJava Api

Version: 4.3.3-00d1137e-b2894

Copyright © 2009 The University of Dundee. All Rights Reserved.