FileDocCategorySizeDatePackage
Http11Protocol.javaAPI DocGlassfish v2 API25761Fri May 04 22:32:42 BST 2007org.apache.coyote.http11

Http11Protocol

public class Http11Protocol extends Object implements 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

Fields Summary
protected boolean
blocking
protected String
selectorThreadImpl
The SelectorThread implementation class. Not used when Coyote is used.
protected static final org.apache.tomcat.util.res.StringManager
sm
The string manager for this package.
ObjectName
tpOname
ObjectName
rgOname
protected org.apache.tomcat.util.threads.ThreadPool
tp
protected PoolTcpEndpoint
ep
protected boolean
secure
protected ServerSocketFactory
socketFactory
protected SSLImplementation
sslImplementation
protected Hashtable
attributes
protected String
socketFactoryName
protected String
sslImplementationName
private int
maxKeepAliveRequests
protected int
timeout
protected int
maxPostSize
protected int
maxHttpHeaderSize
private String
reportedname
protected int
socketCloseDelay
protected boolean
disableUploadTimeout
protected Adapter
adapter
private Http11ConnectionHandler
cHandler
protected int
requestBufferSize
The input request buffer size.
protected String
compression
Compression value.
public static final int
THREAD_DATA_PROCESSOR
public static final int
THREAD_DATA_OBJECT_NAME
protected static final com.sun.org.apache.commons.logging.Log
log
protected String
domain
protected ObjectName
oname
protected MBeanServer
mserver
Constructors Summary
public Http11Protocol()

 
    
    
      
        // START SJSAS 6439313 
        this(false,false,null);
    
public Http11Protocol(boolean secure, boolean blocking, String selectorThreadImpl)

        this.secure = secure;
        this.blocking = blocking; 
        this.selectorThreadImpl = selectorThreadImpl;
        // END SJSAS 6439313
        create();
    
Methods Summary
private voidcheckSocketFactory()
Sanity check and socketFactory setup. IMHO it is better to stop the show on a broken connector, then leave Tomcat running and broken.

exception
TomcatException Unable to resolve classes


    // -------------------- Various implementation classes --------------------

                                         
         
	if(secure) {
 	    try {
 		// The SSL setup code has been moved into
 		// SSLImplementation since SocketFactory doesn't
 		// provide a wide enough interface
 		sslImplementation=SSLImplementation.getInstance
 		    (sslImplementationName);
                socketFactory = 
                        sslImplementation.getServerSocketFactory();
		ep.setServerSocketFactory(socketFactory);
 	    } catch (ClassNotFoundException e){
 		throw e;
  	    }
  	}
 	else {
 	    if (socketFactoryName != null) {
 		try {
 		    socketFactory = string2SocketFactory(socketFactoryName);
 		    ep.setServerSocketFactory(socketFactory);
 		} catch(Exception sfex) {
 		    throw sfex;
 		}
	    }
	}
    
protected voidcreate()

        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);
    
public voiddestroy()

        log.info("Stoping http11 protocol on " + ep.getPort() + " " + tpOname);
        ep.stopEndpoint();
        if( tpOname!=null ) 
            Registry.getRegistry().unregisterComponent(tpOname);
        if( rgOname != null ) 
            Registry.getRegistry().unregisterComponent(rgOname);
    
public AdaptergetAdapter()

        return adapter;
    
public java.net.InetAddressgetAddress()

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

        return getProperty("algorithm");
    
public java.lang.ObjectgetAttribute(java.lang.String key)

        return attributes.get(key);
    
public intgetBacklog()

        return ep.getBacklog();
    
public booleangetBlocking()

        return blocking;
    
public intgetBufferSize()
Return the request input buffer size

        return requestBufferSize;
    
public java.lang.StringgetCiphers()

        return getProperty("ciphers");
    
public java.lang.StringgetClientauth()

        return getProperty("clientauth");
    
public java.lang.StringgetCompression()

        return compression;
    
public booleangetDisableUploadTimeout()

        return disableUploadTimeout;
    
