class RemoteReceiverStreamClient extends ContextAwareBase implements RemoteReceiverClient
RemoteReceiverClient that writes serialized logging events to an
OutputStream.| Modifier and Type | Field and Description |
|---|---|
private java.lang.String |
clientId |
private java.io.OutputStream |
outputStream |
private java.util.concurrent.BlockingQueue<java.io.Serializable> |
queue |
private java.net.Socket |
socket |
context| Constructor and 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.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes any resources that are held by the client.
|
private java.io.ObjectOutputStream |
createObjectOutputStream() |
boolean |
offer(java.io.Serializable event)
Offers an event to the client.
|
void |
run() |
void |
setQueue(java.util.concurrent.BlockingQueue<java.io.Serializable> queue)
Sets the client's event queue.
|
addError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, getDeclaredOrigin, getStatusManager, setContextclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaddError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, setContextprivate final java.lang.String clientId
private final java.net.Socket socket
private final java.io.OutputStream outputStream
private java.util.concurrent.BlockingQueue<java.io.Serializable> queue
public RemoteReceiverStreamClient(java.lang.String id,
java.net.Socket socket)
id - identifier string for the clientsocket - socket to which logging events will be writtenRemoteReceiverStreamClient(java.lang.String id,
java.io.OutputStream outputStream)
This constructor exists primarily to support unit tests where it is inconvenient to have to create a socket for the test.
id - identifier string for the clientoutputStream - output stream to which logging Events will be writtenpublic void setQueue(java.util.concurrent.BlockingQueue<java.io.Serializable> queue)
This method must be invoked before the Runnable.run() method is invoked.
setQueue in interface RemoteReceiverClientqueue - the queue to setpublic boolean offer(java.io.Serializable event)
offer in interface RemoteReceiverClientevent - the subject eventtrue if the client's queue accepted the event,
false if the client's queue is fullpublic void close()
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).
public void run()
run in interface java.lang.Runnableprivate java.io.ObjectOutputStream createObjectOutputStream()
throws java.io.IOException
java.io.IOException