Class RemoteAppenderStreamClient

java.lang.Object
ch.qos.logback.classic.net.server.RemoteAppenderStreamClient
All Implemented Interfaces:
RemoteAppenderClient, Client, Closeable, AutoCloseable, Runnable

class RemoteAppenderStreamClient extends Object implements RemoteAppenderClient
A RemoteAppenderClient that reads serialized ILoggingEvent objects from an InputStream.
  • Field Details

  • Constructor Details

    • RemoteAppenderStreamClient

      public RemoteAppenderStreamClient(String id, Socket socket)
      Constructs a new client.
      Parameters:
      id - a display name for the client
      inputStream - input stream from which events will be read
    • RemoteAppenderStreamClient

      public RemoteAppenderStreamClient(String id, InputStream inputStream)
      Constructs a new client.

      This constructor is provided primarily to support unit tests for which it is inconvenient to create a socket.

      Parameters:
      id - a display name for the client
      inputStream - input stream from which events will be read
  • Method Details

    • setLoggerContext

      public void setLoggerContext(LoggerContext lc)
      Sets the client's logger context.

      This provides the local logging context to the client's service thread, and is used as the destination for logging events received from the client.

      This method must be invoked before the Runnable.run() method.

      Specified by:
      setLoggerContext in interface RemoteAppenderClient
      Parameters:
      lc - the logger context to set
    • close

      public void close()
      Closes any resources that are held by the client.

      Note that (as described in Doug Lea's discussion about interrupting I/O operations in "Concurrent Programming in Java" (Addison-Wesley Professional, 2nd edition, 1999) this method is used to interrupt any blocked I/O operation in the client when the server is shutting down. The client implementation must anticipate this potential, and gracefully exit when the blocked I/O operation throws the relevant IOException subclass.

      Note also, that unlike Closeable.close() this method is not permitted to propagate any IOException that occurs when closing the underlying resource(s).

      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Client
      Specified by:
      close in interface Closeable
    • run

      public void run()
      Specified by:
      run in interface Runnable
    • createObjectInputStream

      private HardenedObjectInputStream createObjectInputStream() throws IOException
      Throws:
      IOException
    • toString

      public String toString()
      Overrides:
      toString in class Object