Skip to content

Commit

Permalink
Reformat the code, add missing Javadocs. *NO* functional changes
Browse files Browse the repository at this point in the history
  • Loading branch information
jfarcand committed Jun 30, 2011
1 parent c5a7ea5 commit 49c29c4
Show file tree
Hide file tree
Showing 91 changed files with 1,090 additions and 913 deletions.
11 changes: 6 additions & 5 deletions src/main/java/com/ning/http/client/AsyncCompletionHandler.java
Expand Up @@ -23,8 +23,8 @@
* An {@link AsyncHandler} augmented with an {@link #onCompleted(Response)} convenience method which gets called
* when the {@link Response} processing is finished. This class also implement the {@link ProgressAsyncHandler} callback,
* all doing nothing except returning {@link com.ning.http.client.AsyncHandler.STATE#CONTINUE}
*
* @param <T> Type of the value that will be returned by the associated {@link java.util.concurrent.Future}
*
* @param <T> Type of the value that will be returned by the associated {@link java.util.concurrent.Future}
*/
public abstract class AsyncCompletionHandler<T> implements AsyncHandler<T>, ProgressAsyncHandler<T> {

Expand Down Expand Up @@ -73,7 +73,7 @@ public void onThrowable(Throwable t) {
/**
* Invoked once the HTTP response processing is finished.
* <p/>
*
* <p/>
* Gets always invoked as last callback method.
*
* @param response The {@link Response}
Expand Down Expand Up @@ -104,9 +104,10 @@ public STATE onContentWriteCompleted() {

/**
* Invoked when the I/O operation associated with the {@link Request} body as been progressed.
* @param amount The amount of bytes to transfer.
*
* @param amount The amount of bytes to transfer.
* @param current The amount of bytes transferred
* @param total The total number of bytes transferred
* @param total The total number of bytes transferred
* @return a {@link com.ning.http.client.AsyncHandler.STATE} telling to CONTINUE or ABORT the current processing.
*/
public STATE onContentWriteProgress(long amount, long current, long total) {
Expand Down
Expand Up @@ -20,16 +20,22 @@
import org.slf4j.LoggerFactory;

/**
* Simple {@link AsyncHandler} of type {@link Response}
* Simple {@link AsyncHandler} of type {@link Response}
*/
public class AsyncCompletionHandlerBase extends AsyncCompletionHandler<Response>{
public class AsyncCompletionHandlerBase extends AsyncCompletionHandler<Response> {
private final Logger log = LoggerFactory.getLogger(AsyncCompletionHandlerBase.class);

/**
* {@inheritDoc}
*/
@Override
public Response onCompleted(Response response) throws Exception {
return response;
}

/**
* {@inheritDoc}
*/
/* @Override */
public void onThrowable(Throwable t) {
log.debug(t.getMessage(), t);
Expand Down
17 changes: 10 additions & 7 deletions src/main/java/com/ning/http/client/AsyncHandler.java
Expand Up @@ -25,11 +25,11 @@
* <li>{@link #onBodyPartReceived(HttpResponseBodyPart)}, which could be invoked multiple times,</li>
* <li>{@link #onCompleted()}, once the response has been fully read.</li>
* </ol>
*
* <p/>
* Returning a {@link AsyncHandler.STATE#ABORT} from any of those callback methods will interrupt asynchronous response
* processing, after that only {@link #onCompleted()} is going to be called.
* <p/>
*
* <p/>
* AsyncHandler aren't thread safe, hence you should avoid re-using the same instance when doing concurrent requests.
* As an exmaple, the following may produce unexpected results:
* <blockquote><pre>
Expand All @@ -55,7 +55,7 @@ public static enum STATE {
*/
CONTINUE
}

/**
* Invoked when an unexpected exception occurs during the processing of the response. The exception may have been
* produced by implementation of onXXXReceived method invokation.
Expand All @@ -66,33 +66,36 @@ public static enum STATE {

/**
* Invoked as soon as some response body part are received. Could be invoked many times.
*
* @param bodyPart response's body part.
* @throws Exception if something wrong happens
* @return a {@link STATE} telling to CONTINUE or ABORT the current processing.
* @throws Exception if something wrong happens
*/
STATE onBodyPartReceived(HttpResponseBodyPart bodyPart) throws Exception;

/**
* Invoked as soon as the HTTP status line has been received
*
* @param responseStatus the status code and test of the response
* @throws Exception if something wrong happens
* @return a {@link STATE} telling to CONTINUE or ABORT the current processing.
* @throws Exception if something wrong happens
*/
STATE onStatusReceived(HttpResponseStatus responseStatus) throws Exception;

/**
* Invoked as soon as the HTTP headers has been received. Can potentially be invoked morethan once if a broken server
* sent trailling headers.
*
* @param headers the HTTP headers.
* @throws Exception if something wrong happens
* @return a {@link STATE} telling to CONTINUE or ABORT the current processing.
* @throws Exception if something wrong happens
*/
STATE onHeadersReceived(HttpResponseHeaders headers) throws Exception;

/**
* Invoked once the HTTP response processing is finished.
* <p/>
*
* <p/>
* Gets always invoked as last callback method.
*
* @return T Value that will be returned by the associated {@link java.util.concurrent.Future}
Expand Down

0 comments on commit 49c29c4

Please sign in to comment.