Package org.apache.coyote
Class AbstractProtocol<S>
- java.lang.Object
- 
- org.apache.coyote.AbstractProtocol<S>
 
- 
- All Implemented Interfaces:
- javax.management.MBeanRegistration,- ProtocolHandler
 - Direct Known Subclasses:
- AbstractAjpProtocol,- AbstractHttp11Protocol
 
 public abstract class AbstractProtocol<S> extends java.lang.Object implements ProtocolHandler, javax.management.MBeanRegistration 
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description protected classAbstractProtocol.AsyncTimeoutAsync timeout threadprotected static classAbstractProtocol.ConnectionHandler<S>protected static classAbstractProtocol.RecycledProcessors
 - 
Field SummaryFields Modifier and Type Field Description protected AdapteradapterThe adapter provides the link between the ProtocolHandler and the connector.protected java.lang.StringclientCertProviderWhen client certificate information is presented in a form other than instances ofX509Certificateit needs to be converted before it can be used and this property controls which JSSE provider is used to perform the conversion.protected java.lang.Stringdomainprotected javax.management.MBeanServermserverprotected javax.management.ObjectNameonameprotected intprocessorCacheThe maximum number of idle processors that will be retained in the cache and re-used with a subsequent request.protected javax.management.ObjectNamergOnameName of MBean for the Global Request Processor.
 - 
Constructor SummaryConstructors Constructor Description AbstractProtocol(AbstractEndpoint<S,?> endpoint)
 - 
