View Javadoc
1   /*
2    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
3    * The software in this package is published under the terms of the CPAL v1.0
4    * license, a copy of which has been included with this distribution in the
5    * LICENSE.txt file.
6    */
7   package org.mule.retry;
8   
9   
10  /**
11   * Indicates the current state of a RetryPolicy
12   * <ul>
13   * <li>ok: The policy is active</li>
14   * <li>exhausted: The policy has run through the actions for the policy</li>
15   * </ul>
16   *
17   * For example, a RetryPolicy may have a RetryCount - how many times the policy can be invoked.
18   * Once the retryCount has been reached, the policy is exhausted and cannot be used again.
19   */
20  public class PolicyStatus
21  {
22      private boolean exhausted = false;
23      private boolean ok = false;
24      private Throwable throwable;
25  
26      public static PolicyStatus policyExhausted(Throwable t)
27      {
28          return new PolicyStatus(true, t);
29      }
30  
31      public static PolicyStatus policyOk()
32      {
33          return new PolicyStatus();
34      }
35  
36      protected PolicyStatus()
37      {
38          this.ok = true;
39      }
40  
41      protected PolicyStatus(boolean exhausted, Throwable throwable)
42      {
43          this.exhausted = exhausted;
44          this.throwable = throwable;
45      }
46  
47      public boolean isExhausted()
48      {
49          return exhausted;
50      }
51  
52      public boolean isOk()
53      {
54          return ok;
55      }
56  
57      public Throwable getThrowable()
58      {
59          return throwable;
60      }
61  }