org.productivity.java.syslog4j.impl.net.tcp
Class TCPNetSyslogWriter

java.lang.Object
  extended by org.productivity.java.syslog4j.impl.AbstractSyslogWriter
      extended by org.productivity.java.syslog4j.impl.net.tcp.TCPNetSyslogWriter
All Implemented Interfaces:
java.io.Serializable, java.lang.Runnable
Direct Known Subclasses:
SSLTCPNetSyslogWriter

public class TCPNetSyslogWriter
extends AbstractSyslogWriter

TCPNetSyslogWriter is an implementation of Runnable that supports sending TCP-based messages within a separate Thread.

When used in "threaded" mode (see TCPNetSyslogConfig for the option), a queuing mechanism is used (via LinkedList).

Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy of the LGPL license is available in the META-INF folder in all distributions of Syslog4j and in the base directory of the "doc" ZIP.

Version:
$Id: TCPNetSyslogWriter.java,v 1.20 2010/11/28 01:38:08 cvs Exp $
Author:
<syslog4j@productivity.org>
See Also:
Serialized Form

Field Summary
protected  long lastSocketCreationTimeMs
           
protected  java.net.Socket socket
           
protected  TCPNetSyslog tcpNetSyslog
           
protected  TCPNetSyslogConfigIF tcpNetSyslogConfig
           
 
Fields inherited from class org.productivity.java.syslog4j.impl.AbstractSyslogWriter
queuedMessages, shutdown, syslog, syslogConfig, thread
 
Constructor Summary
TCPNetSyslogWriter()
           
 
Method Summary
protected  void closeSocket(java.net.Socket socketToClose)
           
protected  java.net.Socket createSocket(java.net.InetAddress hostAddress, int port, boolean keepalive)
           
 void flush()
           
protected  java.net.Socket getSocket()
           
 void initialize(AbstractSyslog abstractSyslog)
           
protected  javax.net.SocketFactory obtainSocketFactory()
           
protected  void runCompleted()
           
 void shutdown()
           
 void write(byte[] message)
           
 
Methods inherited from class org.productivity.java.syslog4j.impl.AbstractSyslogWriter
hasThread, queue, run, setThread
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

tcpNetSyslog

protected TCPNetSyslog tcpNetSyslog

socket

protected java.net.Socket socket

tcpNetSyslogConfig

protected TCPNetSyslogConfigIF tcpNetSyslogConfig

lastSocketCreationTimeMs

protected long lastSocketCreationTimeMs
Constructor Detail

TCPNetSyslogWriter

public TCPNetSyslogWriter()
Method Detail

initialize

public void initialize(AbstractSyslog abstractSyslog)
Overrides:
initialize in class AbstractSyslogWriter

obtainSocketFactory

protected javax.net.SocketFactory obtainSocketFactory()

createSocket

protected java.net.Socket createSocket(java.net.InetAddress hostAddress,
                                       int port,
                                       boolean keepalive)
                                throws java.io.IOException
Throws:
java.io.IOException

getSocket

protected java.net.Socket getSocket()
                             throws SyslogRuntimeException
Throws:
SyslogRuntimeException

closeSocket

protected void closeSocket(java.net.Socket socketToClose)

write

public void write(byte[] message)
           throws SyslogRuntimeException
Specified by:
write in class AbstractSyslogWriter
Throws:
SyslogRuntimeException

flush

public void flush()
           throws SyslogRuntimeException
Specified by:
flush in class AbstractSyslogWriter
Throws:
SyslogRuntimeException

shutdown

public void shutdown()
              throws SyslogRuntimeException
Specified by:
shutdown in class AbstractSyslogWriter
Throws:
SyslogRuntimeException

runCompleted

protected void runCompleted()
Specified by:
runCompleted in class AbstractSyslogWriter