Top Description Methods
org.apache.coyote

public Interface ProtocolHandler

Known Direct Implementers
org.apache.coyote.AbstractProtocol
Imports
java.lang.reflect.InvocationTargetException, java.util.concurrent.Executor, .ScheduledExecutorService, org.apache.tomcat.util.net.SSLHostConfig

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.
Authors
Remy Maucherat, Costin Manolache
See Also
Adapter

Method Summary

Modifier and TypeMethod and Description
public void
addSslHostConfig(SSLHostConfig
the configuration
sslHostConfig
)

Add a new SSL configuration for a virtual host.

public void
addSslHostConfig(SSLHostConfig
the configuration
sslHostConfig
,
boolean
If true replacement of an existing configuration is permitted, otherwise any such attempted replacement will trigger an exception
replace
)

Add a new SSL configuration for a virtual host.

public void
addUpgradeProtocol(UpgradeProtocol
the protocol
upgradeProtocol
)

Add a new protocol for used by HTTP/1.1 upgrade or ALPN.

public long

Returns:

The wait time, if any remaining when the method returned
awaitConnectionsClose
(long
The maximum time to wait in milliseconds for the client connections to close.
waitMillis
)

Wait for the client connections to the server to close gracefully.

public void
closeServerSocketGraceful()

Close the server socket (to prevent further connections) if the server socket was bound on start() (rather than on init() but do not perform any further shutdown.

public static ProtocolHandler

Returns:

the newly instantiated protocol handler
create
(String
the protocol
protocol
)

Create a new ProtocolHandler for the given protocol.

public void
destroy()

Destroy the protocol (optional).

public SSLHostConfig[]

Returns:

the configurations
findSslHostConfigs
()

Find all configured SSL virtual host configurations which will be used by SNI.

public UpgradeProtocol[]

Returns:

the protocols
findUpgradeProtocols
()

Return all configured upgrade protocols.

public Adapter

Returns:

the adapter
getAdapter
()

Return the adapter associated with the protocol handler.

public default int

Returns:

the desired buffer size, or -1 if not relevant
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.

public Executor

Returns:

The executor used to process requests
getExecutor
()

The executor, provide access to the underlying thread pool.

public default String

Returns:

the id
getId
()

The default behavior is to identify connectors uniquely with address and port.

public ScheduledExecutorService

Returns:

the executor
getUtilityExecutor
()

Get the utility executor that should be used by the protocol handler.

public void
init()

Initialise the protocol.

public boolean

Returns:

true if this Protocol Handler supports sendfile, otherwise false
isSendfileSupported
()

Does this ProtocolHandler support sendfile?

public void
pause()

Pause the protocol (optional).

public void
resume()

Resume the protocol (optional).

public void
setAdapter(Adapter
The adapter to associate
adapter
)

The adapter, used to call the connector.

public void
setExecutor(Executor
the executor
executor
)

Set the optional executor that will be used by the connector.

public void
setUtilityExecutor(ScheduledExecutorService
the executor
utilityExecutor
)

Set the utility executor that should be used by the protocol handler.

public void
start()

Start the protocol.

public void
stop()

Stop the protocol.

Method Detail

addSslHostConfigback to summary
public void addSslHostConfig(SSLHostConfig sslHostConfig)

Add a new SSL configuration for a virtual host.

Parameters
sslHostConfig:SSLHostConfig

the configuration

addSslHostConfigback to summary
public void addSslHostConfig(SSLHostConfig sslHostConfig, boolean replace)

Add a new SSL configuration for a virtual host.

Parameters
sslHostConfig:SSLHostConfig

the configuration

replace:boolean

If true replacement of an existing configuration is permitted, otherwise any such attempted replacement will trigger an exception

Exceptions
IllegalArgumentException:
If the host name is not valid or if a configuration has already been provided for that host and replacement is not allowed
addUpgradeProtocolback to summary
public void addUpgradeProtocol(UpgradeProtocol upgradeProtocol)

Add a new protocol for used by HTTP/1.1 upgrade or ALPN.

Parameters
upgradeProtocol:UpgradeProtocol

the protocol

awaitConnectionsCloseback to summary
public long 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 for waitTimeMillis.

Parameters
waitMillis:long

The maximum time to wait in milliseconds for the client connections to close.

Returns:long

The wait time, if any remaining when the method returned

closeServerSocketGracefulback to summary
public void closeServerSocketGraceful()

Close the server socket (to prevent further connections) if the server socket was bound on start() (rather than on init() but do not perform any further shutdown.

createback to summary
public static ProtocolHandler create(String protocol) throws ClassNotFoundException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException

Create a new ProtocolHandler for the given protocol.

Parameters
protocol:String

the protocol

Returns:ProtocolHandler

the newly instantiated protocol handler

Exceptions
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
destroyback to summary
public void destroy() throws Exception

Destroy the protocol (optional).

Exceptions
Exception:
If the protocol handler fails to destroy
findSslHostConfigsback to summary
public SSLHostConfig[] findSslHostConfigs()

Find all configured SSL virtual host configurations which will be used by SNI.

Returns:SSLHostConfig[]

the configurations

findUpgradeProtocolsback to summary
public UpgradeProtocol[] findUpgradeProtocols()

Return all configured upgrade protocols.

Returns:UpgradeProtocol[]

the protocols

getAdapterback to summary
public Adapter getAdapter()

Return the adapter associated with the protocol handler.

Returns:Adapter

the adapter

getDesiredBufferSizeback to summary
public default 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:int

the desired buffer size, or -1 if not relevant

getExecutorback to summary
public Executor getExecutor()

The executor, provide access to the underlying thread pool.

Returns:Executor

The executor used to process requests

getIdback to summary
public default String getId()

The 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:String

the id

getUtilityExecutorback to summary
public ScheduledExecutorService getUtilityExecutor()

Get the utility executor that should be used by the protocol handler.

Returns:ScheduledExecutorService

the executor

initback to summary
public void init() throws Exception

Initialise the protocol.

Exceptions
Exception:
If the protocol handler fails to initialise
isSendfileSupportedback to summary
public boolean isSendfileSupported()

Does this ProtocolHandler support sendfile?

Returns:boolean

true if this Protocol Handler supports sendfile, otherwise false

pauseback to summary
public void pause() throws Exception

Pause the protocol (optional).

Exceptions
Exception:
If the protocol handler fails to pause
resumeback to summary
public void resume() throws Exception

Resume the protocol (optional).

Exceptions
Exception:
If the protocol handler fails to resume
setAdapterback to summary
public void setAdapter(Adapter adapter)

The adapter, used to call the connector.

Parameters
adapter:Adapter

The adapter to associate

setExecutorback to summary
public void setExecutor(Executor executor)

Set the optional executor that will be used by the connector.

Parameters
executor:Executor

the executor

setUtilityExecutorback to summary
public void setUtilityExecutor(ScheduledExecutorService utilityExecutor)

Set the utility executor that should be used by the protocol handler.

Parameters
utilityExecutor:ScheduledExecutorService

the executor

startback to summary
public void start() throws Exception

Start the protocol.

Exceptions
Exception:
If the protocol handler fails to start
stopback to summary
public void stop() throws Exception

Stop the protocol.

Exceptions
Exception:
If the protocol handler fails to stop