Method SummaryAll Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddWaitingProcessor(Processor processor)longawaitConnectionsClose(long waitMillis)Wait for the client connections to the server to close gracefully.voidcloseServerSocketGraceful()Close the server socket (to prevent further connections) if the server socket was bound onProtocolHandler.start()(rather than onProtocolHandler.init()but do not perform any further shutdown.protected abstract ProcessorcreateProcessor()Create and configure a new Processor instance for the current protocol implementation.protected abstract ProcessorcreateUpgradeProcessor(SocketWrapperBase<?> socket, UpgradeToken upgradeToken)voiddestroy()Destroy the protocol (optional).intgetAcceptCount()intgetAcceptorThreadCount()Deprecated.This attribute is hard-coded to1and is no longer configurable.intgetAcceptorThreadPriority()AdaptergetAdapter()Return the adapter associated with the protocol handler.java.net.InetAddressgetAddress()AbstractProtocol.AsyncTimeoutgetAsyncTimeout()intgetBacklog()Deprecated.java.lang.StringgetClientCertProvider()longgetConnectionCount()intgetConnectionLinger()intgetConnectionTimeout()java.lang.StringgetDomain()protected AbstractEndpoint<S,?>getEndpoint()java.util.concurrent.ExecutorgetExecutor()The executor, provide access to the underlying thread pool.javax.management.ObjectNamegetGlobalRequestProcessorMBeanName()protected AbstractEndpoint.Handler<S>getHandler()intgetKeepAliveTimeout()The time Tomcat will wait for a subsequent request before closing the connection.intgetLocalPort()protected abstract LoggetLog()Concrete implementations need to provide access to their logger to be used by the abstract classes.intgetMaxConnections()intgetMaxHeaderCount()intgetMaxThreads()intgetMinSpareThreads()java.lang.StringgetName()The name will be prefix-address-port if address is non-null and prefix-port if the address is null.intgetNameIndex()protected abstract java.lang.StringgetNamePrefix()Obtain the prefix to be used when construction a name for this protocol handler.protected abstract UpgradeProtocolgetNegotiatedProtocol(java.lang.String name)Find a suitable handler for the protocol negotiated at the network layer.javax.management.ObjectNamegetObjectName()intgetPort()intgetPortOffset()intgetPortWithOffset()intgetProcessorCache()java.lang.StringgetProperty(java.lang.String name)Generic property getter used by the digester.protected abstract java.lang.StringgetProtocolName()Obtain the name of the protocol, (Http, Ajp, etc.).booleangetSendReasonPhrase()Deprecated.This option will be removed in Tomcat 9.intgetSoLinger()Deprecated.intgetSoTimeout()Deprecated.booleangetTcpNoDelay()intgetThreadPriority()protected abstract UpgradeProtocolgetUpgradeProtocol(java.lang.String name)Find a suitable handler for the protocol upgraded name specified.intgetWaitingProcessorCount()voidinit()Initialise the protocol.booleanisAprRequired()Requires APR/native librarybooleanisSendfileSupported()Does this ProtocolHandler support sendfile?voidpause()Pause the protocol (optional).voidpostDeregister()voidpostRegister(java.lang.Boolean registrationDone)voidpreDeregister()javax.management.ObjectNamepreRegister(javax.management.MBeanServer server, javax.management.ObjectName name)voidremoveWaitingProcessor(Processor processor)voidresume()Resume the protocol (optional).voidsetAcceptCount(int acceptCount)voidsetAcceptorThreadCount(int threadCount)Deprecated.This attribute is hard-coded to1and is no longer configurable.voidsetAcceptorThreadPriority(int threadPriority)voidsetAdapter(Adapter adapter)The adapter, used to call the connector.voidsetAddress(java.net.InetAddress ia)voidsetBacklog(int backlog)Deprecated.voidsetClientCertProvider(java.lang.String s)voidsetConnectionLinger(int connectionLinger)voidsetConnectionTimeout(int timeout)voidsetExecutor(java.util.concurrent.Executor executor)protected voidsetHandler(AbstractEndpoint.Handler<S> handler)voidsetKeepAliveTimeout(int keepAliveTimeout)voidsetMaxConnections(int maxConnections)voidsetMaxHeaderCount(int maxHeaderCount)voidsetMaxThreads(int maxThreads)voidsetMinSpareThreads(int minSpareThreads)voidsetPort(int port)voidsetPortOffset(int portOffset)voidsetProcessorCache(int processorCache)booleansetProperty(java.lang.String name, java.lang.String value)Generic property setter used by the digester.voidsetSendReasonPhrase(boolean sendReasonPhrase)Deprecated.This option will be removed in Tomcat 9.voidsetSoLinger(int soLinger)Deprecated.voidsetSoTimeout(int timeout)Deprecated.voidsetTcpNoDelay(boolean tcpNoDelay)voidsetThreadPriority(int threadPriority)voidstart()Start the protocol.voidstop()Stop the protocol.- 
Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 - 
Methods inherited from interface org.apache.coyote.ProtocolHandleraddSslHostConfig, addUpgradeProtocol, findSslHostConfigs, findUpgradeProtocols
 
- 
 
- 
- 
- 
Field Detail- 
rgOnameprotected javax.management.ObjectName rgOname Name of MBean for the Global Request Processor.
 - 
adapterprotected Adapter adapter The adapter provides the link between the ProtocolHandler and the connector.
 - 
processorCacheprotected int processorCache The maximum number of idle processors that will be retained in the cache and re-used with a subsequent request. The default is 200. A value of -1 means unlimited. In the unlimited case, the theoretical maximum number of cached Processor objects isgetMaxConnections()although it will usually be closer togetMaxThreads().
 - 
clientCertProviderprotected java.lang.String clientCertProvider When client certificate information is presented in a form other than instances ofX509Certificateit needs to be converted before it can be used and this property controls which JSSE provider is used to perform the conversion. For example it is used with the AJP connectors, the HTTP APR connector and with theSSLValve. If not specified, the default provider will be used.
 - 
domainprotected java.lang.String domain 
 - 
onameprotected javax.management.ObjectName oname 
 - 
mserverprotected javax.management.MBeanServer mserver 
 
- 
 - 
Constructor Detail- 
AbstractProtocolpublic AbstractProtocol(AbstractEndpoint<S,?> endpoint) 
 
- 
 - 
Method Detail- 
setPropertypublic boolean setProperty(java.lang.String name, java.lang.String value)Generic property setter used by the digester. Other code should not need to use this. The digester will only use this method if it can't find a more specific setter. That means the property belongs to the Endpoint, the ServerSocketFactory or some other lower level component. This method ensures that it is visible to both.- Parameters:
- name- The name of the property to set
- value- The value, in string form, to set for the property
- Returns:
- trueif the property was set successfully, otherwise- false
 
 - 
getPropertypublic java.lang.String getProperty(java.lang.String name) Generic property getter used by the digester. Other code should not need to use this.- Parameters:
- name- The name of the property to get
- Returns:
- The value of the property converted to a string
 
 - 
getGlobalRequestProcessorMBeanNamepublic javax.management.ObjectName getGlobalRequestProcessorMBeanName() 
 - 
setAdapterpublic void setAdapter(Adapter adapter) Description copied from interface:ProtocolHandlerThe adapter, used to call the connector.- Specified by:
- setAdapterin interface- ProtocolHandler
- Parameters:
- adapter- The adapter to associate
 
 - 
getAdapterpublic Adapter getAdapter() Description copied from interface:ProtocolHandlerReturn the adapter associated with the protocol handler.- Specified by:
- getAdapterin interface- ProtocolHandler
- Returns:
- the adapter
 
 - 
getProcessorCachepublic int getProcessorCache() 
 - 
setProcessorCachepublic void setProcessorCache(int processorCache) 
 - 
getClientCertProviderpublic java.lang.String getClientCertProvider() 
 - 
setClientCertProviderpublic void setClientCertProvider(java.lang.String s) 
 - 
isAprRequiredpublic boolean isAprRequired() Description copied from interface:ProtocolHandlerRequires APR/native library- Specified by:
- isAprRequiredin interface- ProtocolHandler
- Returns:
- trueif this Protocol Handler requires the APR/native library, otherwise- false
 
 - 
isSendfileSupportedpublic boolean isSendfileSupported() Description copied from interface:ProtocolHandlerDoes this ProtocolHandler support sendfile?- Specified by:
- isSendfileSupportedin interface- ProtocolHandler
- Returns:
- trueif this Protocol Handler supports sendfile, otherwise- false
 
 - 
getAsyncTimeoutpublic AbstractProtocol.AsyncTimeout getAsyncTimeout() 
 - 
getSendReasonPhrase@Deprecated public boolean getSendReasonPhrase() Deprecated.This option will be removed in Tomcat 9. Reason phrase will not be sent.Returns whether the reason phrase will be sent in the response. By default a reason phrase will not be sent in the response.- Returns:
- whether the reason phrase will be sent
 
 - 
setSendReasonPhrase@Deprecated public void setSendReasonPhrase(boolean sendReasonPhrase) Deprecated.This option will be removed in Tomcat 9. Reason phrase will not be sent.Specifies whether the reason phrase will be sent in the response. By default a reason phrase will not be sent in the response.- Parameters:
- sendReasonPhrase- specifies whether the reason phrase will be sent
 
 - 
getExecutorpublic java.util.concurrent.Executor getExecutor() Description copied from interface:ProtocolHandlerThe executor, provide access to the underlying thread pool.- Specified by:
- getExecutorin interface- ProtocolHandler
- Returns:
- The executor used to process requests
 
 - 
setExecutorpublic void setExecutor(java.util.concurrent.Executor executor) 
 - 
getMaxThreadspublic int getMaxThreads() 
 - 
setMaxThreadspublic void setMaxThreads(int maxThreads) 
 - 
getMaxConnectionspublic int getMaxConnections() 
 - 
setMaxConnectionspublic void setMaxConnections(int maxConnections) 
 - 
getMinSpareThreadspublic int getMinSpareThreads() 
 - 
setMinSpareThreadspublic void setMinSpareThreads(int minSpareThreads) 
 - 
getThreadPrioritypublic int getThreadPriority() 
 - 
setThreadPrioritypublic void setThreadPriority(int threadPriority) 
 - 
getAcceptCountpublic int getAcceptCount() 
 - 
setAcceptCountpublic void setAcceptCount(int acceptCount) 
 - 
getBacklog@Deprecated public int getBacklog() Deprecated.
 - 
setBacklog@Deprecated public void setBacklog(int backlog) Deprecated.
 - 
getTcpNoDelaypublic boolean getTcpNoDelay() 
 - 
setTcpNoDelaypublic void setTcpNoDelay(boolean tcpNoDelay) 
 - 
getConnectionLingerpublic int getConnectionLinger() 
 - 
setConnectionLingerpublic void setConnectionLinger(int connectionLinger) 
 - 
getSoLinger@Deprecated public int getSoLinger() Deprecated.
 - 
setSoLinger@Deprecated public void setSoLinger(int soLinger) Deprecated.
 - 
getKeepAliveTimeoutpublic int getKeepAliveTimeout() The time Tomcat will wait for a subsequent request before closing the connection. The default isgetConnectionTimeout().- Returns:
- The timeout in milliseconds
 
 - 
setKeepAliveTimeoutpublic void setKeepAliveTimeout(int keepAliveTimeout) 
 - 
getAddresspublic java.net.InetAddress getAddress() 
 - 
setAddresspublic void setAddress(java.net.InetAddress ia) 
 - 
getPortpublic int getPort() 
 - 
setPortpublic void setPort(int port) 
 - 
getPortOffsetpublic int getPortOffset() 
 - 
setPortOffsetpublic void setPortOffset(int portOffset) 
 - 
getPortWithOffsetpublic int getPortWithOffset() 
 - 
getLocalPortpublic int getLocalPort() 
 - 
getConnectionTimeoutpublic int getConnectionTimeout() 
 - 
setConnectionTimeoutpublic void setConnectionTimeout(int timeout) 
 - 
getSoTimeout@Deprecated public int getSoTimeout() Deprecated.
 - 
setSoTimeout@Deprecated public void setSoTimeout(int timeout) Deprecated.
 - 
getMaxHeaderCountpublic int getMaxHeaderCount() 
 - 
setMaxHeaderCountpublic void setMaxHeaderCount(int maxHeaderCount) 
 - 
getConnectionCountpublic long getConnectionCount() 
 - 
setAcceptorThreadCount@Deprecated public void setAcceptorThreadCount(int threadCount) Deprecated.This attribute is hard-coded to1and is no longer configurable.Unused.- Parameters:
- threadCount- Ignored
 
 - 
getAcceptorThreadCount@Deprecated public int getAcceptorThreadCount() Deprecated.This attribute is hard-coded to1and is no longer configurable.Unused.- Returns:
- Always returns 1
 
 - 
setAcceptorThreadPrioritypublic void setAcceptorThreadPriority(int threadPriority) 
 - 
getAcceptorThreadPrioritypublic int getAcceptorThreadPriority() 
 - 
getNameIndexpublic int getNameIndex() 
 - 
getNamepublic java.lang.String getName() The name will be prefix-address-port if address is non-null and prefix-port if the address is null.- Returns:
- A name for this protocol instance that is appropriately quoted for use in an ObjectName.
 
 - 
addWaitingProcessorpublic void addWaitingProcessor(Processor processor) 
 - 
removeWaitingProcessorpublic void removeWaitingProcessor(Processor processor) 
 - 
getWaitingProcessorCountpublic int getWaitingProcessorCount() 
 - 
getEndpointprotected AbstractEndpoint<S,?> getEndpoint() 
 - 
getHandlerprotected AbstractEndpoint.Handler<S> getHandler() 
 - 
setHandlerprotected void setHandler(AbstractEndpoint.Handler<S> handler) 
 - 
getLogprotected abstract Log getLog() Concrete implementations need to provide access to their logger to be used by the abstract classes.- Returns:
- the logger
 
 - 
getNamePrefixprotected abstract java.lang.String getNamePrefix() Obtain the prefix to be used when construction a name for this protocol handler. The name will be prefix-address-port.- Returns:
- the prefix
 
 - 
getProtocolNameprotected abstract java.lang.String getProtocolName() Obtain the name of the protocol, (Http, Ajp, etc.). Used with JMX.- Returns:
- the protocol name
 
 - 
getNegotiatedProtocolprotected abstract UpgradeProtocol getNegotiatedProtocol(java.lang.String name) Find a suitable handler for the protocol negotiated at the network layer.- Parameters:
- name- The name of the requested negotiated protocol.
- Returns:
- The instance where UpgradeProtocol.getAlpnName()matches the requested protocol
 
 - 
getUpgradeProtocolprotected abstract UpgradeProtocol getUpgradeProtocol(java.lang.String name) Find a suitable handler for the protocol upgraded name specified. This is used for direct connection protocol selection.- Parameters:
- name- The name of the requested negotiated protocol.
- Returns:
- The instance where UpgradeProtocol.getAlpnName()matches the requested protocol
 
 - 
createProcessorprotected abstract Processor createProcessor() Create and configure a new Processor instance for the current protocol implementation.- Returns:
- A fully configured Processor instance that is ready to use
 
 - 
createUpgradeProcessorprotected abstract Processor createUpgradeProcessor(SocketWrapperBase<?> socket, UpgradeToken upgradeToken) 
 - 
getObjectNamepublic javax.management.ObjectName getObjectName() 
 - 
getDomainpublic java.lang.String getDomain() 
 - 
preRegisterpublic javax.management.ObjectName preRegister(javax.management.MBeanServer server, javax.management.ObjectName name) throws java.lang.Exception- Specified by:
- preRegisterin interface- javax.management.MBeanRegistration
- Throws:
- java.lang.Exception
 
 - 
postRegisterpublic void postRegister(java.lang.Boolean registrationDone) - Specified by:
- postRegisterin interface- javax.management.MBeanRegistration
 
 - 
preDeregisterpublic void preDeregister() throws java.lang.Exception- Specified by:
- preDeregisterin interface- javax.management.MBeanRegistration
- Throws:
- java.lang.Exception
 
 - 
postDeregisterpublic void postDeregister() - Specified by:
- postDeregisterin interface- javax.management.MBeanRegistration
 
 - 
initpublic void init() throws java.lang.ExceptionDescription copied from interface:ProtocolHandlerInitialise the protocol.- Specified by:
- initin interface- ProtocolHandler
- Throws:
- java.lang.Exception- If the protocol handler fails to initialise
 
 - 
startpublic void start() throws java.lang.ExceptionDescription copied from interface:ProtocolHandlerStart the protocol.- Specified by:
- startin interface- ProtocolHandler
- Throws:
- java.lang.Exception- If the protocol handler fails to start
 
 - 
pausepublic void pause() throws java.lang.ExceptionDescription copied from interface:ProtocolHandlerPause the protocol (optional).- Specified by:
- pausein interface- ProtocolHandler
- Throws:
- java.lang.Exception- If the protocol handler fails to pause
 
 - 
resumepublic void resume() throws java.lang.ExceptionDescription copied from interface:ProtocolHandlerResume the protocol (optional).- Specified by:
- resumein interface- ProtocolHandler
- Throws:
- java.lang.Exception- If the protocol handler fails to resume
 
 - 
stoppublic void stop() throws java.lang.ExceptionDescription copied from interface:ProtocolHandlerStop the protocol.- Specified by:
- stopin interface- ProtocolHandler
- Throws:
- java.lang.Exception- If the protocol handler fails to stop
 
 - 
destroypublic void destroy() throws java.lang.ExceptionDescription copied from interface:ProtocolHandlerDestroy the protocol (optional).- Specified by:
- destroyin interface- ProtocolHandler
- Throws:
- java.lang.Exception- If the protocol handler fails to destroy
 
 - 
closeServerSocketGracefulpublic void closeServerSocketGraceful() Description copied from interface:ProtocolHandlerClose the server socket (to prevent further connections) if the server socket was bound onProtocolHandler.start()(rather than onProtocolHandler.init()but do not perform any further shutdown.- Specified by:
- closeServerSocketGracefulin interface- ProtocolHandler
 
 - 
awaitConnectionsClosepublic long awaitConnectionsClose(long waitMillis) Description copied from interface:ProtocolHandlerWait for the client connections to the server to close gracefully. The method will return when all of the client connections have closed or the method has been waiting forwaitTimeMillis.- Specified by:
- awaitConnectionsClosein interface- ProtocolHandler
- Parameters:
- waitMillis- The maximum time to wait in milliseconds for the client connections to close.
- Returns:
- The wait time, if any remaining when the method returned
 
 
- 
 
-