aboutsummaryrefslogtreecommitdiffstats
path: root/container-core/src/main/java/com/yahoo/processing/rendering/AsynchronousRenderer.java
blob: bdca8110309d75b92e9cb0b53957fbe1d0a2f455 (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
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.processing.rendering;

import com.yahoo.jdisc.handler.CompletionHandler;
import com.yahoo.jdisc.handler.ContentChannel;
import com.yahoo.processing.Response;

import java.util.concurrent.Executor;

/**
 * Superclass of all asynchronous renderers.
 * Subclasses this to receive an executor and the network wiring necessary to respectively
 * run callback listeners and close up the channel when the response is complete.
 *
 * @author bratseth
 */
public abstract class AsynchronousRenderer <RESPONSE extends Response> extends Renderer<RESPONSE> {

    /**
     * Exposes JDisc wiring to ensure asynchronous cleanup.
     *
     * @param channel the channel to the client receiving the response
     * @param completionHandler the JDisc completion handler which will be invoked at the end of the rendering
     * @throws IllegalStateException if attempted invoked more than once
     */
    public abstract void setNetworkWiring(ContentChannel channel, CompletionHandler completionHandler);

}