Package net.dona.doip.server

# Interface DoipProcessor

public interface DoipProcessor
A DoipProcessor encapsulates the request-processing logic of a DOIP server. When a request comes to the listener of a `DoipServer`, the `process(DoipServerRequest, DoipServerResponse)` method of the DoipProcessor will be called with an object representing the incoming request and an object representing the outgoing response. The request object may be inspected and the response object may be populated to provide the response. When the process method returns the server will close the request and response objects as necessary, while generally leaving the socket open for other requests.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `default void`
  `init(com.google.gson.JsonObject config)`
  Initializes the DoipProcessor according to the supplied configuration object.
  `void`
  `process(DoipServerRequest req, DoipServerResponse resp)`
  Process a request and provide a response.
  `default void`
  `shutdown()`
  Shuts down the DoipProcessor.

- ## Method Details

  - ### init

    default void init(com.google.gson.JsonObject config)
    Initializes the DoipProcessor according to the supplied configuration object. This method is called by the `DoipServer` when the DoipServer is constructed using `DoipServer(DoipServerConfig)`; the configuration must supply a DoipProcessor class name (via `DoipServerConfig.processorClass`); the configuration object for the DoipProcessor is given by `DoipServerConfig.processorConfig`.
    Parameters:
      `config` - a configuration JSON object

  - ### process

    void process(DoipServerRequest req, DoipServerResponse resp) throws IOException
    Process a request and provide a response. The supplied request object may be inspected for the details of the request, and the supplied response object may be called to populate the response. It is not necessary to close these objects in this method.
    Parameters:
      `req` - the request object
      `resp` - the response object
    Throws:
      `IOException` - if something goes wrong reading or writing, which will cause the DoipServer to end the connection

  - ### shutdown

    default void shutdown()
    Shuts down the DoipProcessor. This method may be overridden to clean up any resources used by the DoipProcessor instance. It will be called by the `DoipServer` if the DoipServer was constructed using `DoipServer(DoipServerConfig)`.