Class SyslogPublisher
- java.lang.Object
-
- org.forgerock.openam.log.handlers.syslog.SyslogPublisher
-
- Direct Known Subclasses:
SyslogTcpPublisher,SyslogUdpPublisher
public abstract class SyslogPublisher extends Object
This class manages the real socket that is connected to syslog daemon. The socket could be either TCP or UDP socket. If TCP socket is closed, it is (re)opened before sending a message.
-
-
Field Summary
Fields Modifier and Type Field Description protected SocketAddresssocketAddress
-
Constructor Summary
Constructors Constructor Description SyslogPublisher(InetSocketAddress socketAddress)Creates a new SyslogPublisher instance.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract voidcloseConnection()Closes the underlying connection.voidpublishLogRecords(List<String> logRecords)Flush underlying connection.protected abstract voidreconnect()Checks if the currently opened connection is still valid, and connects/reconnects to the Syslog server if necessary.protected abstract voidsendLogRecord(byte[] bytes)Sends the log record to the syslog server by the means of the chosen protocol (TCP or UDP).
-
-
-
Field Detail
-
socketAddress
protected final SocketAddress socketAddress
-
-
Constructor Detail
-
SyslogPublisher
public SyslogPublisher(InetSocketAddress socketAddress)
Creates a new SyslogPublisher instance.- Parameters:
socketAddress- The socket address to be used for sending the syslog messages.
-
-
Method Detail
-
publishLogRecords
public void publishLogRecords(List<String> logRecords)
Flush underlying connection. Sends buffered bytes as UDP datagram or as the next message on TCP stream. The real socket is (re)opened before, if necessary.- Parameters:
logRecords- The logRecords that needs to be published to Syslog.
-
reconnect
protected abstract void reconnect() throws IOExceptionChecks if the currently opened connection is still valid, and connects/reconnects to the Syslog server if necessary.- Throws:
IOException- If there was an IO error while trying to connect to the Syslog server.
-
sendLogRecord
protected abstract void sendLogRecord(byte[] bytes) throws IOExceptionSends the log record to the syslog server by the means of the chosen protocol (TCP or UDP).- Parameters:
bytes- The logRecord's byte[] representation.- Throws:
IOException- If there was an IO error while sending the audit entry to Syslog.
-
closeConnection
protected abstract void closeConnection() throws IOExceptionCloses the underlying connection.- Throws:
IOException- If there was an IO error while closing the connection.
-
-