Class SocketNode13
java.lang.Object
org.apache.log4j.component.spi.ComponentBase
org.apache.log4j.receivers.net.SocketNode13
Read
LoggingEvent objects 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
FieldsModifier and TypeFieldDescriptionprivate booleanClosed state.private ListList of listeners.private booleanPaused state.private ReceiverReceiver.private SocketSocket.Fields inherited from class ComponentBase
repository -
Constructor Summary
ConstructorsConstructorDescriptionSocketNode13(Socket s, Receiver r) Constructor for socket and receiver.SocketNode13(Socket s, org.apache.log4j.spi.LoggerRepository hierarchy) Constructor for socket and logger repository. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds the listener to the list of listeners to be notified of the respective event.voidclose()Close the node and underlying socketprivate voidfireSocketClosedEvent(Exception listenerException) Notifies all registered listeners regarding the closing of the Socket.private voidfireSocketOpened(String remoteInfo) Notifies all registered listeners regarding the opening of a Socket.booleanisClosed()Get if node is closed.booleanisPaused()Get if node is paused.voidRemoves the registered Listener from this instances list of listeners.voidrun()Deserialize events from socket until interrupted.voidDeprecated.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 ComponentBase
getLogger, getLoggerRepository, getNonFloodingLogger, resetErrorCount, setLoggerRepository
-
Field Details
-
paused
private boolean pausedPaused state. -
closed
private boolean closedClosed state. -
socket
Socket. -
receiver
Receiver. -
listenerList
List of listeners.
-
-
Constructor Details
-
SocketNode13
Constructor for socket and logger repository.- Parameters:
s- sockethierarchy- logger repository
-
SocketNode13
-
-
Method Details
-
setListener
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
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
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
-
fireSocketClosedEvent
Notifies all registered listeners regarding the closing of the Socket.- Parameters:
listenerException- listener exception
-
fireSocketOpened
Notifies all registered listeners regarding the opening of a Socket.- Parameters:
remoteInfo- remote info
-
setPaused
-
isPaused
-
close
-
isClosed
public boolean isClosed()Get if node is closed.- Returns:
- true if closed.
-