All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.netty.channel.ChannelOption Maven / Gradle / Ivy

There is a newer version: 5.0.0.Alpha2
Show newest version
/*
 * Copyright 2012 The Netty Project
 *
 * The Netty Project licenses this file to you under the Apache License,
 * version 2.0 (the "License"); you may not use this file except in compliance
 * with the License. You may obtain a copy of the License at:
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations
 * under the License.
 */
package io.netty.channel;

import io.netty.buffer.ByteBufAllocator;
import io.netty.util.UniqueName;
import io.netty.util.internal.PlatformDependent;

import java.net.InetAddress;
import java.net.NetworkInterface;
import java.util.concurrent.ConcurrentMap;

/**
 * A {@link ChannelOption} allows to configure a {@link ChannelConfig} in a type-safe
 * way. Which {@link ChannelOption} is supported depends on the actual implementation
 * of {@link ChannelConfig} and may depend on the nature of the transport it belongs
 * to.
 *
 * @param    the type of the value which is valid for the {@link ChannelOption}
 */
public class ChannelOption extends UniqueName {

    private static final ConcurrentMap names = PlatformDependent.newConcurrentHashMap();

    public static final ChannelOption ALLOCATOR = new ChannelOption("ALLOCATOR");
    public static final ChannelOption CONNECT_TIMEOUT_MILLIS =
            new ChannelOption("CONNECT_TIMEOUT_MILLIS");
    public static final ChannelOption WRITE_SPIN_COUNT =
            new ChannelOption("WRITE_SPIN_COUNT");
    public static final ChannelOption ALLOW_HALF_CLOSURE =
            new ChannelOption("ALLOW_HALF_CLOSURE");
    public static final ChannelOption AUTO_READ =
            new ChannelOption("AUTO_READ");
    public static final ChannelOption DEFAULT_HANDLER_BYTEBUF_TYPE =
            new ChannelOption("DEFAULT_HANDLER_BYTEBUF_TYPE");
    public static final ChannelOption SO_BROADCAST =
            new ChannelOption("SO_BROADCAST");
    public static final ChannelOption SO_KEEPALIVE =
            new ChannelOption("SO_KEEPALIVE");
    public static final ChannelOption SO_SNDBUF =
            new ChannelOption("SO_SNDBUF");
    public static final ChannelOption SO_RCVBUF =
            new ChannelOption("SO_RCVBUF");
    public static final ChannelOption SO_REUSEADDR =
            new ChannelOption("SO_REUSEADDR");
    public static final ChannelOption SO_LINGER =
            new ChannelOption("SO_LINGER");
    public static final ChannelOption SO_BACKLOG =
            new ChannelOption("SO_BACKLOG");
    public static final ChannelOption SO_TIMEOUT =
            new ChannelOption("SO_TIMEOUT");

    public static final ChannelOption IP_TOS =
            new ChannelOption("IP_TOS");
    public static final ChannelOption IP_MULTICAST_ADDR =
            new ChannelOption("IP_MULTICAST_ADDR");
    public static final ChannelOption IP_MULTICAST_IF =
            new ChannelOption("IP_MULTICAST_IF");
    public static final ChannelOption IP_MULTICAST_TTL =
            new ChannelOption("IP_MULTICAST_TTL");
    public static final ChannelOption IP_MULTICAST_LOOP_DISABLED =
            new ChannelOption("IP_MULTICAST_LOOP_DISABLED");

    public static final ChannelOption UDP_RECEIVE_PACKET_SIZE =
            new ChannelOption("UDP_RECEIVE_PACKET_SIZE");

    public static final ChannelOption TCP_NODELAY =
            new ChannelOption("TCP_NODELAY");

    public static final ChannelOption AIO_READ_TIMEOUT =
            new ChannelOption("AIO_READ_TIMEOUT");
    public static final ChannelOption AIO_WRITE_TIMEOUT =
            new ChannelOption("AIO_WRITE_TIMEOUT");

    /**
     * Create a new {@link ChannelOption} with the given name. The name needs to be
     * unique.
     */
    protected ChannelOption(String name) {
        super(names, name);
    }

    /**
     * Validate the value which is set for the {@link ChannelOption}. Sub-classes
     * may override this for special checks.
     */
    public void validate(T value) {
        if (value == null) {
            throw new NullPointerException("value");
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy