Package org.apache.coyote
Interface ProtocolHandler
- All Known Implementing Classes:
- AbstractAjpProtocol,- AbstractHttp11JsseProtocol,- AbstractHttp11Protocol,- AbstractProtocol,- AjpNio2Protocol,- AjpNioProtocol,- Http11Nio2Protocol,- Http11NioProtocol
public interface ProtocolHandler
Abstract the protocol implementation, including threading, etc. This is the main interface to be implemented by a
 coyote protocol. Adapter is the main interface to be implemented by a coyote servlet container.
- Author:
- Remy Maucherat, Costin Manolache
- See Also:
- 
Method SummaryModifier and TypeMethodDescriptionvoidaddSslHostConfig(SSLHostConfig sslHostConfig) Add a new SSL configuration for a virtual host.voidaddSslHostConfig(SSLHostConfig sslHostConfig, boolean replace) Add a new SSL configuration for a virtual host.voidaddUpgradeProtocol(UpgradeProtocol upgradeProtocol) Add a new protocol for used by HTTP/1.1 upgrade or ALPN.longawaitConnectionsClose(long waitMillis) Wait for the client connections to the server to close gracefully.voidstatic ProtocolHandlerCreate a new ProtocolHandler for the given protocol.voiddestroy()Destroy the protocol (optional).Find all configured SSL virtual host configurations which will be used by SNI.Return all configured upgrade protocols.Return the adapter associated with the protocol handler.default intSome protocols, like AJP, have a packet length that shouldn't be exceeded, and this can be used to adjust the buffering used by the application layer.The executor, provide access to the underlying thread pool.default StringgetId()The default behavior is to identify connectors uniquely with address and port.Get the utility executor that should be used by the protocol handler.voidinit()Initialise the protocol.booleanDoes this ProtocolHandler support sendfile?voidpause()Pause the protocol (optional).voidresume()Resume the protocol (optional).voidsetAdapter(Adapter adapter) The adapter, used to call the connector.voidsetExecutor(Executor executor) Set the optional executor that will be used by the connector.voidsetUtilityExecutor(ScheduledExecutorService utilityExecutor) Set the utility executor that should be used by the protocol handler.voidstart()Start the protocol.voidstop()Stop the protocol.
- 
Method Details- 
getAdapterAdapter getAdapter()Return the adapter associated with the protocol handler.- Returns:
- the adapter
 
- 
setAdapterThe adapter, used to call the connector.- Parameters:
- adapter- The adapter to associate
 
- 
getExecutorExecutor getExecutor()The executor, provide access to the underlying thread pool.- Returns:
- The executor used to process requests
 
- 
setExecutorSet the optional executor that will be used by the connector.- Parameters:
- executor- the executor
 
- 
getUtilityExecutorScheduledExecutorService getUtilityExecutor()Get the utility executor that should be used by the protocol handler.- Returns:
- the executor
 
- 
setUtilityExecutorSet the utility executor that should be used by the protocol handler.- Parameters:
- utilityExecutor- the executor
 
- 
initInitialise the protocol.- Throws:
- Exception- If the protocol handler fails to initialise
 
- 
startStart the protocol.- Throws:
- Exception- If the protocol handler fails to start
 
- 
pausePause the protocol (optional).- Throws:
- Exception- If the protocol handler fails to pause
 
- 
resumeResume the protocol (optional).- Throws:
- Exception- If the protocol handler fails to resume
 
- 
stopStop the protocol.- Throws:
- Exception- If the protocol handler fails to stop
 
- 
destroyDestroy the protocol (optional).- Throws:
- Exception- If the protocol handler fails to destroy
 
- 
closeServerSocketGracefulvoid closeServerSocketGraceful()
- 
awaitConnectionsCloselong awaitConnectionsClose(long waitMillis) 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.- 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
 
- 
isSendfileSupportedboolean isSendfileSupported()Does this ProtocolHandler support sendfile?- Returns:
- trueif this Protocol Handler supports sendfile, otherwise- false
 
- 
addSslHostConfigAdd a new SSL configuration for a virtual host.- Parameters:
- sslHostConfig- the configuration
 
- 
addSslHostConfigAdd a new SSL configuration for a virtual host.- Parameters:
- sslHostConfig- the configuration
- replace- If- truereplacement of an existing configuration is permitted, otherwise any such attempted replacement will trigger an exception
- Throws:
- IllegalArgumentException- If the host name is not valid or if a configuration has already been provided for that host and replacement is not allowed
 
- 
findSslHostConfigsSSLHostConfig[] findSslHostConfigs()Find all configured SSL virtual host configurations which will be used by SNI.- Returns:
- the configurations
 
- 
addUpgradeProtocolAdd a new protocol for used by HTTP/1.1 upgrade or ALPN.- Parameters:
- upgradeProtocol- the protocol
 
- 
findUpgradeProtocolsUpgradeProtocol[] findUpgradeProtocols()Return all configured upgrade protocols.- Returns:
- the protocols
 
- 
getDesiredBufferSizedefault int getDesiredBufferSize()Some protocols, like AJP, have a packet length that shouldn't be exceeded, and this can be used to adjust the buffering used by the application layer.- Returns:
- the desired buffer size, or -1 if not relevant
 
- 
getIdThe 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.- Returns:
- the id
 
- 
createstatic ProtocolHandler create(String protocol) throws ClassNotFoundException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException Create a new ProtocolHandler for the given protocol.- Parameters:
- protocol- the protocol
- Returns:
- the newly instantiated protocol handler
- Throws:
- ClassNotFoundException- Specified protocol was not found
- InstantiationException- Specified protocol could not be instantiated
- IllegalAccessException- Exception occurred
- IllegalArgumentException- Exception occurred
- InvocationTargetException- Exception occurred
- NoSuchMethodException- Exception occurred
- SecurityException- Exception occurred
 
 
-