com.atlassian.scheduler
Class JobRunnerResponse

java.lang.Object
  extended by com.atlassian.scheduler.JobRunnerResponse

@PublicApi
@Immutable
public final class JobRunnerResponse
extends Object

An object that represents the result of a call to JobRunner.runJob(JobRunnerRequest). The job runner can use this to customize the reporting of its status; otherwise it can simply return null on success and throw an exception on failure.

Since:
v1.0

Method Summary
static JobRunnerResponse aborted(String message)
          Creates a response that indicates the request was aborted.
 boolean equals(Object o)
           
static JobRunnerResponse failed(String message)
          Creates a response that indicates the request has failed.
static JobRunnerResponse failed(Throwable cause)
          Creates a response that indicates the request has failed.
 String getMessage()
           
 RunOutcome getRunOutcome()
           
 int hashCode()
           
static JobRunnerResponse success()
          Creates a successful response with no additional message.
static JobRunnerResponse success(String message)
          Creates a successful response with the specified message.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

success

public static JobRunnerResponse success()
Creates a successful response with no additional message.

Returns:
the response

success

public static JobRunnerResponse success(String message)
Creates a successful response with the specified message.

Parameters:
message - the message to return, which is optional and will be truncated to RunDetails.MAXIMUM_MESSAGE_LENGTH if necessary
Returns:
the response

aborted

public static JobRunnerResponse aborted(@Nonnull
                                        String message)
Creates a response that indicates the request was aborted. In most cases, it will make more sense to report the job as either having succeeded with nothing to do or failed, instead.

Parameters:
message - the message to return, which will be truncated to RunDetails.MAXIMUM_MESSAGE_LENGTH if necessary. The message is required when reporting that the job was aborted.
Returns:
the response

failed

public static JobRunnerResponse failed(@Nonnull
                                       String message)
Creates a response that indicates the request has failed.

Parameters:
message - the message to return, which will be truncated to RunDetails.MAXIMUM_MESSAGE_LENGTH if necessary. The message is required when reporting that the job has failed.
Returns:
the response

failed

public static JobRunnerResponse failed(@Nonnull
                                       Throwable cause)
Creates a response that indicates the request has failed. The message is set to to an abbreviated representation of the exception and its causes, but the RunDetails.MAXIMUM_MESSAGE_LENGTH still applies, so this information may be incomplete. When possible, the JobRunner is encouraged to trap its exceptions and report more specific diagnostic messages with failed(String), instead.

Parameters:
cause - the exception that caused this failure
Returns:
the response

getRunOutcome

@Nonnull
public RunOutcome getRunOutcome()

getMessage

@Nullable
public String getMessage()

equals

public boolean equals(Object o)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2014 Atlassian. All Rights Reserved.