View Javadoc

1   /**
2    *
3    * Copyright (C) 2011 Cloud Conscious, LLC. <info@cloudconscious.com>
4    *
5    * ====================================================================
6    * Licensed under the Apache License, Version 2.0 (the "License");
7    * you may not use this file except in compliance with the License.
8    * You may obtain a copy of the License at
9    *
10   * http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   * ====================================================================
18   */
19  package org.jclouds.http;
20  
21  /**
22   * Command whose endpoint is an http service.
23   * 
24   * @author Adrian Cole
25   */
26  public interface HttpCommand {
27  
28     /**
29      * increments the current number of redirect attempts for this command.
30      * 
31      * @see #getRedirectCount
32      */
33     int incrementRedirectCount();
34  
35     /**
36      * This displays the current number of redirect attempts for this command.
37      * 
38      * @see org.jclouds.Constants.PROPERTY_MAX_REDIRECTS
39      */
40     int getRedirectCount();
41  
42     /**
43      * Commands need to be replayed, if redirected or on a retryable error. Typically, this implies
44      * the payload carried is not a streaming type.
45      */
46     boolean isReplayable();
47  
48     /**
49      * increment the current failure count.
50      * 
51      * @see #getFailureCount
52      */
53     int incrementFailureCount();
54  
55     /**
56      * This displays the current number of error retries for this command.
57      * 
58      * @see org.jclouds.Constants.PROPERTY_MAX_RETRIES
59      */
60     int getFailureCount();
61  
62     /**
63      * The request associated with this command.
64      */
65     HttpRequest getCurrentRequest();
66  
67     /**
68      * The request associated with this command.
69      */
70     void setCurrentRequest(HttpRequest request);
71  
72     /**
73      * Used to prevent a command from being re-executed, or having its response parsed.
74      */
75     void setException(Exception exception);
76  
77     /**
78      * @see #setException
79      */
80     Exception getException();
81  
82  }