Package org.apache.coyote
Class AbstractProtocol<S>
java.lang.Object
org.apache.coyote.AbstractProtocol<S>
- All Implemented Interfaces:
- MBeanRegistration,- ProtocolHandler
- Direct Known Subclasses:
- AbstractAjpProtocol,- AbstractHttp11Protocol
public abstract class AbstractProtocol<S>
extends Object
implements ProtocolHandler, MBeanRegistration
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionprotected static classprotected static class
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected AdapterThe adapter provides the link between the ProtocolHandler and the connector.protected Stringprotected MBeanServerprotected ObjectNameprotected intThe maximum number of idle processors that will be retained in the cache and re-used with a subsequent request.protected ObjectNameName of MBean for the Global Request Processor.
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidaddWaitingProcessor(Processor processor) longawaitConnectionsClose(long waitMillis) Wait for the client connections to the server to close gracefully.voidClose 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 ProcessorCreate and configure a new Processor instance for the current protocol implementation.protected abstract ProcessorcreateUpgradeProcessor(SocketWrapperBase<?> socket, UpgradeToken upgradeToken) voiddestroy()Destroy the protocol (optional).intintReturn the adapter associated with the protocol handler.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.longintintprotected AbstractEndpoint<S,?> The executor, provide access to the underlying thread pool.protected AbstractEndpoint.Handler<S>getId()The default behavior is to identify connectors uniquely with address and port.intThe time Tomcat will wait for a subsequent request before closing the connection.intprotected abstract LoggetLog()Concrete implementations need to provide access to their logger to be used by the abstract classes.intintintintgetName()The name will be prefix-address-port if address is non-null and prefix-port if the address is null.intprotected abstract StringObtain the prefix to be used when construction a name for this protocol handler.protected abstract UpgradeProtocolgetNegotiatedProtocol(String name) Find a suitable handler for the protocol negotiated at the network layer.intgetPort()intintintgetProperty(String name) Generic property getter used by the digester.protected abstract StringObtain the name of the protocol, (Http, Ajp, etc.).booleanintprotected abstract UpgradeProtocolgetUpgradeProtocol(String name) Find a suitable handler for the protocol upgraded name specified.Get the utility executor that should be used by the protocol handler.intvoidinit()Initialise the protocol.booleanisPaused()booleanDoes this ProtocolHandler support sendfile?voidpause()Pause the protocol (optional).voidvoidpostRegister(Boolean registrationDone) voidpreRegister(MBeanServer server, ObjectName name) voidremoveWaitingProcessor(Processor processor) voidresume()Resume the protocol (optional).voidsetAcceptCount(int acceptCount) voidsetAcceptorThreadPriority(int threadPriority) voidsetAdapter(Adapter adapter) The adapter, used to call the connector.voidvoidvoidsetConnectionLinger(int connectionLinger) voidsetConnectionTimeout(int timeout) voidsetExecutor(Executor executor) Set the optional executor that will be used by the connector.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(String name, String value) Generic property setter used by the digester.voidsetTcpNoDelay(boolean tcpNoDelay) voidsetThreadPriority(int threadPriority) voidsetUtilityExecutor(ScheduledExecutorService utilityExecutor) Set the utility executor that should be used by the protocol handler.voidstart()Start the protocol.protected voidNote: The name of this method originated with the Servlet 3.0 asynchronous processing but evolved over time to represent a timeout that is triggered independently of the socket read/write timeouts.voidstop()Stop the protocol.protected voidMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.coyote.ProtocolHandleraddSslHostConfig, addSslHostConfig, addUpgradeProtocol, findSslHostConfigs, findUpgradeProtocols, getDesiredBufferSize
- 
Field Details- 
rgOnameName of MBean for the Global Request Processor.
- 
adapterThe adapter provides the link between the ProtocolHandler and the connector.
- 
processorCacheprotected int processorCacheThe 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().
- 
domain
- 
oname
- 
mserver
 
- 
- 
Constructor Details- 
AbstractProtocol
 
- 
- 
Method Details- 
setPropertyGeneric 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
 
- 
getPropertyGeneric 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
 
- 
getGlobalRequestProcessorMBeanName
- 
setAdapterDescription copied from interface:ProtocolHandlerThe adapter, used to call the connector.- Specified by:
- setAdapterin interface- ProtocolHandler
- Parameters:
- adapter- The adapter to associate
 
- 
getAdapterDescription 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) 
- 
getClientCertProviderWhen 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 and with theSSLValve. If not specified, the default provider will be used.- Returns:
- The name of the JSSE provider to use
 
- 
setClientCertProvider
- 
getMaxHeaderCountpublic int getMaxHeaderCount()
- 
setMaxHeaderCountpublic void setMaxHeaderCount(int maxHeaderCount) 
- 
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
 
