Package org.apache.log4j.receivers.net
Class SocketNode13
- java.lang.Object
-
- org.apache.log4j.component.spi.ComponentBase
-
- org.apache.log4j.receivers.net.SocketNode13
-
public class SocketNode13 extends ComponentBase implements java.lang.Runnable, Pauseable
ReadLoggingEventobjects sent from a remote client using Sockets (TCP). These logging events are logged according to local policy, as if they were generated locally.For example, the socket node might decide to log events to a local file and also resent them to a second socket node. Implementation lifted from org.apache.log4j.net.SocketNode in log4j 1.3 and renamed to prevent collision with log4j 1.2 implementation.
-
-
Field Summary
Fields Modifier and Type Field Description private booleanclosedClosed state.private java.util.ListlistenerListList of listeners.private booleanpausedPaused state.private ReceiverreceiverReceiver.private java.net.SocketsocketSocket.-
Fields inherited from class org.apache.log4j.component.spi.ComponentBase
repository
-
-
Constructor Summary
Constructors Constructor Description SocketNode13(java.net.Socket s, Receiver r)Constructor for socket and receiver.SocketNode13(java.net.Socket s, org.apache.log4j.spi.LoggerRepository hierarchy)Constructor for socket and logger repository.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddSocketNodeEventListener(SocketNodeEventListener listener)Adds the listener to the list of listeners to be notified of the respective event.voidclose()Close the node and underlying socketprivate voidfireSocketClosedEvent(java.lang.Exception listenerException)Notifies all registered listeners regarding the closing of the Socket.private voidfireSocketOpened(java.lang.String remoteInfo)Notifies all registered listeners regarding the opening of a Socket.booleanisClosed()Get if node is closed.booleanisPaused()Get if node is paused.voidremoveSocketNodeEventListener(SocketNodeEventListener listener)Removes the registered Listener from this instances list of listeners.voidrun()Deserialize events from socket until interrupted.voidsetListener(SocketNodeEventListener l)Deprecated.Now supports mutliple listeners, this method simply invokes the removeSocketNodeEventListener() to remove the listener, and then readds it.voidsetPaused(boolean b)Sets if node is paused.-
Methods inherited from class org.apache.log4j.component.spi.ComponentBase
getLogger, getLoggerRepository, getNonFloodingLogger, resetErrorCount, setLoggerRepository
-
-
-
-
Field Detail
-
paused
private boolean paused
Paused state.
-
closed
private boolean closed
Closed state.
-
socket
private java.net.Socket socket
Socket.
-
receiver
private Receiver receiver
Receiver.
-
listenerList
private java.util.List listenerList
List of listeners.
-
-
Constructor Detail
-
SocketNode13
public SocketNode13(java.net.Socket s, org.apache.log4j.spi.LoggerRepository hierarchy)Constructor for socket and logger repository.- Parameters:
s- sockethierarchy- logger repository
-
SocketNode13
public SocketNode13(java.net.Socket s, Receiver r)Constructor for socket and receiver.- Parameters:
s- socketr- receiver
-
-
Method Detail
-
setListener
public void setListener(SocketNodeEventListener l)
Deprecated.Now supports mutliple listeners, this method simply invokes the removeSocketNodeEventListener() to remove the listener, and then readds it.Set the event listener on this node.- Parameters:
l- listener
-
addSocketNodeEventListener
public void addSocketNodeEventListener(SocketNodeEventListener listener)
Adds the listener to the list of listeners to be notified of the respective event.- Parameters:
listener- the listener to add to the list
-
removeSocketNodeEventListener
public void removeSocketNodeEventListener(SocketNodeEventListener listener)
Removes the registered Listener from this instances list of listeners. If the listener has not been registered, then invoking this method has no effect.- Parameters:
listener- the SocketNodeEventListener to remove
-
run
public void run()
Deserialize events from socket until interrupted.- Specified by:
runin interfacejava.lang.Runnable
-
fireSocketClosedEvent
private void fireSocketClosedEvent(java.lang.Exception listenerException)
Notifies all registered listeners regarding the closing of the Socket.- Parameters:
listenerException- listener exception
-
fireSocketOpened
private void fireSocketOpened(java.lang.String remoteInfo)
Notifies all registered listeners regarding the opening of a Socket.- Parameters:
remoteInfo- remote info
-
setPaused
public void setPaused(boolean b)
Sets if node is paused.
-
isPaused
public boolean isPaused()
Get if node is paused.
-
close
public void close() throws java.io.IOExceptionClose the node and underlying socket- Throws:
java.io.IOException
-
isClosed
public boolean isClosed()
Get if node is closed.- Returns:
- true if closed.
-
-