Class RemoteAppenderStreamClient

    • Field Detail

      • id

        private final java.lang.String id
      • socket

        private final java.net.Socket socket
      • inputStream

        private final java.io.InputStream inputStream
      • logger

        private Logger logger
    • Constructor Detail

      • RemoteAppenderStreamClient

        public RemoteAppenderStreamClient​(java.lang.String id,
                                          java.net.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​(java.lang.String id,
                                          java.io.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 Detail

      • 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 java.lang.AutoCloseable
        Specified by:
        close in interface Client
        Specified by:
        close in interface java.io.Closeable
      • run

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

        private HardenedObjectInputStream createObjectInputStream()
                                                           throws java.io.IOException
        Throws:
        java.io.IOException
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object