Class RemoteAppenderStreamClient
- java.lang.Object
-
- ch.qos.logback.classic.net.server.RemoteAppenderStreamClient
-
- All Implemented Interfaces:
RemoteAppenderClient
,Client
,java.io.Closeable
,java.lang.AutoCloseable
,java.lang.Runnable
class RemoteAppenderStreamClient extends java.lang.Object implements RemoteAppenderClient
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.String
id
private java.io.InputStream
inputStream
private LoggerContext
lc
private Logger
logger
private java.net.Socket
socket
-
Constructor Summary
Constructors Constructor Description RemoteAppenderStreamClient(java.lang.String id, java.io.InputStream inputStream)
Constructs a new client.RemoteAppenderStreamClient(java.lang.String id, java.net.Socket socket)
Constructs a new client.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Closes any resources that are held by the client.private HardenedObjectInputStream
createObjectInputStream()
void
run()
void
setLoggerContext(LoggerContext lc)
Sets the client's logger context.java.lang.String
toString()
-
-
-
Field Detail
-
id
private final java.lang.String id
-
socket
private final java.net.Socket socket
-
inputStream
private final java.io.InputStream inputStream
-
lc
private LoggerContext lc
-
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 clientinputStream
- 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 clientinputStream
- 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 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()
- Specified by:
run
in interfacejava.lang.Runnable
-
createObjectInputStream
private HardenedObjectInputStream createObjectInputStream() throws java.io.IOException
- Throws:
java.io.IOException
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-