Class RemoteAppenderStreamClient
- All Implemented Interfaces:
RemoteAppenderClient
,Client
,Closeable
,AutoCloseable
,Runnable
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final String
private final InputStream
private LoggerContext
private Logger
private final Socket
-
Constructor Summary
ConstructorsConstructorDescriptionRemoteAppenderStreamClient
(String id, InputStream inputStream) Constructs a new client.RemoteAppenderStreamClient
(String id, Socket socket) Constructs a new client. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Closes any resources that are held by the client.private HardenedObjectInputStream
void
run()
void
Sets the client's logger context.toString()
-
Field Details
-
id
-
socket
-
inputStream
-
lc
-
logger
-
-
Constructor Details
-
RemoteAppenderStreamClient
Constructs a new client.- Parameters:
id
- a display name for the clientinputStream
- input stream from which events will be read
-
RemoteAppenderStreamClient
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 clientinputStream
- input stream from which events will be read
-
-
Method Details
-
setLoggerContext
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 interfaceRemoteAppenderClient
- 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 anyIOException
that occurs when closing the underlying resource(s). -
run
public void run() -
createObjectInputStream
- Throws:
IOException
-
toString
-