FileDocCategorySizeDatePackage
Http11NioProtocol.javaAPI DocApache Tomcat 6.0.1428809Fri Jul 20 04:20:32 BST 2007org.apache.coyote.http11

Http11NioProtocol

public class Http11NioProtocol extends Object implements org.apache.coyote.ProtocolHandler, MBeanRegistration
Abstract the protocol implementation, including threading, etc. Processor is single threaded and specific to stream-based protocols, will not fit Jk protocols like JNI.
author
Remy Maucherat
author
Costin Manolache
author
Filip Hanik

Fields Summary
protected org.apache.tomcat.util.net.SSLImplementation
sslImplementation
protected static org.apache.tomcat.util.res.StringManager
sm
The string manager for this package.
ObjectName
tpOname
ObjectName
rgOname
protected org.apache.tomcat.util.net.NioEndpoint
ep
protected boolean
secure
protected Hashtable
attributes
private int
maxKeepAliveRequests
private int
timeout
private int
maxSavePostSize
private int
maxHttpHeaderSize
protected int
processorCache
private int
socketCloseDelay
private boolean
disableUploadTimeout
private int
socketBuffer
private org.apache.coyote.Adapter
adapter
private Http11ConnectionHandler
cHandler
private String
compression
Compression value.
private String
noCompressionUserAgents
private String
restrictedUserAgents
private String
compressableMimeTypes
private int
compressionMinSize
private String
server
protected static org.apache.juli.logging.Log
log
protected String
domain
protected ObjectName
oname
protected MBeanServer
mserver
Constructors Summary
public Http11NioProtocol()

    
      
        cHandler = new Http11ConnectionHandler( this );
        setSoLinger(Constants.DEFAULT_CONNECTION_LINGER);
        setSoTimeout(Constants.DEFAULT_CONNECTION_TIMEOUT);
        //setServerSoTimeout(Constants.DEFAULT_SERVER_SOCKET_TIMEOUT);
        setTcpNoDelay(Constants.DEFAULT_TCP_NO_DELAY);
    
Methods Summary
public voiddestroy()

        if(log.isInfoEnabled())
            log.info(sm.getString("http11protocol.stop", getName()));
        ep.destroy();
        if( tpOname!=null )
            Registry.getRegistry(null, null).unregisterComponent(tpOname);
        if( rgOname != null )
            Registry.getRegistry(null, null).unregisterComponent(rgOname);
    
public intgetAcceptorThreadPriority()

      return ep.getAcceptorThreadPriority();
    
public org.apache.coyote.AdaptergetAdapter()

        return adapter;
    
public java.net.InetAddressgetAddress()

        return ep.getAddress();
    
public java.lang.StringgetAlgorithm()

 return ep.getAlgorithm();
public java.lang.ObjectgetAttribute(java.lang.String key)

        if( log.isTraceEnabled())
            log.trace(sm.getString("http11protocol.getattribute", key));
        return attributes.get(key);
    
public java.util.IteratorgetAttributeNames()

        return attributes.keySet().iterator();
    
public intgetBacklog()

        return ep.getBacklog();
    
public java.lang.StringgetCiphers()

 return ep.getCiphers();
public booleangetClientAuth()

 return ep.getClientAuth();
public java.lang.StringgetCompressableMimeType()

        return compressableMimeTypes;
    
public java.lang.StringgetCompression()

        return compression;
    
public intgetCompressionMinSize()

        return compressionMinSize;
    
public booleangetDisableUploadTimeout()

        return disableUploadTimeout;
    
public java.lang.StringgetDomain()

        return domain;
    
public java.util.concurrent.ExecutorgetExecutor()

        return ep.getExecutor();
    
public booleangetKeepAlive()
Return the Keep-Alive policy for the connection.

        return ((maxKeepAliveRequests != 0) && (maxKeepAliveRequests != 1));
    
public java.lang.StringgetKeypass()

 return getKeystorePass();
public java.lang.StringgetKeystore()

 return getKeystoreFile();
public java.lang.StringgetKeystoreFile()

 return ep.getKeystoreFile();
public java.lang.StringgetKeystorePass()

 return ep.getKeystorePass();
public java.lang.StringgetKeystoreType()

 return ep.getKeystoreType();
public intgetMaxHttpHeaderSize()

        return maxHttpHeaderSize;
    
public intgetMaxKeepAliveRequests()

        return maxKeepAliveRequests;
    
public intgetMaxSavePostSize()

        return maxSavePostSize;
    
public intgetMaxThreads()

        return ep.getMaxThreads();
    
public java.lang.StringgetName()

        String encodedAddr = "";
        if (getAddress() != null) {
            encodedAddr = "" + getAddress();
            if (encodedAddr.startsWith("/"))
                encodedAddr = encodedAddr.substring(1);
            encodedAddr = URLEncoder.encode(encodedAddr) + "-";
        }
        return ("http-" + encodedAddr + ep.getPort());
    
public java.lang.StringgetNoCompressionUserAgents()

        return noCompressionUserAgents;
    
public javax.management.ObjectNamegetObjectName()


       
        return oname;
    
