Class RemoteReceiverStreamClient
- java.lang.Object
-
- ch.qos.logback.core.spi.ContextAwareBase
-
- ch.qos.logback.core.net.server.RemoteReceiverStreamClient
-
- All Implemented Interfaces:
Client,RemoteReceiverClient,ContextAware,java.io.Closeable,java.lang.AutoCloseable,java.lang.Runnable
class RemoteReceiverStreamClient extends ContextAwareBase implements RemoteReceiverClient
ARemoteReceiverClientthat writes serialized logging events to anOutputStream.
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.StringclientIdprivate java.io.OutputStreamoutputStreamprivate java.util.concurrent.BlockingQueue<java.io.Serializable>queueprivate java.net.Socketsocket-
Fields inherited from class ch.qos.logback.core.spi.ContextAwareBase
context
-
-
Constructor Summary
Constructors Constructor Description RemoteReceiverStreamClient(java.lang.String id, java.io.OutputStream outputStream)Constructs a new client.RemoteReceiverStreamClient(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 voidclose()Closes any resources that are held by the client.private java.io.ObjectOutputStreamcreateObjectOutputStream()booleanoffer(java.io.Serializable event)Offers an event to the client.voidrun()voidsetQueue(java.util.concurrent.BlockingQueue<java.io.Serializable> queue)Sets the client's event queue.-
Methods inherited from class ch.qos.logback.core.spi.ContextAwareBase
addError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, getDeclaredOrigin, getStatusManager, setContext
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface ch.qos.logback.core.spi.ContextAware
addError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, setContext
-
-
-
-
Constructor Detail
-
RemoteReceiverStreamClient
public RemoteReceiverStreamClient(java.lang.String id, java.net.Socket socket)Constructs a new client.- Parameters:
id- identifier string for the clientsocket- socket to which logging events will be written
-
RemoteReceiverStreamClient
RemoteReceiverStreamClient(java.lang.String id, java.io.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 clientoutputStream- output stream to which logging Events will be written
-
-
Method Detail
-
setQueue
public void setQueue(java.util.concurrent.BlockingQueue<java.io.Serializable> queue)
Sets the client's event queue.This method must be invoked before the
Runnable.run()method is invoked.- Specified by:
setQueuein interfaceRemoteReceiverClient- Parameters:
queue- the queue to set
-
offer
public boolean offer(java.io.Serializable event)
Offers an event to the client.- Specified by:
offerin interfaceRemoteReceiverClient- Parameters:
event- the subject event- Returns:
trueif the client's queue accepted the event,falseif 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
IOExceptionsubclass.Note also, that unlike
Closeable.close()this method is not permitted to propagate anyIOExceptionthat occurs when closing the underlying resource(s).
-
run
public void run()
- Specified by:
runin interfacejava.lang.Runnable
-
createObjectOutputStream
private java.io.ObjectOutputStream createObjectOutputStream() throws java.io.IOException- Throws:
java.io.IOException
-
-