Class RemoteReceiverStreamClient

java.lang.Object
ch.qos.logback.core.spi.ContextAwareBase
ch.qos.logback.core.net.server.RemoteReceiverStreamClient
All Implemented Interfaces:
Client, RemoteReceiverClient, ContextAware, Closeable, AutoCloseable, Runnable

class RemoteReceiverStreamClient extends ContextAwareBase implements RemoteReceiverClient
A RemoteReceiverClient that writes serialized logging events to an OutputStream.
  • Field Details

  • Constructor Details

    • RemoteReceiverStreamClient

      public RemoteReceiverStreamClient(String id, Socket socket)
      Constructs a new client.
      Parameters:
      id - identifier string for the client
      socket - socket to which logging events will be written
    • RemoteReceiverStreamClient

      RemoteReceiverStreamClient(String id, OutputStream outputStream)
      Constructs a new client.

      This constructor exists primarily to support unit tests where it is inconvenient to have to create a socket for the test.

      Parameters:
      id - identifier string for the client
      outputStream - output stream to which logging Events will be written
  • Method Details

    • setQueue

      public void setQueue(BlockingQueue<Serializable> queue)
      Sets the client's event queue.

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

      Specified by:
      setQueue in interface RemoteReceiverClient
      Parameters:
      queue - the queue to set
    • offer

      public boolean offer(Serializable event)
      Offers an event to the client.
      Specified by:
      offer in interface RemoteReceiverClient
      Parameters:
      event - the subject event
      Returns:
      true if the client's queue accepted the event, false if the client's queue is full
    • 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
    • createObjectOutputStream

      private ObjectOutputStream createObjectOutputStream() throws IOException
      Throws:
      IOException