View Javadoc

1   //
2   //  ========================================================================
3   //  Copyright (c) 1995-2016 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      /**
43       * @return whether this stream is local or remote
44       */
45      public boolean isLocal();
46  
47      @Override
48      public ISession getSession();
49  
50      /**
51       * @return the {@link org.eclipse.jetty.http2.api.Stream.Listener} associated with this stream
52       * @see #setListener(Listener)
53       */
54      public Listener getListener();
55  
56      /**
57       * @param listener the {@link org.eclipse.jetty.http2.api.Stream.Listener} associated with this stream
58       * @see #getListener()
59       */
60      public void setListener(Listener listener);
61  
62      /**
63       * <p>Processes the given {@code frame}, belonging to this stream.</p>
64       *
65       * @param frame the frame to process
66       * @param callback the callback to complete when frame has been processed
67       */
68      public void process(Frame frame, Callback callback);
69  
70      /**
71       * <p>Updates the close state of this stream.</p>
72       *
73       * @param update whether to update the close state
74       * @param local  whether the update comes from a local operation
75       *               (such as sending a frame that ends the stream)
76       *               or a remote operation (such as receiving a frame
77       * @return whether the stream has been fully closed by this invocation
78       */
79      public boolean updateClose(boolean update, boolean local);
80  
81      /**
82       * <p>Forcibly closes this stream.</p>
83       */
84      @Override
85      public void close();
86  
87      /**
88       * <p>Updates the stream send window by the given {@code delta}.</p>
89       *
90       * @param delta the delta value (positive or negative) to add to the stream send window
91       * @return the previous value of the stream send window
92       */
93      public int updateSendWindow(int delta);
94  
95      /**
96       * <p>Updates the stream receive window by the given {@code delta}.</p>
97       *
98       * @param delta the delta value (positive or negative) to add to the stream receive window
99       * @return the previous value of the stream receive window
100      */
101     public int updateRecvWindow(int delta);
102 }