Skip to content

Commit

Permalink
add javadocs
Browse files Browse the repository at this point in the history
  • Loading branch information
Edvard Fonsell committed Feb 1, 2021
1 parent 9dfda8c commit 0af374d
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,21 @@

import org.slf4j.event.Level;

/**
* Controls how an exception thrown by a state method should be handled by the workflow state processor.
*/
public class ExceptionHandling {
/**
* True when the state method processing should be retried.
*/
public final boolean isRetryable;
/**
* The log entry level for logging the exception.
*/
public final Level logLevel;
/**
* True when the exception stack trace of the exception should be logged. False to log only exception message.
*/
public final boolean logStackTrace;

ExceptionHandling(boolean isRetryable, Level logLevel, boolean logStackTrace) {
Expand All @@ -15,26 +27,55 @@ public class ExceptionHandling {
this.logStackTrace = logStackTrace;
}

/**
* Builder for exception handling settings.
*/
public static class Builder {
private boolean isRetryable = true;
private Level logLevel = ERROR;
private boolean logStackTrace = true;

/**
* Set if state method processing is retryable or not.
*
* @param isRetryable
* True is state method processing should be retried.
* @return This.
*/
public Builder setRetryable(boolean isRetryable) {
this.isRetryable = isRetryable;
return this;
}

/**
* Set the log entry level.
*
* @param logLevel
* The log entry level.
* @return This.
*/
public Builder setLogLevel(Level logLevel) {
this.logLevel = logLevel;
return this;
}

/**
* Set if exception stack trace should be logged or not.
*
* @param logStackTrace
* True to log the exception stack trace, false to log the exception message only.
* @return This.
*/
public Builder setLogStackTrace(boolean logStackTrace) {
this.logStackTrace = logStackTrace;
return this;
}

/**
* Create the exception handling object.
*
* @return Exception handling.
*/
public ExceptionHandling build() {
return new ExceptionHandling(isRetryable, logLevel, logStackTrace);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ public class WorkflowSettings extends ModelObject {
* Default priority for new workflow instances.
*/
public final short defaultPriority;
/**
* Exception analyzer controls how an exception thrown by a state method should be handled.
*/
public final BiFunction<WorkflowState, Throwable, ExceptionHandling> exceptionAnalyzer;

WorkflowSettings(Builder builder) {
Expand Down Expand Up @@ -259,6 +262,13 @@ public Builder setDefaultPriority(short defaultPriority) {
return this;
}

/**
* Set the exception analyzer function.
*
* @param exceptionAnalyzer
* The exception analyzer function.
* @return this.
*/
public Builder setExceptionAnalyzer(BiFunction<WorkflowState, Throwable, ExceptionHandling> exceptionAnalyzer) {
this.exceptionAnalyzer = exceptionAnalyzer;
return this;
Expand Down

0 comments on commit 0af374d

Please sign in to comment.