Home / Class/ OioByteStreamChannel Class — netty Architecture

OioByteStreamChannel Class — netty Architecture

Architecture documentation for the OioByteStreamChannel class in OioByteStreamChannel.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  462ee44c_01dd_0264_afa1_574b02e134cf["OioByteStreamChannel"]
  e1422a5c_a1e7_fa08_bbc2_6ad131bdde19["OioByteStreamChannel.java"]
  462ee44c_01dd_0264_afa1_574b02e134cf -->|defined in| e1422a5c_a1e7_fa08_bbc2_6ad131bdde19
  44541bad_4e5c_a8fa_1a83_eafda67b0997["OioByteStreamChannel()"]
  462ee44c_01dd_0264_afa1_574b02e134cf -->|method| 44541bad_4e5c_a8fa_1a83_eafda67b0997
  683c092c_c011_3ca0_37a3_0152ede1925d["activate()"]
  462ee44c_01dd_0264_afa1_574b02e134cf -->|method| 683c092c_c011_3ca0_37a3_0152ede1925d
  ca541f02_410a_5bbf_a52c_2e7cdbe4a933["isActive()"]
  462ee44c_01dd_0264_afa1_574b02e134cf -->|method| ca541f02_410a_5bbf_a52c_2e7cdbe4a933
  707bdd56_2ea2_7d74_c5af_b688b8d21212["available()"]
  462ee44c_01dd_0264_afa1_574b02e134cf -->|method| 707bdd56_2ea2_7d74_c5af_b688b8d21212
  5459b100_ac86_863c_cbca_3f46245c2103["doReadBytes()"]
  462ee44c_01dd_0264_afa1_574b02e134cf -->|method| 5459b100_ac86_863c_cbca_3f46245c2103
  3b0f7958_5a8e_a06c_cf2d_a4f50e2b6665["doWriteBytes()"]
  462ee44c_01dd_0264_afa1_574b02e134cf -->|method| 3b0f7958_5a8e_a06c_cf2d_a4f50e2b6665
  f68e1584_5098_5009_3d34_29958ec0bd40["doWriteFileRegion()"]
  462ee44c_01dd_0264_afa1_574b02e134cf -->|method| f68e1584_5098_5009_3d34_29958ec0bd40
  b1ebe3ea_ac52_b27e_85c4_00db7034ff08["checkEOF()"]
  462ee44c_01dd_0264_afa1_574b02e134cf -->|method| b1ebe3ea_ac52_b27e_85c4_00db7034ff08
  3ab3bf6b_8e91_da80_3674_a2c21f6203d5["doClose()"]
  462ee44c_01dd_0264_afa1_574b02e134cf -->|method| 3ab3bf6b_8e91_da80_3674_a2c21f6203d5

Relationship Graph

Source Code

transport/src/main/java/io/netty/channel/oio/OioByteStreamChannel.java lines 38–172

@Deprecated
public abstract class OioByteStreamChannel extends AbstractOioByteChannel {

    private static final InputStream CLOSED_IN = new InputStream() {
        @Override
        public int read() {
            return -1;
        }
    };

    private static final OutputStream CLOSED_OUT = new OutputStream() {
        @Override
        public void write(int b) throws IOException {
            throw new ClosedChannelException();
        }
    };

    private InputStream is;
    private OutputStream os;
    private WritableByteChannel outChannel;

    /**
     * Create a new instance
     *
     * @param parent    the parent {@link Channel} which was used to create this instance. This can be null if the
     *                  {@link} has no parent as it was created by your self.
     */
    protected OioByteStreamChannel(Channel parent) {
        super(parent);
    }

    /**
     * Activate this instance. After this call {@link #isActive()} will return {@code true}.
     */
    protected final void activate(InputStream is, OutputStream os) {
        if (this.is != null) {
            throw new IllegalStateException("input was set already");
        }
        if (this.os != null) {
            throw new IllegalStateException("output was set already");
        }
        this.is = ObjectUtil.checkNotNull(is, "is");
        this.os = ObjectUtil.checkNotNull(os, "os");
        if (readWhenInactive) {
            eventLoop().execute(readTask);
            readWhenInactive = false;
        }
    }

    @Override
    public boolean isActive() {
        InputStream is = this.is;
        if (is == null || is == CLOSED_IN) {
            return false;
        }

        OutputStream os = this.os;
        return !(os == null || os == CLOSED_OUT);
    }

    @Override
    protected int available() {
        try {
            return is.available();
        } catch (IOException ignored) {
            return 0;
        }
    }

    @Override
    protected int doReadBytes(ByteBuf buf) throws Exception {
        final RecvByteBufAllocator.Handle allocHandle = unsafe().recvBufAllocHandle();
        allocHandle.attemptedBytesRead(Math.max(1, Math.min(available(), buf.maxWritableBytes())));
        return buf.writeBytes(is, allocHandle.attemptedBytesRead());
    }

    @Override
    protected void doWriteBytes(ByteBuf buf) throws Exception {
        OutputStream os = this.os;
        if (os == null) {
            throw new NotYetConnectedException();

Frequently Asked Questions

What is the OioByteStreamChannel class?
OioByteStreamChannel is a class in the netty codebase, defined in transport/src/main/java/io/netty/channel/oio/OioByteStreamChannel.java.
Where is OioByteStreamChannel defined?
OioByteStreamChannel is defined in transport/src/main/java/io/netty/channel/oio/OioByteStreamChannel.java at line 38.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free