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 Summary
Modifier and TypeClassDescriptionprotected class
Async timeout threadprotected static class
protected static class
-
Field Summary
Modifier and TypeFieldDescriptionprotected Adapter
The adapter provides the link between the ProtocolHandler and the connector.protected String
When client certificate information is presented in a form other than instances ofX509Certificate
it needs to be converted before it can be used and this property controls which JSSE provider is used to perform the conversion.protected String
protected MBeanServer
protected ObjectName
protected int
The maximum number of idle processors that will be retained in the cache and re-used with a subsequent request.protected ObjectName
Name of MBean for the Global Request Processor. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addWaitingProcessor
(Processor processor) long
awaitConnectionsClose
(long waitMillis) Wait for the client connections to the server to close gracefully.void
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 Processor
Create and configure a new Processor instance for the current protocol implementation.protected abstract Processor
createUpgradeProcessor
(SocketWrapperBase<?> socket, UpgradeToken upgradeToken) void
destroy()
Destroy the protocol (optional).int
int
Deprecated.int
Return the adapter associated with the protocol handler.int
Deprecated.long
int
int
protected AbstractEndpoint<S,
?> The executor, provide access to the underlying thread pool.protected AbstractEndpoint.Handler<S>
int
The time Tomcat will wait for a subsequent request before closing the connection.int
protected abstract Log
getLog()
Concrete implementations need to provide access to their logger to be used by the abstract classes.int
int
int
int
getName()
The name will be prefix-address-port if address is non-null and prefix-port if the address is null.int
protected abstract String
Obtain the prefix to be used when construction a name for this protocol handler.protected abstract UpgradeProtocol
getNegotiatedProtocol
(String name) Find a suitable handler for the protocol negotiated at the network layer.int
getPort()
int
int
int
getProperty
(String name) Generic property getter used by the digester.protected abstract String
Obtain the name of the protocol, (Http, Ajp, etc.).boolean
Deprecated.This option will be removed in Tomcat 9.int
Deprecated.int
Deprecated.boolean
int
protected abstract UpgradeProtocol
getUpgradeProtocol
(String name) Find a suitable handler for the protocol upgraded name specified.int
void
init()
Initialise the protocol.boolean
Requires APR/native libraryboolean
Does this ProtocolHandler support sendfile?void
pause()
Pause the protocol (optional).void
void
postRegister
(Boolean registrationDone) void
preRegister
(MBeanServer server, ObjectName name) void
removeWaitingProcessor
(Processor processor) void
resume()
Resume the protocol (optional).void
setAcceptCount
(int acceptCount) void
setAcceptorThreadCount
(int threadCount) Deprecated.This attribute is hard-coded to1
and is no longer configurable.void
setAcceptorThreadPriority
(int threadPriority) void
setAdapter
(Adapter adapter) The adapter, used to call the connector.void
void
setBacklog
(int backlog) Deprecated.void
void
setConnectionLinger
(int connectionLinger) void
setConnectionTimeout
(int timeout) void
setExecutor
(Executor executor) protected void
setHandler
(AbstractEndpoint.Handler<S> handler) void
setKeepAliveTimeout
(int keepAliveTimeout) void
setMaxConnections
(int maxConnections) void
setMaxHeaderCount
(int maxHeaderCount) void
setMaxThreads
(int maxThreads) void
setMinSpareThreads
(int minSpareThreads) void
setPort
(int port) void
setPortOffset
(int portOffset) void
setProcessorCache
(int processorCache) boolean
setProperty
(String name, String value) Generic property setter used by the digester.void
setSendReasonPhrase
(boolean sendReasonPhrase) Deprecated.This option will be removed in Tomcat 9.void
setSoLinger
(int soLinger) Deprecated.void
setSoTimeout
(int timeout) Deprecated.void
setTcpNoDelay
(boolean tcpNoDelay) void
setThreadPriority
(int threadPriority) void
start()
Start the protocol.void
stop()
Stop the protocol.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.coyote.ProtocolHandler
addSslHostConfig, addSslHostConfig, addUpgradeProtocol, findSslHostConfigs, findUpgradeProtocols
-
Field Details
-
rgOname
Name of MBean for the Global Request Processor. -
adapter
The adapter provides the link between the ProtocolHandler and the connector. -
processorCache
protected 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()
. -
clientCertProvider
When client certificate information is presented in a form other than instances ofX509Certificate
it 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. -
domain
-
oname
-
mserver
-
-
Constructor Details
-
AbstractProtocol
-
-
Method Details
-
setProperty
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 setvalue
- The value, in string form, to set for the property- Returns:
true
if the property was set successfully, otherwisefalse
-
getProperty
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
-
getGlobalRequestProcessorMBeanName
-
setAdapter
Description copied from interface:ProtocolHandler
The adapter, used to call the connector.- Specified by:
setAdapter
in interfaceProtocolHandler
- Parameters:
adapter
- The adapter to associate
-
getAdapter
Description copied from interface:ProtocolHandler
Return the adapter associated with the protocol handler.- Specified by:
getAdapter
in interfaceProtocolHandler
- Returns:
- the adapter
-
getProcessorCache
public int getProcessorCache() -
setProcessorCache
public void setProcessorCache(int processorCache) -
getClientCertProvider
-
setClientCertProvider
-
isAprRequired
public boolean isAprRequired()Description copied from interface:ProtocolHandler
Requires APR/native library- Specified by:
isAprRequired
in interfaceProtocolHandler
- Returns:
true
if this Protocol Handler requires the APR/native library, otherwisefalse
-
isSendfileSupported
public boolean isSendfileSupported()Description copied from interface:ProtocolHandler
Does this ProtocolHandler support sendfile?- Specified by:
isSendfileSupported
in interfaceProtocolHandler
- Returns:
true
if this Protocol Handler supports sendfile, otherwisefalse
-
getAsyncTimeout
-
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.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
-
getExecutor
Description copied from interface:ProtocolHandler
The executor, provide access to the underlying thread pool.- Specified by:
getExecutor
in interfaceProtocolHandler
- Returns:
- The executor used to process requests
-
setExecutor
-
getMaxThreads
public int getMaxThreads() -
setMaxThreads
public void setMaxThreads(int maxThreads) -
getMaxConnections
public int getMaxConnections() -
setMaxConnections
public void setMaxConnections(int maxConnections) -
getMinSpareThreads
public int getMinSpareThreads() -
setMinSpareThreads
public void setMinSpareThreads(int minSpareThreads) -
getThreadPriority
public int getThreadPriority() -
setThreadPriority
public void setThreadPriority(int threadPriority) -
getAcceptCount
public int getAcceptCount() -
setAcceptCount
public void setAcceptCount(int acceptCount) -
getBacklog
Deprecated. -
setBacklog
Deprecated. -
getTcpNoDelay
public boolean getTcpNoDelay() -
setTcpNoDelay
public void setTcpNoDelay(boolean tcpNoDelay) -
getConnectionLinger
public int getConnectionLinger() -
setConnectionLinger
public void setConnectionLinger(int connectionLinger) -
getSoLinger
Deprecated. -
setSoLinger
Deprecated. -
getKeepAliveTimeout
public int getKeepAliveTimeout()The time Tomcat will wait for a subsequent request before closing the connection. The default isgetConnectionTimeout()
.- Returns:
- The timeout in milliseconds
-
setKeepAliveTimeout
public void setKeepAliveTimeout(int keepAliveTimeout) -
getAddress
-
setAddress
-
getPort
public int getPort() -
setPort
public void setPort(int port) -
getPortOffset
public int getPortOffset() -
setPortOffset
public void setPortOffset(int portOffset) -
getPortWithOffset
public int getPortWithOffset() -
getLocalPort
public int getLocalPort() -
getConnectionTimeout
public int getConnectionTimeout() -
setConnectionTimeout
public void setConnectionTimeout(int timeout) -
getSoTimeout
Deprecated. -
setSoTimeout
Deprecated. -
getMaxHeaderCount
public int getMaxHeaderCount() -
setMaxHeaderCount
public void setMaxHeaderCount(int maxHeaderCount) -
getConnectionCount
public long getConnectionCount() -
setAcceptorThreadCount
Deprecated.This attribute is hard-coded to1
and is no longer configurable.Unused.- Parameters:
threadCount
- Ignored
-
getAcceptorThreadCount
Deprecated.This attribute is hard-coded to1
and is no longer configurable.Unused.- Returns:
- Always returns
1
-
setAcceptorThreadPriority
public void setAcceptorThreadPriority(int threadPriority) -
getAcceptorThreadPriority
public int getAcceptorThreadPriority() -
getNameIndex
public int getNameIndex() -
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.
-
addWaitingProcessor
-
removeWaitingProcessor
-
getWaitingProcessorCount
public int getWaitingProcessorCount() -
getEndpoint
-
getHandler
-
setHandler
-
getLog
Concrete implementations need to provide access to their logger to be used by the abstract classes.- Returns:
- the logger
-
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
-
getProtocolName
Obtain the name of the protocol, (Http, Ajp, etc.). Used with JMX.- Returns:
- the protocol name
-
getNegotiatedProtocol
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
-
getUpgradeProtocol
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
-
createProcessor
Create and configure a new Processor instance for the current protocol implementation.- Returns:
- A fully configured Processor instance that is ready to use
-
createUpgradeProcessor
protected abstract Processor createUpgradeProcessor(SocketWrapperBase<?> socket, UpgradeToken upgradeToken) -
getObjectName
-
getDomain
-
preRegister
- Specified by:
preRegister
in interfaceMBeanRegistration
- Throws:
Exception
-
postRegister
- Specified by:
postRegister
in interfaceMBeanRegistration
-
preDeregister
- Specified by:
preDeregister
in interfaceMBeanRegistration
- Throws:
Exception
-
postDeregister
public void postDeregister()- Specified by:
postDeregister
in interfaceMBeanRegistration
-
init
Description copied from interface:ProtocolHandler
Initialise the protocol.- Specified by:
init
in interfaceProtocolHandler
- Throws:
Exception
- If the protocol handler fails to initialise
-
start
Description copied from interface:ProtocolHandler
Start the protocol.- Specified by:
start
in interfaceProtocolHandler
- Throws:
Exception
- If the protocol handler fails to start
-
pause
Description copied from interface:ProtocolHandler
Pause the protocol (optional).- Specified by:
pause
in interfaceProtocolHandler
- Throws:
Exception
- If the protocol handler fails to pause
-
resume
Description copied from interface:ProtocolHandler
Resume the protocol (optional).- Specified by:
resume
in interfaceProtocolHandler
- Throws:
Exception
- If the protocol handler fails to resume
-
stop
Description copied from interface:ProtocolHandler
Stop the protocol.- Specified by:
stop
in interfaceProtocolHandler
- Throws:
Exception
- If the protocol handler fails to stop
-
destroy
Description copied from interface:ProtocolHandler
Destroy the protocol (optional).- Specified by:
destroy
in interfaceProtocolHandler
- Throws:
Exception
- If the protocol handler fails to destroy
-
closeServerSocketGraceful
public void closeServerSocketGraceful()Description copied from interface:ProtocolHandler
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.- Specified by:
closeServerSocketGraceful
in interfaceProtocolHandler
-
awaitConnectionsClose
public long awaitConnectionsClose(long waitMillis) Description copied from interface:ProtocolHandler
Wait 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:
awaitConnectionsClose
in interfaceProtocolHandler
- 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
-
1
and is no longer configurable.