public intgetOomParachute()

        return ep.getOomParachute();
    
public intgetPollerThreadCount()

        return ep.getPollerThreadCount();
    
public intgetPollerThreadPriority()

      return ep.getThreadPriority();
    
public intgetPort()

        return ep.getPort();
    
public intgetProcessorCache()

        return processorCache;
    
public java.lang.StringgetProperty(java.lang.String name)
Get a property

        return (String)getAttribute(name);
    
public java.lang.StringgetProtocol()

        return getProperty("protocol");
    
public java.lang.StringgetRestrictedUserAgents()

        return restrictedUserAgents;
    
public booleangetSSLEnabled()

 return ep.isSSLEnabled(); 
public booleangetSecure()

        return secure;
    
public longgetSelectorTimeout()

        return ep.getSelectorTimeout();
    
public java.lang.StringgetServer()

        return server;
    
public intgetSoLinger()

        return ep.getSoLinger();
    
public intgetSoTimeout()

        return ep.getSoTimeout();
    
public intgetSocketBuffer()

        return socketBuffer;
    
public intgetSocketCloseDelay()

        return socketCloseDelay;
    
public java.lang.StringgetSslProtocol()

 return ep.getSslProtocol();
public booleangetTcpNoDelay()

        return ep.getTcpNoDelay();
    
public intgetThreadPriority()

      return ep.getThreadPriority();
    
public intgetTimeout()

        return timeout;
    
public booleangetUseSendfile()

        return ep.getUseSendfile();
    
public voidinit()
Start the protocol

        ep.setName(getName());
        ep.setHandler(cHandler);
        
        //todo, determine if we even need these
        ep.getSocketProperties().setRxBufSize(Math.max(ep.getSocketProperties().getRxBufSize(),getMaxHttpHeaderSize()));
        ep.getSocketProperties().setTxBufSize(Math.max(ep.getSocketProperties().getTxBufSize(),getMaxHttpHeaderSize()));
        
        try {
            ep.init();
            sslImplementation = SSLImplementation.getInstance("org.apache.tomcat.util.net.jsse.JSSEImplementation");
        } catch (Exception ex) {
            log.error(sm.getString("http11protocol.endpoint.initerror"), ex);
            throw ex;
        }
        if(log.isInfoEnabled())
            log.info(sm.getString("http11protocol.init", getName()));

    
public voidpause()

        try {
            ep.pause();
        } catch (Exception ex) {
            log.error(sm.getString("http11protocol.endpoint.pauseerror"), ex);
            throw ex;
        }
        if(log.isInfoEnabled())
            log.info(sm.getString("http11protocol.pause", getName()));
    
public voidpostDeregister()

    
public voidpostRegister(java.lang.Boolean registrationDone)

    
public voidpreDeregister()

    
public javax.management.ObjectNamepreRegister(javax.management.MBeanServer server, javax.management.ObjectName name)

        oname=name;
        mserver=server;
        domain=name.getDomain();
        return name;
    
public voidresume()

        try {
            ep.resume();
        } catch (Exception ex) {
            log.error(sm.getString("http11protocol.endpoint.resumeerror"), ex);
            throw ex;
        }
        if(log.isInfoEnabled())
            log.info(sm.getString("http11protocol.resume", getName()));
    
public voidsetAcceptorThreadPriority(int threadPriority)

      ep.setAcceptorThreadPriority(threadPriority);
      setAttribute("acceptorThreadPriority", "" + threadPriority);
    
public voidsetAdapter(org.apache.coyote.Adapter adapter)
The adapter, used to call the connector

        this.adapter=adapter;
    
public voidsetAddress(java.net.InetAddress ia)

        ep.setAddress( ia );
        setAttribute("address", "" + ia);
    
public voidsetAlgorithm(java.lang.String s)

 ep.setAlgorithm(s);
public voidsetAttribute(java.lang.String name, java.lang.Object value)
Pass config info


            
            
        if( log.isTraceEnabled())
            log.trace(sm.getString("http11protocol.setattribute", name, value));

        attributes.put(name, value);
    
public voidsetBacklog(int i)

        ep.setBacklog(i);
        setAttribute("backlog", "" + i);
    
public voidsetCiphers(java.lang.String s)

 ep.setCiphers(s);
public voidsetClientAuth(boolean b)

 ep.setClientAuth(b);
public voidsetCompressableMimeType(java.lang.String valueS)

        compressableMimeTypes = valueS;
        setAttribute("compressableMimeTypes", valueS);
    
public voidsetCompression(java.lang.String valueS)

        compression = valueS;
        setAttribute("compression", valueS);
    
public voidsetCompressionMinSize(int valueI)

        compressionMinSize = valueI;
        setAttribute("compressionMinSize", "" + valueI);
    
public voidsetDisableUploadTimeout(boolean isDisabled)

        disableUploadTimeout = isDisabled;
    
public voidsetExecutor(java.util.concurrent.Executor executor)

        ep.setExecutor(executor);
    
public voidsetKeepAlive(boolean keepAlive)
Set the keep-alive policy for this connection.

        if (!keepAlive) {
            setMaxKeepAliveRequests(1);
        }
    
