|
JBoss Log Manager 1.5.6.Final | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.io.OutputStream
org.jboss.logmanager.handlers.TcpOutputStream
public class TcpOutputStream
An output stream that writes data to a socket.
IOException occurs during a write(byte[], int, int) and a socket factory was defined the stream will attempt to reconnect indefinitely. By default
additional writes are discarded when reconnecting. If you set the block on
reconnect to true, then the reconnect will indefinitely block until the TCP stream is reconnected.
You can optionally get a collection of the errors that occurred during a write or reconnect.
| Field Summary | |
|---|---|
protected Object |
outputLock
|
| Constructor Summary | |
|---|---|
|
TcpOutputStream(InetAddress address,
int port)
Creates a TCP output stream. |
|
TcpOutputStream(InetAddress address,
int port,
boolean blockOnReconnect)
Creates a TCP output stream. |
protected |
TcpOutputStream(Socket socket)
Deprecated. Use TcpOutputStream(javax.net.SocketFactory, java.net.InetAddress, int) |
protected |
TcpOutputStream(SocketFactory socketFactory,
InetAddress address,
int port)
Creates a new TCP output stream. |
protected |
TcpOutputStream(SocketFactory socketFactory,
InetAddress address,
int port,
boolean blockOnReconnect)
Creates a new TCP output stream. |
| Method Summary | |
|---|---|
void |
close()
|
void |
flush()
|
Collection<Exception> |
getErrors()
Retrieves the errors occurred, if any, during a write or reconnect. |
boolean |
isBlockOnReconnect()
Indicates whether or not the output stream is set to block when attempting to reconnect a TCP connection. |
boolean |
isConnected()
Returns the connected state of the TCP stream. |
void |
setBlockOnReconnect(boolean blockOnReconnect)
Enables or disables blocking when attempting to reconnect the socket. |
void |
write(byte[] b)
|
void |
write(byte[] b,
int off,
int len)
|
void |
write(int b)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected final Object outputLock
| Constructor Detail |
|---|
public TcpOutputStream(InetAddress address,
int port)
throws IOException
default socket factory to create the socket.
address - the address to connect toport - the port to connect to
IOException - no longer throws an exception. If an exception occurs while attempting to connect the socket
a reconnect will be attempted on the next write.
public TcpOutputStream(InetAddress address,
int port,
boolean blockOnReconnect)
throws IOException
Uses the default socket factory to create the socket.
address - the address to connect toport - the port to connect toblockOnReconnect - true to block when attempting to reconnect the socket or false to
reconnect asynchronously
IOException - no longer throws an exception. If an exception occurs while attempting to connect the socket
a reconnect will be attempted on the next write.@Deprecated protected TcpOutputStream(Socket socket)
TcpOutputStream(javax.net.SocketFactory, java.net.InetAddress, int)
socket - the socket used to write the output to
protected TcpOutputStream(SocketFactory socketFactory,
InetAddress address,
int port)
throws IOException
socket from the socketFactory argument.
socketFactory - the factory used to create the socketaddress - the address to connect toport - the port to connect to
IOException - no longer throws an exception. If an exception occurs while attempting to connect the socket
a reconnect will be attempted on the next write.
protected TcpOutputStream(SocketFactory socketFactory,
InetAddress address,
int port,
boolean blockOnReconnect)
throws IOException
Creates a socket from the socketFactory argument.
socketFactory - the factory used to create the socketaddress - the address to connect toport - the port to connect toblockOnReconnect - true to block when attempting to reconnect the socket or false to
reconnect asynchronously
IOException - no longer throws an exception. If an exception occurs while attempting to connect the socket
a reconnect will be attempted on the next write.| Method Detail |
|---|
public void write(int b)
throws IOException
write in class OutputStreamIOException
public void write(byte[] b)
throws IOException
write in class OutputStreamIOException
public void write(byte[] b,
int off,
int len)
throws IOException
write in class OutputStreamIOException
public void flush()
throws IOException
flush in interface Flushableflush in class OutputStreamIOException
public void close()
throws IOException
close in interface Closeableclose in class OutputStreamIOExceptionpublic boolean isBlockOnReconnect()
true if blocking is enabled, otherwise falsepublic void setBlockOnReconnect(boolean blockOnReconnect)
true the write methods will block when attempting to reconnect. This is only advisable
to be set to true if using an asynchronous handler.
blockOnReconnect - true to block when reconnecting or false to reconnect asynchronously
discarding any new messages coming inpublic boolean isConnected()
IOException occurs during a write. Otherwise a
stream is considered connected.
true if the stream is connected, otherwise falsepublic Collection<Exception> getErrors()
|
JBoss Log Manager 1.5.6.Final | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||