- 
getIdDescription copied from interface:ProtocolHandlerThe default behavior is to identify connectors uniquely with address and port. However, certain connectors are not using that and need some other identifier, which then can be used as a replacement.- Specified by:
- getIdin interface- ProtocolHandler
- Returns:
- the id
 
- 
getExecutorDescription copied from interface:ProtocolHandlerThe executor, provide access to the underlying thread pool.- Specified by:
- getExecutorin interface- ProtocolHandler
- Returns:
- The executor used to process requests
 
- 
setExecutorDescription copied from interface:ProtocolHandlerSet the optional executor that will be used by the connector.- Specified by:
- setExecutorin interface- ProtocolHandler
- Parameters:
- executor- the executor
 
- 
getUtilityExecutorDescription copied from interface:ProtocolHandlerGet the utility executor that should be used by the protocol handler.- Specified by:
- getUtilityExecutorin interface- ProtocolHandler
- Returns:
- the executor
 
- 
setUtilityExecutorDescription copied from interface:ProtocolHandlerSet the utility executor that should be used by the protocol handler.- Specified by:
- setUtilityExecutorin interface- ProtocolHandler
- Parameters:
- utilityExecutor- the 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) 
- 
getTcpNoDelaypublic boolean getTcpNoDelay()
- 
setTcpNoDelaypublic void setTcpNoDelay(boolean tcpNoDelay) 
- 
getConnectionLingerpublic int getConnectionLinger()
- 
setConnectionLingerpublic void setConnectionLinger(int connectionLinger) 
- 
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) 
- 
getAddress
- 
setAddress
- 
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) 
- 
getConnectionCountpublic long getConnectionCount()
- 
setAcceptorThreadPrioritypublic void setAcceptorThreadPriority(int threadPriority) 
- 
getAcceptorThreadPrioritypublic int getAcceptorThreadPriority()
- 
getNameIndexpublic int getNameIndex()
- 
getNameThe 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.
 
- 
addWaitingProcessor
- 
removeWaitingProcessor
- 
getWaitingProcessorCountpublic int getWaitingProcessorCount()
- 
getEndpoint
- 
getHandler
- 
setHandler
- 
getLogConcrete implementations need to provide access to their logger to be used by the abstract classes.- Returns:
- the logger
 
- 
getNamePrefixObtain the prefix to be used when construction a name for this protocol handler. The name will be prefix-address-port.- Returns:
- the prefix
 
- 
getProtocolNameObtain the name of the protocol, (Http, Ajp, etc.). Used with JMX.- Returns:
- the protocol name
 
- 
getNegotiatedProtocolFind 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
 
- 
getUpgradeProtocolFind 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
 
- 
createProcessorCreate 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) 
- 
getObjectName
- 
getDomain
- 
preRegister- Specified by:
- preRegisterin interface- MBeanRegistration
- Throws:
- Exception
 
- 
postRegister- Specified by:
- postRegisterin interface- MBeanRegistration
 
- 
preDeregister- Specified by:
- preDeregisterin interface- MBeanRegistration
- Throws:
- Exception
 
- 
postDeregisterpublic void postDeregister()- Specified by:
- postDeregisterin interface- MBeanRegistration
 
- 
initDescription copied from interface:ProtocolHandlerInitialise the protocol.- Specified by:
- initin interface- ProtocolHandler
- Throws:
- Exception- If the protocol handler fails to initialise
 
- 
startDescription copied from interface:ProtocolHandlerStart the protocol.- Specified by:
- startin interface- ProtocolHandler
- Throws:
- Exception- If the protocol handler fails to start
 
- 
startAsyncTimeoutprotected void startAsyncTimeout()Note: The name of this method originated with the Servlet 3.0 asynchronous processing but evolved over time to represent a timeout that is triggered independently of the socket read/write timeouts.
- 
stopAsyncTimeoutprotected void stopAsyncTimeout()
- 
pauseDescription copied from interface:ProtocolHandlerPause the protocol (optional).- Specified by:
- pausein interface- ProtocolHandler
- Throws:
- Exception- If the protocol handler fails to pause
 
- 
isPausedpublic boolean isPaused()
- 
resumeDescription copied from interface:ProtocolHandlerResume the protocol (optional).- Specified by:
- resumein interface- ProtocolHandler
- Throws:
- Exception- If the protocol handler fails to resume
 
- 
stopDescription copied from interface:ProtocolHandlerStop the protocol.- Specified by:
- stopin interface- ProtocolHandler
- Throws:
- Exception- If the protocol handler fails to stop
 
- 
destroyDescription copied from interface:ProtocolHandlerDestroy the protocol (optional).- Specified by:
- destroyin interface- ProtocolHandler
- Throws:
- 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
 
 
-