# 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`

public abstract class AbstractAjpProtocol<S> extends AbstractProtocol<S>
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 org.apache.coyote.AbstractProtocol

  `AbstractProtocol.ConnectionHandler<S>, AbstractProtocol.RecycledProcessors`

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected static final StringManager`
  `sm`
  The string manager for this package.

  ### Fields inherited from class org.apache.coyote.AbstractProtocol

  `adapter, domain, mserver, oname, processorCache, rgOname`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `AbstractAjpProtocol(AbstractEndpoint<S,?> endpoint)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `addSslHostConfig(SSLHostConfig sslHostConfig)`
  Add a new SSL configuration for a virtual host.
  `void`
  `addSslHostConfig(SSLHostConfig sslHostConfig, boolean replace)`
  Add a new SSL configuration for a virtual host.
  `void`
  `addUpgradeProtocol(UpgradeProtocol upgradeProtocol)`
  Add a new protocol for used by HTTP/1.1 upgrade or ALPN.
  `protected Processor`
  `createProcessor()`
  Create and configure a new Processor instance for the current protocol implementation.
  `protected Processor`
  `createUpgradeProcessor(SocketWrapperBase<?> socket, UpgradeToken upgradeToken)`
  `SSLHostConfig[]`
  `findSslHostConfigs()`
  Find all configured SSL virtual host configurations which will be used by SNI.
  `UpgradeProtocol[]`
  `findUpgradeProtocols()`
  Return all configured upgrade protocols.
  `boolean`
  `getAjpFlush()`
  `String`
  `getAllowedRequestAttributesPattern()`
  `protected Pattern`
  `getAllowedRequestAttributesPatternInternal()`
  `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.
  `protected AbstractEndpoint<S,?>`
  `getEndpoint()`
  Overridden to make getter accessible to other classes in this package.
  `protected UpgradeProtocol`
  `getNegotiatedProtocol(String name)`
  Find a suitable handler for the protocol negotiated at the network layer.
  `int`
  `getPacketSize()`
  `protected String`
  `getProtocolName()`
  Obtain the name of the protocol, (Http, Ajp, etc.).
  `protected String`
  `getRequiredSecret()`
  Deprecated.
  Replaced by `getSecret()`.
  `protected String`
  `getSecret()`
  `boolean`
  `getSecretRequired()`
  `boolean`
  `getTomcatAuthentication()`
  Should authentication be done in the native web server layer, or in the Servlet container ?
  `boolean`
  `getTomcatAuthorization()`
  Should authentication be done in the native web server layer and authorization in the Servlet container?
  `protected UpgradeProtocol`
  `getUpgradeProtocol(String name)`
  Find a suitable handler for the protocol upgraded name specified.
  `void`
  `setAjpFlush(boolean ajpFlush)`
  Configure whether to aend an AJP flush packet when flushing.
  `void`
  `setAllowedRequestAttributesPattern(String allowedRequestAttributesPattern)`
  `void`
  `setPacketSize(int packetSize)`
  `void`
  `setRequiredSecret(String requiredSecret)`
  Deprecated.
  Replaced by `setSecret(String)`.
  `void`
  `setSecret(String secret)`
  Set the secret that must be included with every request.
  `void`
  `setSecretRequired(boolean secretRequired)`
  `void`
  `setTomcatAuthentication(boolean tomcatAuthentication)`
  `void`
  `setTomcatAuthorization(boolean tomcatAuthorization)`
  `void`
  `start()`
  Start the protocol.

  ### Methods inherited from class org.apache.coyote.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`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### sm

    protected static final StringManager sm
    The string manager for this package.

- ## Constructor Details

  - ### AbstractAjpProtocol

    public AbstractAjpProtocol(AbstractEndpoint<S,?> endpoint)