public java.lang.StringgetDomain()

        return domain;
    
public java.lang.StringgetKeyAlias()

        return getProperty("keyAlias");
    
public java.lang.StringgetKeypass()

        return getProperty("keypass");
    
public java.lang.StringgetKeystore()

        return getProperty("keystore");
    
public java.lang.StringgetKeytype()

        return getProperty("keystoreType");
    
public intgetMaxHttpHeaderSize()

        return maxHttpHeaderSize;
    
public intgetMaxKeepAliveRequests()

        return maxKeepAliveRequests;
    
public intgetMaxPostSize()

        return maxPostSize;
    
public intgetMaxSpareThreads()

        return ep.getMaxSpareThreads();
    
public intgetMaxThreads()

        return ep.getMaxThreads();
    
public intgetMinSpareThreads()

        return ep.getMinSpareThreads();
    
public javax.management.ObjectNamegetObjectName()

        return oname;
    
public booleangetPools()


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

       
        return ep.isPoolOn();
    
public intgetPort()

        return ep.getPort();
    
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.StringgetProtocols()

        return getProperty("protocols");
    
public java.lang.StringgetReportedname()

        return reportedname;
    
public java.lang.StringgetSSLImplementation()

        return sslImplementationName;
    
public booleangetSecure()

        return secure;
    
public intgetServerSoTimeout()

        return ep.getServerSoTimeout();
    
public intgetSoLinger()

        return ep.getSoLinger();
    
public intgetSoTimeout()

        return ep.getSoTimeout();
    
public intgetSocketCloseDelay()

        return socketCloseDelay;
    
public java.lang.StringgetSocketFactory()

        return socketFactoryName;
    
public booleangetTcpNoDelay()

        return ep.getTcpNoDelay();
    
public intgetTimeout()

        return timeout;
    
public voidinit()
Start the protocol

        ep.setConnectionHandler( cHandler );
	try {
            checkSocketFactory();
        } catch( Exception ex ) {
            log.error(sm.getString("http11protocol.socketfactory.initerror"),
                      ex);
            throw ex;
        }

        if( socketFactory!=null ) {
            Enumeration attE=attributes.keys();
            while( attE.hasMoreElements() ) {
                String key=(String)attE.nextElement();
                Object v=attributes.get( key );
                socketFactory.setAttribute( key, v );
            }
        }

        // XXX get domain from registration
        try {
            ep.initEndpoint();
        } catch (Exception ex) {
            log.error(sm.getString("http11protocol.endpoint.initerror"), ex);
            throw ex;
        }
        log.info(sm.getString("http11protocol.init", "" + ep.getPort(),
                System.getProperty("product.name")));

    
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 voidsetAdapter(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 k)

        setAttribute("algorithm", k);
    
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);
/*
        if ("maxKeepAliveRequests".equals(name)) {
            maxKeepAliveRequests = Integer.parseInt((String) value.toString());
        } else if ("port".equals(name)) {
            setPort(Integer.parseInt((String) value.toString()));
        }
*/
    
public voidsetBacklog(int i)

	ep.setBacklog(i);
        setAttribute("backlog", "" + i);
    
public voidsetBlocking(boolean b)

    	blocking=b;
        setAttribute("blocking", "" + b);
    
public voidsetBufferSize(int requestBufferSize)
Set the request input buffer size

        this.requestBufferSize = requestBufferSize;
    
public voidsetCiphers(java.lang.String ciphers)

        setAttribute("ciphers", ciphers);
    
public voidsetClientauth(java.lang.String k)

        setAttribute("clientauth", k);
    
public voidsetCompression(java.lang.String valueS)

        compression = valueS;
        setAttribute("compression", valueS);
    
public voidsetDisableUploadTimeout(boolean isDisabled)

        disableUploadTimeout = isDisabled;
    
public voidsetKeyAlias(java.lang.String keyAlias)

        setAttribute("keyAlias", keyAlias);
    
public voidsetKeypass(java.lang.String k)

        attributes.put("keypass", k);
        //setAttribute("keypass", k);
    
