1 /* 2 * $Id: RetryContext.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.api.retry; 12 13 import org.mule.api.MuleContext; 14 import org.mule.api.MuleMessage; 15 16 import java.util.Map; 17 18 /** 19 * The RetryContext is used to store any data which carries over from 20 * attempt to attempt such as response messages. 21 */ 22 public interface RetryContext 23 { 24 String FAILED_RECEIVER = "failedReceiver"; 25 String FAILED_DISPATCHER = "failedDispatcher"; 26 String FAILED_REQUESTER = "failedRequester"; 27 28 /** 29 * @return a read-only meta-info map or an empty map, never null. 30 */ 31 Map<Object, Object> getMetaInfo(); 32 33 MuleMessage[] getReturnMessages(); 34 35 MuleMessage getFirstReturnMessage(); 36 37 void setReturnMessages(MuleMessage[] returnMessages); 38 39 void addReturnMessage(MuleMessage result); 40 41 String getDescription(); 42 43 MuleContext getMuleContext(); 44 45 /** 46 * The most recent failure which prevented the context from validating the connection. Note that the method may 47 * return null. Instead, the {@link #isOk()} should be consulted first. 48 * 49 * @return last failure or null 50 */ 51 Throwable getLastFailure(); 52 53 /** 54 * Typically called by validation logic to mark no problems with the current connection. Additionally, 55 * clears any previous failure set. 56 */ 57 void setOk(); 58 59 /** 60 * Typically called by validation logic to mark a problem and an optional root cause. 61 * 62 * @param lastFailure the most recent failure, can be null 63 */ 64 void setFailed(Throwable lastFailure); 65 66 /** 67 * Note that it's possible for an implementation to return false and have no failure specified, thus 68 * the subsequent {@link #getLastFailure()} may return null. 69 * 70 * @return true if no problems detected before 71 */ 72 boolean isOk(); 73 }