Class AbstractAjpProtocol<S>
java.lang.Object
org.apache.coyote.AbstractProtocol<S>
org.apache.coyote.ajp.AbstractAjpProtocol<S>
- Type Parameters:
S- The type of socket used by the implementation
- All Implemented Interfaces:
MBeanRegistration, ProtocolHandler
- Direct Known Subclasses:
AjpNio2Protocol, AjpNioProtocol
This the base implementation for the AJP protocol handlers. Implementations typically extend this base class rather
than implement
ProtocolHandler. All of the implementations that ship with Tomcat are
implemented this way.-
Nested Class Summary
Nested classes/interfaces inherited from class AbstractProtocol
AbstractProtocol.ConnectionHandler<S>, AbstractProtocol.RecycledProcessors -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final StringManagerThe string manager for this package.Fields inherited from class AbstractProtocol
adapter, domain, mserver, oname, processorCache, rgOname -
Constructor Summary
ConstructorsConstructorDescriptionAbstractAjpProtocol(AbstractEndpoint<S, ?> endpoint) Creates a new AJP protocol handler. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddSslHostConfig(SSLHostConfig sslHostConfig) Adds an SSL host configuration.voidaddSslHostConfig(SSLHostConfig sslHostConfig, boolean replace) Adds an SSL host configuration.voidaddUpgradeProtocol(UpgradeProtocol upgradeProtocol) Adds an upgrade protocol.protected ProcessorCreates a new AJP processor.protected ProcessorcreateUpgradeProcessor(SocketWrapperBase<?> socket, UpgradeToken upgradeToken) Creates an upgrade processor.Finds SSL host configurations.Finds upgrade protocols.booleanGets whether AJP flush packets are used.Gets the pattern for allowed request attributes.protected PatternGets the compiled pattern for allowed request attributes.intGets the desired buffer size for AJP packets.protected AbstractEndpoint<S, ?> Gets the endpoint.protected UpgradeProtocolgetNegotiatedProtocol(String name) Find a suitable handler for the protocol negotiated at the network layer.intGets the AJP packet size.protected StringGets the name of the protocol.protected StringGets the secret that must be included with every request.booleanGets whether a secret is required with every request.booleanShould authentication be done in the native web server layer, or in the Servlet container ?booleanShould authentication be done in the native web server layer and authorization in the Servlet container?protected UpgradeProtocolgetUpgradeProtocol(String name) Find a suitable handler for the protocol upgraded name specified.voidsetAjpFlush(boolean ajpFlush) Configure whether to aend an AJP flush packet when flushing.voidsetAllowedRequestAttributesPattern(String allowedRequestAttributesPattern) Sets the pattern for allowed request attributes.voidsetPacketSize(int packetSize) Sets the AJP packet size.voidSet the secret that must be included with every request.voidsetSecretRequired(boolean secretRequired) Sets whether a secret is required with every request.voidsetTomcatAuthentication(boolean tomcatAuthentication) Sets whether authentication should be done in Tomcat.voidsetTomcatAuthorization(boolean tomcatAuthorization) Sets whether authorization should be done by Tomcat.voidstart()Starts the AJP protocol handler.Methods inherited from class AbstractProtocol
addWaitingProcessor, awaitConnectionsClose, closeServerSocketGraceful, destroy, getAcceptCount, getAcceptorThreadPriority, getAdapter, getAddress, getClientCertProvider, getConnectionCount, getConnectionLinger, getConnectionTimeout, getDomain, getExecutor, getGlobalRequestProcessorMBeanName, getHandler, getId, getKeepAliveTimeout, getLocalPort, getLog, getMaxConnections, getMaxHeaderCount, getMaxQueueSize, getMaxThreads, getMinSpareThreads, getName, getNameIndex, getNamePrefix, getObjectName, getPort, getPortOffset, getPortWithOffset, getProcessorCache, getProperty, getTcpNoDelay, getThreadPriority, getUtilityExecutor, getWaitingProcessorCount, init, isPaused, isSendfileSupported, pause, postDeregister, postRegister, preDeregister, preRegister, removeWaitingProcessor, resume, setAcceptCount, setAcceptorThreadPriority, setAdapter, setAddress, setClientCertProvider, setConnectionLinger, setConnectionTimeout, setExecutor, setHandler, setKeepAliveTimeout, setMaxConnections, setMaxHeaderCount, setMaxQueueSize, setMaxThreads, setMinSpareThreads, setPort, setPortOffset, setProcessorCache, setProperty, setTcpNoDelay, setThreadPriority, setUtilityExecutor, startAsyncTimeout, stop, stopAsyncTimeout
-
Field Details
-
sm
The string manager for this package.
-
-
Constructor Details
-
AbstractAjpProtocol
Creates a new AJP protocol handler.- Parameters:
endpoint- The endpoint for low-level network I/O
-
-
Method Details
-
getProtocolName
Gets the name of the protocol.- Specified by:
getProtocolNamein classAbstractProtocol<S>- Returns:
- the protocol name
-
getEndpoint
Gets the endpoint. Overridden to make getter accessible to other classes in this package.- Overrides:
getEndpointin classAbstractProtocol<S>- Returns:
- the endpoint
-
getNegotiatedProtocol
Find a suitable handler for the protocol negotiated at the network layer. AJP does not support protocol negotiation so this always returns null.- Specified by:
getNegotiatedProtocolin classAbstractProtocol<S>- 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. AJP does not support protocol upgrade so this always returns null.- Specified by:
getUpgradeProtocolin classAbstractProtocol<S>- Parameters:
name- The name of the requested negotiated protocol.- Returns:
- The instance where
UpgradeProtocol.getAlpnName()matches the requested protocol
-
getAjpFlush
public boolean getAjpFlush()Gets whether AJP flush packets are used.- Returns:
trueif flush packets are used
-
setAjpFlush
public void setAjpFlush(boolean ajpFlush) Configure whether to aend an AJP flush packet when flushing. A flush packet is a zero byte AJP13 SEND_BODY_CHUNK packet. mod_jk and mod_proxy_ajp interpret this as a request to flush data to the client. AJP always does flush at the end of the response, so if it is not important, that the packets get streamed up to the client, do not use extra flush packets. For compatibility and to stay on the safe side, flush packets are enabled by default.- Parameters:
ajpFlush- The new flush setting
-
getTomcatAuthentication
public boolean getTomcatAuthentication()Should authentication be done in the native web server layer, or in the Servlet container ?- Returns:
trueif authentication should be performed by Tomcat, otherwisefalse
-
setTomcatAuthentication
public void setTomcatAuthentication(boolean tomcatAuthentication) Sets whether authentication should be done in Tomcat.- Parameters:
tomcatAuthentication-trueif authentication should be performed by Tomcat
-
getTomcatAuthorization
public boolean getTomcatAuthorization()Should authentication be done in the native web server layer and authorization in the Servlet container?- Returns:
trueif authorization should be performed by Tomcat, otherwisefalse
-
setTomcatAuthorization
public void setTomcatAuthorization(boolean tomcatAuthorization) Sets whether authorization should be done by Tomcat.- Parameters:
tomcatAuthorization-trueif authorization should be performed by Tomcat
-
setSecret
Set the secret that must be included with every request.- Parameters:
secret- The required secret
-
getSecret
Gets the secret that must be included with every request.- Returns:
- the secret
-
setSecretRequired
public void setSecretRequired(boolean secretRequired) Sets whether a secret is required with every request.- Parameters:
secretRequired-trueif a secret is required
-
getSecretRequired
public boolean getSecretRequired()Gets whether a secret is required with every request.- Returns:
trueif a secret is required
-
setAllowedRequestAttributesPattern
Sets the pattern for allowed request attributes.- Parameters:
allowedRequestAttributesPattern- The regex pattern
-
getAllowedRequestAttributesPattern
Gets the pattern for allowed request attributes.- Returns:
- the pattern string
-
getAllowedRequestAttributesPatternInternal
Gets the compiled pattern for allowed request attributes.- Returns:
- the pattern
-
getPacketSize
public int getPacketSize()Gets the AJP packet size.- Returns:
- the packet size
-
setPacketSize
public void setPacketSize(int packetSize) Sets the AJP packet size.- Parameters:
packetSize- The packet size (must be at least MAX_PACKET_SIZE)
-
getDesiredBufferSize
public int getDesiredBufferSize()Gets the desired buffer size for AJP packets.- Returns:
- the desired buffer size
-
addSslHostConfig
Adds an SSL host configuration. AJP does not support SSL so this logs a warning.- Parameters:
sslHostConfig- The SSL host configuration
-
addSslHostConfig
Adds an SSL host configuration. AJP does not support SSL so this logs a warning.- Parameters:
sslHostConfig- The SSL host configurationreplace- Whether to replace existing configurations
-
findSslHostConfigs
Finds SSL host configurations. AJP does not support SSL so this always returns an empty array.- Returns:
- an empty array
-
addUpgradeProtocol
Adds an upgrade protocol. AJP does not support upgrade so this logs a warning.- Parameters:
upgradeProtocol- The upgrade protocol
-
findUpgradeProtocols
Finds upgrade protocols. AJP does not support upgrade so this always returns an empty array.- Returns:
- an empty array
-
createProcessor
Creates a new AJP processor.- Specified by:
createProcessorin classAbstractProtocol<S>- Returns:
- the processor
-
createUpgradeProcessor
Creates an upgrade processor. AJP does not support upgrade so this always throws.- Specified by:
createUpgradeProcessorin classAbstractProtocol<S>- Parameters:
socket- The socket wrapperupgradeToken- The upgrade token- Returns:
- never returns
- Throws:
IllegalStateException- always
-
start
Starts the AJP protocol handler. Validates that a secret is configured if required.- Specified by:
startin interfaceProtocolHandler- Overrides:
startin classAbstractProtocol<S>- Throws:
Exception- if start fails
-