org.apache.coyote

## Class AbstractProcessor

- java.lang.Object
- - org.apache.coyote.AbstractProcessorLight
  - - org.apache.coyote.AbstractProcessor

- All Implemented Interfaces:
    ActionHook, Processor
  Direct Known Subclasses:
    AjpProcessor, Http11Processor

      public abstract class AbstractProcessor
      extends AbstractProcessorLight
      implements ActionHook

  Provides functionality and attributes common to all supported protocols (currently HTTP and AJP).

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected Adapter` | `adapter`
    `protected AsyncStateMachine` | `asyncStateMachine`
    `protected AbstractEndpoint<?>` | `endpoint`
    `protected Request` | `request`
    `protected Response` | `response`
    `protected SocketWrapperBase<?>` | `socketWrapper`
    `protected SSLSupport` | `sslSupport`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `` | `AbstractProcessor(AbstractEndpoint<?> endpoint)`
    `protected` | `AbstractProcessor(AbstractEndpoint<?> endpoint, Request coyoteRequest, Response coyoteResponse)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected abstract void` | `ack()`
    `void` | `action(ActionCode actionCode, Object param)` Send an action to the connector.
    `AbstractEndpoint.Handler.SocketState` | `asyncPostProcess()`
    `protected abstract int` | `available(boolean doRead)`
    `protected abstract void` | `disableSwallowRequest()`
    `AbstractEndpoint.Handler.SocketState` | `dispatch(SocketEvent status)` Process an in-progress request that is not longer in standard HTTP mode.
    `protected abstract AbstractEndpoint.Handler.SocketState` | `dispatchEndRequest()` Perform any necessary clean-up processing if the dispatch resulted in the completion of processing for the current request.
    `protected void` | `dispatchNonBlockingRead()` Perform any necessary processing for a non-blocking read before dispatching to the adapter.
    `protected void` | `doHttpUpgrade(UpgradeToken upgradeToken)` Process an HTTP upgrade.
    `protected void` | `doPush(Request pushTarget)` Process a push.
    `protected void` | `executeDispatches()`
    `protected abstract void` | `finishResponse()`
    `protected abstract void` | `flush()`
    `protected abstract boolean` | `flushBufferedWrite()` Flush any pending writes.
    `Adapter` | `getAdapter()` Get the associated adapter.
    `long` | `getAsyncTimeout()`
    `protected ErrorState` | `getErrorState()`
    `protected Executor` | `getExecutor()`
    `ByteBuffer` | `getLeftoverInput()` Allows retrieving additional input during the upgrade process.
    `protected boolean` | `getPopulateRequestAttributesFromSocket()` Processors that populate request attributes directly (e.g.
    `Request` | `getRequest()`
    `protected SocketWrapperBase<?>` | `getSocketWrapper()`
    `UpgradeToken` | `getUpgradeToken()` Generate an upgrade token.
    `boolean` | `isAsync()`
    `protected boolean` | `isPushSupported()` Protocols that support push should override this method and return `true`.
    `protected abstract boolean` | `isReady()`
    `protected abstract boolean` | `isRequestBodyFullyRead()`
    `boolean` | `isUpgrade()` Processors that implement HTTP upgrade must override this method.
    `protected void` | `populateRequestAttributeRemoteHost()` Populate the remote host request attribute.
    `protected void` | `populateSslRequestAttributes()` Populate the TLS related request attributes from the `SSLSupport` instance associated with this processor.
    `protected abstract void` | `prepareResponse()`
    `protected void` | `processSocketEvent(SocketEvent event, boolean dispatch)`
    `void` | `recycle()` Recycle the processor, ready for the next request which may be on the same connection or a different connection.
    `protected abstract void` | `registerReadInterest()`
    `void` | `setAdapter(Adapter adapter)` Set the associated adapter.
    `void` | `setAsyncTimeout(long timeout)`
    `protected void` | `setErrorState(ErrorState errorState, Throwable t)` Update the current error state to the new error state if the new error state is more severe than the current error state.
    `protected abstract void` | `setRequestBody(ByteChunk body)`
    `protected void` | `setSocketWrapper(SocketWrapperBase<?> socketWrapper)` Set the socket wrapper being used.
    `void` | `setSslSupport(SSLSupport sslSupport)` Set the SSL information for this HTTP connection.
    `protected abstract void` | `setSwallowResponse()`
    `protected void` | `sslReHandShake()` Processors that can perform a TLS re-handshake (e.g.
    `void` | `timeoutAsync(long now)` Check this processor to see if the async timeout has expired and process a timeout if that is that case.

    - ### Methods inherited from class org.apache.coyote.AbstractProcessorLight

      `addDispatch, clearDispatches, getIteratorAndClearDispatches, getLog, process, service`

    - ### 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.Processor

      `pause`

- - ### Field Detail

    - #### adapter

          protected Adapter adapter

    - #### asyncStateMachine

          protected final AsyncStateMachine asyncStateMachine

    - #### endpoint

          protected final AbstractEndpoint<?> endpoint

    - #### request

          protected final Request request

    - #### response

          protected final Response response

    - #### socketWrapper

          protected volatile SocketWrapperBase<?> socketWrapper

    - #### sslSupport

          protected volatile SSLSupport sslSupport

  - ### Constructor Detail

    - #### AbstractProcessor

          public AbstractProcessor(AbstractEndpoint<?> endpoint)

    - #### AbstractProcessor

          protected AbstractProcessor(AbstractEndpoint<?> endpoint,
                           Request coyoteRequest,
                           Response coyoteResponse)

  - ### Method Detail

    - #### setErrorState

          protected void setErrorState(ErrorState errorState,
                           Throwable t)

      Update the current error state to the new error state if the new error state is more severe than the current error state.
      Parameters:
        `errorState` - The error status details
        `t` - The error which occurred

    - #### getErrorState

          protected ErrorState getErrorState()

    - #### getRequest

          public Request getRequest()

      Specified by:
        `getRequest` in interface `Processor`
      Returns:
        The request associated with this processor.

    - #### setAdapter

          public void setAdapter(Adapter adapter)

      Set the associated adapter.
      Parameters:
        `adapter` - the new adapter

    - #### getAdapter

          public Adapter getAdapter()

      Get the associated adapter.
      Returns:
        the associated adapter

    - #### setSocketWrapper

          protected final void setSocketWrapper(SocketWrapperBase<?> socketWrapper)

      Set the socket wrapper being used.
      Parameters:
        `socketWrapper` - The socket wrapper

    - #### getSocketWrapper

          protected final SocketWrapperBase<?> getSocketWrapper()

      Returns:
        the socket wrapper being used.

    - #### setSslSupport

          public final void setSslSupport(SSLSupport sslSupport)

      Description copied from interface: `Processor`
      Set the SSL information for this HTTP connection.
      Specified by:
        `setSslSupport` in interface `Processor`
      Parameters:
        `sslSupport` - The SSL support object to use for this connection

    - #### getExecutor

          protected Executor getExecutor()

      Returns:
        the Executor used by the underlying endpoint.

    - #### isAsync

          public boolean isAsync()

      Specified by:
        `isAsync` in interface `Processor`

    - #### asyncPostProcess

          public AbstractEndpoint.Handler.SocketState asyncPostProcess()

      Specified by:
        `asyncPostProcess` in class `AbstractProcessorLight`

    - #### dispatch

          public final AbstractEndpoint.Handler.SocketState dispatch(SocketEvent status)

      Description copied from class: `AbstractProcessorLight`
      Process an in-progress request that is not longer in standard HTTP mode. Uses currently include Servlet 3.0 Async and HTTP upgrade connections. Further uses may be added in the future. These will typically start as HTTP requests.
      Specified by:
        `dispatch` in class `AbstractProcessorLight`
      Parameters:
        `status` - The event to process
      Returns:
        the socket state

    - #### action

          public final void action(ActionCode actionCode,
                    Object param)

      Description copied from interface: `ActionHook`
      Send an action to the connector.
      Specified by:
        `action` in interface `ActionHook`
      Parameters:
        `actionCode` - Type of the action
        `param` - Action parameter

    - #### dispatchNonBlockingRead

          protected void dispatchNonBlockingRead()

      Perform any necessary processing for a non-blocking read before dispatching to the adapter.

    - #### timeoutAsync

          public void timeoutAsync(long now)

      Description copied from interface: `Processor`
      Check this processor to see if the async timeout has expired and process a timeout if that is that case.
      Specified by:
        `timeoutAsync` in interface `Processor`
      Parameters:
        `now` - The time (as returned by `System.currentTimeMillis()` to use as the current time to determine whether the async timeout has expired. If negative, the timeout will always be treated as if it has expired.

    - #### setAsyncTimeout

          public void setAsyncTimeout(long timeout)

    - #### getAsyncTimeout

          public long getAsyncTimeout()

    - #### recycle

          public void recycle()

      Description copied from interface: `Processor`
      Recycle the processor, ready for the next request which may be on the same connection or a different connection.
      Specified by:
        `recycle` in interface `Processor`

    - #### prepareResponse

          protected abstract void prepareResponse()
                                           throws IOException

      Throws:
        `IOException`

    - #### finishResponse

          protected abstract void finishResponse()
                                          throws IOException

      Throws:
        `IOException`

    - #### ack

          protected abstract void ack()

    - #### flush

          protected abstract void flush()
                                 throws IOException

      Throws:
        `IOException`

    - #### available

          protected abstract int available(boolean doRead)

    - #### setRequestBody

          protected abstract void setRequestBody(ByteChunk body)

    - #### setSwallowResponse

          protected abstract void setSwallowResponse()

    - #### disableSwallowRequest

          protected abstract void disableSwallowRequest()

    - #### getPopulateRequestAttributesFromSocket

          protected boolean getPopulateRequestAttributesFromSocket()

      Processors that populate request attributes directly (e.g. AJP) should over-ride this method and return `false`.
      Returns:
        `true` if the SocketWrapper should be used to populate the request attributes, otherwise `false`.

    - #### populateRequestAttributeRemoteHost

          protected void populateRequestAttributeRemoteHost()

      Populate the remote host request attribute. Processors (e.g. AJP) that populate this from an alternative source should override this method.

    - #### populateSslRequestAttributes

          protected void populateSslRequestAttributes()

      Populate the TLS related request attributes from the `SSLSupport` instance associated with this processor. Protocols that populate TLS attributes from a different source (e.g. AJP) should override this method.

    - #### sslReHandShake

          protected void sslReHandShake()

      Processors that can perform a TLS re-handshake (e.g. HTTP/1.1) should override this method and implement the re-handshake.

    - #### processSocketEvent

          protected void processSocketEvent(SocketEvent event,
                                boolean dispatch)

    - #### isRequestBodyFullyRead

          protected abstract boolean isRequestBodyFullyRead()

    - #### registerReadInterest

          protected abstract void registerReadInterest()

    - #### isReady

          protected abstract boolean isReady()

    - #### executeDispatches

          protected void executeDispatches()

    - #### getUpgradeToken

          public UpgradeToken getUpgradeToken()

      Generate an upgrade token. Processors that implement HTTP upgrade must override this method and provide the necessary token.
      Specified by:
        `getUpgradeToken` in interface `Processor`
      Returns:
        An upgrade token encapsulating the information required to process the upgrade request

    - #### doHttpUpgrade

          protected void doHttpUpgrade(UpgradeToken upgradeToken)

      Process an HTTP upgrade. Processors that support HTTP upgrade should override this method and process the provided token.
      Parameters:
        `upgradeToken` - Contains all the information necessary for the Processor to process the upgrade
      Throws:
        `UnsupportedOperationException` - if the protocol does not support HTTP upgrade

    - #### getLeftoverInput

          public ByteBuffer getLeftoverInput()

      Allows retrieving additional input during the upgrade process. Processors that implement HTTP upgrade must override this method.
      Specified by:
        `getLeftoverInput` in interface `Processor`
      Returns:
        leftover bytes

    - #### isUpgrade

          public boolean isUpgrade()

      Processors that implement HTTP upgrade must override this method.
      Specified by:
        `isUpgrade` in interface `Processor`
      Returns:
        `true` if the Processor is currently processing an upgrade request, otherwise `false`

    - #### isPushSupported

          protected boolean isPushSupported()

      Protocols that support push should override this method and return `true`.
      Returns:
        `true` if push is supported by this processor, otherwise `false`.

    - #### doPush

          protected void doPush(Request pushTarget)

      Process a push. Processors that support push should override this method and process the provided token.
      Parameters:
        `pushTarget` - Contains all the information necessary for the Processor to process the push request
      Throws:
        `UnsupportedOperationException` - if the protocol does not support push

    - #### flushBufferedWrite

          protected abstract boolean flushBufferedWrite()
                                                 throws IOException

      Flush any pending writes. Used during non-blocking writes to flush any remaining data from a previous incomplete write.
      Returns:
        `true` if data remains to be flushed at the end of method
      Throws:
        `IOException` - If an I/O error occurs while attempting to flush the data

    - #### dispatchEndRequest

          protected abstract AbstractEndpoint.Handler.SocketState dispatchEndRequest()

      Perform any necessary clean-up processing if the dispatch resulted in the completion of processing for the current request.
      Returns:
        The state to return for the socket once the clean-up for the current request has completed

Copyright © 2000-2017 Apache Software Foundation. All Rights Reserved.