- ## Method Details

  - ### getProtocolName

    protected String getProtocolName()
    Description copied from class: `AbstractProtocol`
    Obtain the name of the protocol, (Http, Ajp, etc.). Used with JMX.
    Specified by:
      `getProtocolName` in class `AbstractProtocol<S>`
    Returns:
      the protocol name

  - ### getEndpoint

    protected AbstractEndpoint<S,?> getEndpoint()
    Overridden to make getter accessible to other classes in this package.
    Overrides:
      `getEndpoint` in class `AbstractProtocol<S>`

  - ### getNegotiatedProtocol

    protected UpgradeProtocol getNegotiatedProtocol(String name)
    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:
      `getNegotiatedProtocol` in class `AbstractProtocol<S>`
    Parameters:
      `name` - The name of the requested negotiated protocol.
    Returns:
      The instance where `UpgradeProtocol.getAlpnName()` matches the requested protocol

  - ### getUpgradeProtocol

    protected UpgradeProtocol getUpgradeProtocol(String name)
    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:
      `getUpgradeProtocol` in class `AbstractProtocol<S>`
    Parameters:
      `name` - The name of the requested negotiated protocol.
    Returns:
      The instance where `UpgradeProtocol.getAlpnName()` matches the requested protocol

  - ### getAjpFlush

    public boolean getAjpFlush()

  - ### 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:
      `true` if authentication should be performed by Tomcat, otherwise `false`

  - ### setTomcatAuthentication

    public void setTomcatAuthentication(boolean tomcatAuthentication)

  - ### getTomcatAuthorization

    public boolean getTomcatAuthorization()
    Should authentication be done in the native web server layer and authorization in the Servlet container?
    Returns:
      `true` if authorization should be performed by Tomcat, otherwise `false`

  - ### setTomcatAuthorization

    public void setTomcatAuthorization(boolean tomcatAuthorization)

  - ### setSecret

    public void setSecret(String secret)
    Set the secret that must be included with every request.
    Parameters:
      `secret` - The required secret

  - ### getSecret

    protected String getSecret()

  - ### setRequiredSecret

    @Deprecated public void setRequiredSecret(String requiredSecret)
    Deprecated.
    Replaced by `setSecret(String)`. Will be removed in Tomcat 11 onwards
    Set the required secret that must be included with every request.
    Parameters:
      `requiredSecret` - The required secret

  - ### getRequiredSecret

    @Deprecated protected String getRequiredSecret()
    Deprecated.
    Replaced by `getSecret()`. Will be removed in Tomcat 11 onwards
    Returns:
      The current secret

  - ### setSecretRequired

    public void setSecretRequired(boolean secretRequired)

  - ### getSecretRequired

    public boolean getSecretRequired()

  - ### setAllowedRequestAttributesPattern

    public void setAllowedRequestAttributesPattern(String allowedRequestAttributesPattern)

  - ### getAllowedRequestAttributesPattern

    public String getAllowedRequestAttributesPattern()

  - ### getAllowedRequestAttributesPatternInternal

    protected Pattern getAllowedRequestAttributesPatternInternal()

  - ### getPacketSize

    public int getPacketSize()

  - ### setPacketSize

    public void setPacketSize(int packetSize)

  - ### getDesiredBufferSize

    public int getDesiredBufferSize()
    Description copied from interface: `ProtocolHandler`
    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

  - ### addSslHostConfig

    public void addSslHostConfig(SSLHostConfig sslHostConfig)
    Description copied from interface: `ProtocolHandler`
    Add a new SSL configuration for a virtual host.
    Parameters:
      `sslHostConfig` - the configuration

  - ### addSslHostConfig

    public void addSslHostConfig(SSLHostConfig sslHostConfig, boolean replace)
    Description copied from interface: `ProtocolHandler`
    Add a new SSL configuration for a virtual host.
    Parameters:
      `sslHostConfig` - the configuration
      `replace` - If `true` replacement of an existing configuration is permitted, otherwise any such attempted replacement will trigger an exception

  - ### findSslHostConfigs

    public SSLHostConfig[] findSslHostConfigs()
    Description copied from interface: `ProtocolHandler`
    Find all configured SSL virtual host configurations which will be used by SNI.
    Returns:
      the configurations

  - ### addUpgradeProtocol

    public void addUpgradeProtocol(UpgradeProtocol upgradeProtocol)
    Description copied from interface: `ProtocolHandler`
    Add a new protocol for used by HTTP/1.1 upgrade or ALPN.
    Parameters:
      `upgradeProtocol` - the protocol

  - ### findUpgradeProtocols

    public UpgradeProtocol[] findUpgradeProtocols()
    Description copied from interface: `ProtocolHandler`
    Return all configured upgrade protocols.
    Returns:
      the protocols

  - ### createProcessor

    protected Processor createProcessor()
    Description copied from class: `AbstractProtocol`
    Create and configure a new Processor instance for the current protocol implementation.
    Specified by:
      `createProcessor` in class `AbstractProtocol<S>`
    Returns:
      A fully configured Processor instance that is ready to use

  - ### createUpgradeProcessor

    protected Processor createUpgradeProcessor(SocketWrapperBase<?> socket, UpgradeToken upgradeToken)
    Specified by:
      `createUpgradeProcessor` in class `AbstractProtocol<S>`

  - ### start

    public void start() throws Exception
    Description copied from interface: `ProtocolHandler`
    Start the protocol.
    Specified by:
      `start` in interface `ProtocolHandler`
    Overrides:
      `start` in class `AbstractProtocol<S>`
    Throws:
      `Exception` - If the protocol handler fails to start