1 //
2 // ========================================================================
3 // Copyright (c) 1995-2015 Mort Bay Consulting Pty. Ltd.
4 // ------------------------------------------------------------------------
5 // All rights reserved. This program and the accompanying materials
6 // are made available under the terms of the Eclipse Public License v1.0
7 // and Apache License v2.0 which accompanies this distribution.
8 //
9 // The Eclipse Public License is available at
10 // http://www.eclipse.org/legal/epl-v10.html
11 //
12 // The Apache License v2.0 is available at
13 // http://www.opensource.org/licenses/apache2.0.php
14 //
15 // You may elect to redistribute this code under either of these licenses.
16 // ========================================================================
17 //
18
19 package org.eclipse.jetty.http2;
20
21 import java.io.Closeable;
22
23 import org.eclipse.jetty.http2.api.Stream;
24 import org.eclipse.jetty.http2.frames.Frame;
25 import org.eclipse.jetty.util.Callback;
26
27 /**
28 * <p>The SPI interface for implementing a HTTP/2 stream.</p>
29 * <p>This class extends {@link Stream} by adding the methods required to
30 * implement the HTTP/2 stream functionalities.</p>
31 */
32 public interface IStream extends Stream, Closeable
33 {
34 /**
35 * <p>The constant used as attribute key to store/retrieve the HTTP
36 * channel associated with this stream</p>
37 *
38 * @see #setAttribute(String, Object)
39 */
40 public static final String CHANNEL_ATTRIBUTE = IStream.class.getName() + ".channel";
41
42 @Override
43 public ISession getSession();
44
45 /**
46 * @return the {@link org.eclipse.jetty.http2.api.Stream.Listener} associated with this stream
47 * @see #setListener(Listener)
48 */
49 public Listener getListener();
50
51 /**
52 * @param listener the {@link org.eclipse.jetty.http2.api.Stream.Listener} associated with this stream
53 * @see #getListener()
54 */
55 public void setListener(Listener listener);
56
57 /**
58 * <p>Processes the given {@code frame}, belonging to this stream.</p>
59 *
60 * @param frame the frame to process
61 * @param callback the callback to complete when frame has been processed
62 */
63 public void process(Frame frame, Callback callback);
64
65 /**
66 * <p>Updates the close state of this stream.</p>
67 *
68 * @param update whether to update the close state
69 * @param local whether the update comes from a local operation
70 * (such as sending a frame that ends the stream)
71 * or a remote operation (such as receiving a frame
72 * @return whether the stream has been fully closed by this invocation
73 */
74 public boolean updateClose(boolean update, boolean local);
75
76 /**
77 * <p>Forcibly closes this stream.</p>
78 */
79 @Override
80 public void close();
81
82 /**
83 * <p>Updates the stream send window by the given {@code delta}.</p>
84 *
85 * @param delta the delta value (positive or negative) to add to the stream send window
86 * @return the previous value of the stream send window
87 */
88 public int updateSendWindow(int delta);
89
90 /**
91 * <p>Updates the stream receive window by the given {@code delta}.</p>
92 *
93 * @param delta the delta value (positive or negative) to add to the stream receive window
94 * @return the previous value of the stream receive window
95 */
96 public int updateRecvWindow(int delta);
97 }