public voidsetKeypass(java.lang.String s)

 setKeystorePass(s);
public voidsetKeystore(java.lang.String s)

 setKeystoreFile(s);
public voidsetKeystoreFile(java.lang.String s)

 ep.setKeystoreFile(s);
public voidsetKeystorePass(java.lang.String s)

 ep.setKeystorePass(s);
public voidsetKeystoreType(java.lang.String s)

 ep.setKeystoreType(s);
public voidsetMaxHttpHeaderSize(int valueI)

        maxHttpHeaderSize = valueI;
        setAttribute("maxHttpHeaderSize", "" + valueI);
    
public voidsetMaxKeepAliveRequests(int mkar)
Set the maximum number of Keep-Alive requests that we will honor.

        maxKeepAliveRequests = mkar;
        setAttribute("maxKeepAliveRequests", "" + mkar);
    
public voidsetMaxSavePostSize(int valueI)

        maxSavePostSize = valueI;
        setAttribute("maxSavePostSize", "" + valueI);
    
public voidsetMaxThreads(int maxThreads)

        ep.setMaxThreads(maxThreads);
        setAttribute("maxThreads", "" + maxThreads);
    
public voidsetNoCompressionUserAgents(java.lang.String valueS)

        noCompressionUserAgents = valueS;
        setAttribute("noCompressionUserAgents", valueS);
    
public voidsetOomParachute(int oomParachute)

        ep.setOomParachute(oomParachute);
        setAttribute("oomParachute",oomParachute);
    
public voidsetPollerThreadCount(int count)


    // -------------------- Pool setup --------------------

        
        ep.setPollerThreadCount(count);
    
public voidsetPollerThreadPriority(int threadPriority)

      ep.setPollerThreadPriority(threadPriority);
      setAttribute("pollerThreadPriority", "" + threadPriority);
    
public voidsetPort(int port)

        ep.setPort(port);
        setAttribute("port", "" + port);
    
public voidsetProcessorCache(int processorCache)

        this.processorCache = processorCache;
    
public voidsetProperty(java.lang.String name, java.lang.String value)
Set a property.

        if ( name!=null && (name.startsWith("socket.") ||name.startsWith("selectorPool.")) ){
            ep.setProperty(name, value);
        } else {
            ep.setProperty(name,value); //make sure we at least try to set all properties
        }
        setAttribute(name, value);
    
public voidsetProtocol(java.lang.String k)

        setSecure(true);
        setAttribute("protocol", k);
    
public voidsetRestrictedUserAgents(java.lang.String valueS)

        restrictedUserAgents = valueS;
        setAttribute("restrictedUserAgents", valueS);
    
public voidsetSSLEnabled(boolean SSLEnabled)

 ep.setSSLEnabled(SSLEnabled); 
public voidsetSecure(boolean b)

        ep.setSecure(b);
        secure=b;
        setAttribute("secure", "" + b);
    
public voidsetSelectorTimeout(long timeout)

        ep.setSelectorTimeout(timeout);
    
public voidsetServer(java.lang.String server)

        this.server = server;
    
public voidsetSoLinger(int i)

        ep.setSoLinger( i );
        setAttribute("soLinger", "" + i);
    
public voidsetSoTimeout(int i)

        ep.setSoTimeout(i);
        setAttribute("soTimeout", "" + i);
    
public voidsetSocketBuffer(int valueI)

        socketBuffer = valueI;
    
public voidsetSocketCloseDelay(int d)

        socketCloseDelay=d;
        setAttribute("socketCloseDelay", "" + d);
    
public voidsetSslProtocol(java.lang.String s)

 ep.setSslProtocol(s);
public voidsetTcpNoDelay(boolean b)

        ep.setTcpNoDelay( b );
        setAttribute("tcpNoDelay", "" + b);
    
public voidsetThreadPriority(int threadPriority)

      ep.setThreadPriority(threadPriority);
      setAttribute("threadPriority", "" + threadPriority);
    
public voidsetTimeout(int timeouts)

        timeout = timeouts;
        setAttribute("timeout", "" + timeouts);
    
public voidsetUseExecutor(boolean useexec)

        ep.setUseExecutor(useexec);
    
public voidsetUseSendfile(boolean useSendfile)

        ep.setUseSendfile(useSendfile);
    
public voidstart()

        if( this.domain != null ) {
            try {
                tpOname=new ObjectName
                    (domain + ":" + "type=ThreadPool,name=" + getName());
                Registry.getRegistry(null, null)
                .registerComponent(ep, tpOname, null );
            } catch (Exception e) {
                log.error("Can't register threadpool" );
            }
            rgOname=new ObjectName
                (domain + ":type=GlobalRequestProcessor,name=" + getName());
            Registry.getRegistry(null, null).registerComponent
                ( cHandler.global, rgOname, null );
        }

        try {
            ep.start();
        } catch (Exception ex) {
            log.error(sm.getString("http11protocol.endpoint.starterror"), ex);
            throw ex;
        }
        if(log.isInfoEnabled())
            log.info(sm.getString("http11protocol.start", getName()));