blob: 851cf60737b1ccd05f105284bd1136b3cb6ac43d (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.container.jdisc;
import java.io.IOException;
import java.io.OutputStream;
import com.yahoo.jdisc.Response;
import com.yahoo.jdisc.handler.CompletionHandler;
import com.yahoo.jdisc.handler.ContentChannel;
/**
* HTTP response which supports async response rendering.
*
* @author bratseth
* @author <a href="mailto:steinar@yahoo-inc.com">Steinar Knutsen</a>
*/
public abstract class AsyncHttpResponse extends HttpResponse {
/**
* Create a new HTTP response with support for async output.
*
* @param status the HTTP status code for jdisc
* @see Response
*/
public AsyncHttpResponse(int status) {
super(status);
}
/**
* Render to output asynchronously. The output stream will not be closed
* when this return. The implementation is responsible for closing the
* output (using the provided channel and completion handler) when (async)
* rendering is completed.
*
* @param output
* the stream to which content should be rendered
* @param networkChannel
* the channel which must be closed on completion
* @param handler
* the completion handler to submit when closing the channel, may
* be null
*/
public abstract void render(OutputStream output, ContentChannel networkChannel, CompletionHandler handler)
throws IOException;
/**
* Throws UnsupportedOperationException. Use
* {@link #render(OutputStream, ContentChannel, CompletionHandler)} instead.
*/
@Override
public final void render(OutputStream output) {
throw new UnsupportedOperationException("Illegal use.");
}
}
|