public voidsetKeystore(java.lang.String k)

        setAttribute("keystore", k);
    
public voidsetKeytype(java.lang.String k)

        setAttribute("keystoreType", k);
    
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 voidsetMaxPostSize(int valueI)

        maxPostSize = valueI;
        setAttribute("maxPostSize", "" + valueI);
    
public voidsetMaxSpareThreads(int maxThreads)

	ep.setMaxSpareThreads(maxThreads);
        setAttribute("maxSpareThreads", "" + maxThreads);
    
public voidsetMaxThreads(int maxThreads)

	ep.setMaxThreads(maxThreads);
        setAttribute("maxThreads", "" + maxThreads);
    
public voidsetMinSpareThreads(int minSpareThreads)

	ep.setMinSpareThreads(minSpareThreads);
        setAttribute("minSpareThreads", "" + minSpareThreads);
    
public voidsetPools(boolean t)

	ep.setPoolOn(t);
        setAttribute("pools", "" + t);
    
public voidsetPort(int port)

	ep.setPort(port);
        setAttribute("port", "" + port);
    	//this.port=port;
    
public voidsetProperty(java.lang.String name, java.lang.String value)
Set a property.

        setAttribute(name, value);
    
public voidsetProtocol(java.lang.String k)

        setAttribute("protocol", k);
    
public voidsetProtocols(java.lang.String k)

        setAttribute("protocols", k);
    
public voidsetReportedname(java.lang.String reportedName)

	reportedname = reportedName;
    
public voidsetSSLImplementation(java.lang.String valueS)

 	sslImplementationName=valueS;
        setAttribute("sslImplementation", valueS);
    
public voidsetSecure(boolean b)

    	secure=b;
        setAttribute("secure", "" + b);
    
public voidsetServerSoTimeout(int i)

	ep.setServerSoTimeout(i);
        setAttribute("serverSoTimeout", "" + i);
    
public voidsetSoLinger(int i)

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

	ep.setSoTimeout(i);
        setAttribute("soTimeout", "" + i);
    
public voidsetSocketCloseDelay(int d)

        socketCloseDelay=d;
        setAttribute("socketCloseDelay", "" + d);
    
public voidsetSocketFactory(java.lang.String valueS)

	socketFactoryName = valueS;
        setAttribute("socketFactory", valueS);
    
public voidsetTcpNoDelay(boolean b)

	ep.setTcpNoDelay( b );
        setAttribute("tcpNoDelay", "" + b);
    
public voidsetTimeout(int timeouts)

	timeout = timeouts * 1000;
        setAttribute("timeout", "" + timeouts);
    
public voidsetTruststore(java.lang.String truststore)

        setAttribute("truststore", truststore);
    
public voidsetTruststoreType(java.lang.String truststoreType)

        setAttribute("truststoreType", truststoreType);
    
public voidstart()

        if( this.domain != null ) {
            try {
                // XXX We should be able to configure it separately
                // XXX It should be possible to use a single TP
                tpOname=new ObjectName(domain + ":" + "type=ThreadPool,name=http" + ep.getPort());
                Registry.getRegistry().registerComponent(tp, tpOname, null );
                tp.setName("http" + ep.getPort());
                tp.addThreadPoolListener(new MXPoolListener(this, tp));
            } catch (Exception e) {
                log.error("Can't register threadpool" );
            }
            rgOname=new ObjectName( domain + 
                    ":type=GlobalRequestProcessor,name=http" +
                    ep.getPort());
            Registry.getRegistry().registerComponent( cHandler.global,
                    rgOname, null );
        }

        try {
            ep.startEndpoint();
        } catch (Exception ex) {
            log.error(sm.getString("http11protocol.endpoint.starterror"), ex);
            throw ex;
        }
        log.info(sm.getString("http11protocol.start", "" + ep.getPort(),
                System.getProperty("product.name")));
    
protected static ServerSocketFactorystring2SocketFactory(java.lang.String val)

	Class chC=Class.forName( val );
	return (ServerSocketFactory)chC.newInstance();