Top Description Fields Constructors Methods
ch.qos.logback.core.net.server

pack-priv Class RemoteReceiverStreamClient

extends ContextAwareBase
implements RemoteReceiverClient
Class Inheritance
All Implemented Interfaces
ch.qos.logback.core.net.server.RemoteReceiverClient, ch.qos.logback.core.spi.ContextAware, ch.qos.logback.core.net.server.Client, java.io.Closeable, java.lang.AutoCloseable, java.lang.Runnable
Imports
java.io.IOException, .ObjectOutputStream, .OutputStream, .Serializable, java.net.Socket, .SocketException, java.util.concurrent.BlockingQueue, ch.qos.logback.core.CoreConstants, ch.qos.logback.core.spi.ContextAwareBase, ch.qos.logback.core.util.CloseUtil

A RemoteReceiverClient that writes serialized logging events to an OutputStream.
Author
Carl Harris

Field Summary

Modifier and TypeField and Description
private final String
private final OutputStream
private BlockingQueue<Serializable>
private final Socket
Inherited from ch.qos.logback.core.spi.ContextAwareBase:
context

Constructor Summary

AccessConstructor and Description
public
RemoteReceiverStreamClient(String
identifier string for the client
id
,
Socket
socket to which logging events will be written
socket
)

Constructs a new client.

pack-priv
RemoteReceiverStreamClient(String
identifier string for the client
id
,
OutputStream
output stream to which logging Events will be written
outputStream
)

Constructs a new client.

Method Summary

Modifier and TypeMethod and Description
public void
close()

Implements ch.qos.logback.core.net.server.Client.close.

Closes any resources that are held by the client.
private ObjectOutputStream
public boolean
offer(Serializable
the subject event
event
)

Implements ch.qos.logback.core.net.server.RemoteReceiverClient.offer.

Offers an event to the client.
public void
run()

Implements java.lang.Runnable.run.

Runs this operation.
public void
setQueue(BlockingQueue<Serializable>
the queue to set
queue
)

Implements ch.qos.logback.core.net.server.RemoteReceiverClient.setQueue.

Sets the client's event queue.
Inherited from ch.qos.logback.core.spi.ContextAwareBase:
addErroraddErroraddInfoaddInfoaddStatusaddWarnaddWarngetContextgetDeclaredOrigingetStatusManagersetContext

Field Detail

clientIdback to summary
private final String clientId
outputStreamback to summary
private final OutputStream outputStream
queueback to summary
private BlockingQueue<Serializable> queue
socketback to summary
private final Socket socket

Constructor Detail

RemoteReceiverStreamClientback to summary
public RemoteReceiverStreamClient(String id, Socket socket)

Constructs a new client.

Parameters
id:String

identifier string for the client

socket:Socket

socket to which logging events will be written

RemoteReceiverStreamClientback to summary
pack-priv RemoteReceiverStreamClient(String id, 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:String

identifier string for the client

outputStream:OutputStream

output stream to which logging Events will be written

Method Detail

closeback to summary
public void close()

Implements ch.qos.logback.core.net.server.Client.close.

Doc from ch.qos.logback.core.net.server.Client.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).

createObjectOutputStreamback to summary
private ObjectOutputStream createObjectOutputStream() throws IOException
offerback to summary
public boolean offer(Serializable event)

Implements ch.qos.logback.core.net.server.RemoteReceiverClient.offer.

Doc from ch.qos.logback.core.net.server.RemoteReceiverClient.offer.

Offers an event to the client.

Parameters
event:Serializable

the subject event

Returns:boolean

true if the client's queue accepted the event, false if the client's queue is full

runback to summary
public void run()

Implements java.lang.Runnable.run.

Doc from java.lang.Runnable.run.

Runs this operation.

setQueueback to summary
public void setQueue(BlockingQueue<Serializable> queue)

Implements ch.qos.logback.core.net.server.RemoteReceiverClient.setQueue.

Doc from ch.qos.logback.core.net.server.RemoteReceiverClient.setQueue.

Sets the client's event queue.

This method must be invoked before the run() method is invoked.

Parameters
queue:BlockingQueue<Serializable>

the queue to set