View Javadoc

1   /**
2    * Copyright 2005 Steve Molloy
3    * 
4    * This file is part of OV4J.
5    * 
6    * OV4J is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as
7    * published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
8    * 
9    * OV4J is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
10   * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
11   * 
12   * You should have received a copy of the GNU General Public License along with OV4J; if not, write to the Free Software
13   * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
14   * 
15   */
16  package org.ov4j.retry;
17  
18  /**
19   * Interface to implement to be able to have methods retried.
20   * 
21   * @author smolloy
22   * 
23   */
24  public interface IRetryable {
25  	/** Stop retrying the call. */
26  	public static final int	STOP_TRYING		= 0;
27  
28  	/** Keep retrying the call. */
29  	public static final int	KEEP_TRYING		= 1;
30  
31  	/** Stop retrying the call for now, but retry next time the VM is started. */
32  	public static final int	TRY_NEXT_RUN	= 2;
33  
34  	/**
35  	 * The maximum number of retries has been reached.
36  	 * 
37  	 * @param result
38  	 *            Information about the call.
39  	 * @return One of STOP_TRYING, KEEP_TRYING or TRY_NEXT_RUN.
40  	 */
41  	public int maxRetriesReached(RetryableCallResult result);
42  
43  	/**
44  	 * The call is done.
45  	 * 
46  	 * @param result
47  	 *            Result of the call.
48  	 */
49  	public void retryCallback(RetryableCallResult result);
50  }