View Javadoc

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