Klasse AbstractStreamClient<C extends StreamClientConfiguration,REQUEST>

java.lang.Object
org.jupnp.transport.spi.AbstractStreamClient<C,REQUEST>
Alle implementierten Schnittstellen:
StreamClient<C>
Bekannte direkte Unterklassen:
JettyStreamClientImpl

public abstract class AbstractStreamClient<C extends StreamClientConfiguration,REQUEST> extends Object implements StreamClient<C>
Implements the timeout/callback processing and unifies exception handling.
Autor:
Christian Bauer
  • Konstruktordetails

    • AbstractStreamClient

      public AbstractStreamClient()
  • Methodendetails

    • sendRequest

      public StreamResponseMessage sendRequest(StreamRequestMessage requestMessage) throws InterruptedException
      Beschreibung aus Schnittstelle kopiert: StreamClient
      Sends the given request via TCP (HTTP) and returns the response.

      This method must implement expiration of timed out requests using the StreamClientConfiguration settings. When a request expires, a null response will be returned.

      This method will always try to complete execution without throwing an exception. It will return null if an error occurs, and optionally log any exception messages.

      The rules for logging are:

      • If the caller interrupts the calling thread, log at TRACE.
      • If the request expires because the timeout has been reached, log at INFO level.
      • If another error occurs, log at WARNING level

      This method is required to add a Host HTTP header to the outgoing HTTP request, even if the given StreamRequestMessage does not contain such a header.

      This method will add the User-Agent HTTP header to the outgoing HTTP request if the given message did not already contain such a header. You can set this default value in your StreamClientConfiguration.

      Angegeben von:
      sendRequest in Schnittstelle StreamClient<C extends StreamClientConfiguration>
      Parameter:
      requestMessage - The message to send.
      Gibt zurück:
      The response or null if no response has been received or an error occurred.
      Löst aus:
      InterruptedException - if you interrupt the calling thread.
    • createRequest

      protected abstract REQUEST createRequest(StreamRequestMessage requestMessage)
      Create a proprietary representation of this request, log warnings and return null if creation fails.
    • createCallable

      protected abstract Callable<StreamResponseMessage> createCallable(StreamRequestMessage requestMessage, REQUEST request)
      Create a callable procedure that will execute the request.
    • abort

      protected abstract void abort(REQUEST request)
      Cancel and abort the request immediately, with the proprietary API.
    • logExecutionException

      protected abstract boolean logExecutionException(Throwable t)
      Gibt zurück:
      true if no more logging of this exception should be done.
    • onFinally

      protected void onFinally(REQUEST request)