org.apache.log4j.receivers.net

## Class SocketNode13

- java.lang.Object
- - org.apache.log4j.component.spi.ComponentBase
  - - org.apache.log4j.receivers.net.SocketNode13

- All Implemented Interfaces:
    Runnable, Pauseable, Component

      public class SocketNode13
      extends ComponentBase
      implements Runnable, Pauseable

  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.

  Author:
    Ceki Gülcü, Paul Smith (psmith@apache.org)

- - ### Field Summary

    - ### Fields inherited from class org.apache.log4j.component.spi.ComponentBase

      `repository`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `SocketNode13(Socket s, org.apache.log4j.spi.LoggerRepository hierarchy)` Constructor for socket and logger repository.
    `SocketNode13(Socket s, Receiver r)` Constructor for socket and receiver.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addSocketNodeEventListener(SocketNodeEventListener listener)` Adds the listener to the list of listeners to be notified of the respective event.
    `void` | `close()` Close the node and underlying socket
    `boolean` | `isClosed()` Get if node is closed.
    `boolean` | `isPaused()` Get if node is paused.
    `void` | `removeSocketNodeEventListener(SocketNodeEventListener listener)` Removes the registered Listener from this instances list of listeners.
    `void` | `run()` Deserialize events from socket until interrupted.
    `void` | `setListener(SocketNodeEventListener l)` Deprecated. Now supports mutliple listeners, this method simply invokes the removeSocketNodeEventListener() to remove the listener, and then readds it.
    `void` | `setPaused(boolean b)` Sets if node is paused.

    - ### Methods inherited from class org.apache.log4j.component.spi.ComponentBase

      `getLogger, getLoggerRepository, getNonFloodingLogger, resetErrorCount, setLoggerRepository`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### SocketNode13

          public SocketNode13(Socket s,
                      org.apache.log4j.spi.LoggerRepository hierarchy)

      Constructor for socket and logger repository.
      Parameters:
        `s` - socket
        `hierarchy` - logger repository

    - #### SocketNode13

          public SocketNode13(Socket s,
                      Receiver r)

      Constructor for socket and receiver.
      Parameters:
        `s` - socket
        `r` - 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:
        `run` in interface `Runnable`

    - #### setPaused

          public void setPaused(boolean b)

      Sets if node is paused.
      Specified by:
        `setPaused` in interface `Pauseable`
      Parameters:
        `b` - new value

    - #### isPaused

          public boolean isPaused()

      Get if node is paused.
      Specified by:
        `isPaused` in interface `Pauseable`
      Returns:
        true if pause.

    - #### close

          public void close()
                     throws IOException

      Close the node and underlying socket
      Throws:
        `IOException`

    - #### isClosed

          public boolean isClosed()

      Get if node is closed.
      Returns:
        true if closed.

Copyright © 2013 The Apache Software Foundation. Licensed under the Apache License, Version 2.0

Apache Extras for Apache log4j, Apache log4j and Apache are trademarks of the Apache Software Foundation.