org.apache.log4j.net
クラス SocketHubReceiver

java.lang.Object
  上位を拡張 org.apache.log4j.spi.ComponentBase
      上位を拡張 org.apache.log4j.plugins.PluginSkeleton
          上位を拡張 org.apache.log4j.plugins.Receiver
              上位を拡張 org.apache.log4j.net.SocketHubReceiver
すべての実装されたインタフェース:
java.util.EventListener, NetworkBased, PortBased, SocketNodeEventListener, org.apache.log4j.plugins.Plugin, org.apache.log4j.spi.Component, org.apache.log4j.spi.OptionHandler, org.apache.log4j.spi.Thresholdable

public class SocketHubReceiver
extends org.apache.log4j.plugins.Receiver
implements SocketNodeEventListener, PortBased

SocketHubReceiver receives a remote logging event on a configured socket and "posts" it to a LoggerRepository as if the event was generated locally. This class is designed to receive events from the SocketHubAppender class (or classes that send compatible events).

Once the event has been "posted", it will be handled by the appenders currently configured in the LoggerRespository.

作成者:
Mark Womack, Ceki Gülcü, Paul Smith (psmith@apache.org)

フィールドの概要
protected  boolean active
          Active.
protected  org.apache.log4j.net.SocketHubReceiver.Connector connector
          Connector.
protected  java.lang.String host
          Host.
protected  int port
          Port.
protected  int reconnectionDelay
          Reconnection delay.
protected  SocketNode13 socketNode
          Socket.
static java.lang.String ZONE
          The MulticastDNS zone advertised by a SocketHubReceiver
 
クラス org.apache.log4j.plugins.Receiver から継承されたフィールド
thresholdLevel
 
クラス org.apache.log4j.plugins.PluginSkeleton から継承されたフィールド
name
 
クラス org.apache.log4j.spi.ComponentBase から継承されたフィールド
repository
 
コンストラクタの概要
SocketHubReceiver()
          Create new instance.
SocketHubReceiver(java.lang.String h, int p)
          Create new instance.
SocketHubReceiver(java.lang.String h, int p, org.apache.log4j.spi.LoggerRepository repo)
          Create new instance.
 
メソッドの概要
 void activateOptions()
          Starts the SocketReceiver with the current options.
 void addSocketNodeEventListener(SocketNodeEventListener l)
          Adds a SocketNodeEventListener to this receiver to be notified of SocketNode events.
 java.lang.String getHost()
          Get the remote host to connect to for logging events.
 int getPort()
          Get the remote port to connect to for logging events.
 int getReconnectionDelay()
          Returns value of the ReconnectionDelay option.
 boolean isAdvertiseViaMulticastDNS()
           
 boolean isEquivalent(org.apache.log4j.plugins.Plugin testPlugin)
          Returns true if the receiver is the same class and they are configured for the same properties, and super class also considers them to be equivalent.
 void removeSocketNodeEventListener(SocketNodeEventListener l)
          Removes a specific SocketNodeEventListener from this instance so that it will no longer be notified of SocketNode events.
protected  void setActive(boolean b)
          Sets the flag to indicate if receiver is active or not.
 void setAdvertiseViaMulticastDNS(boolean advertiseViaMulticastDNS)
           
 void setHost(java.lang.String remoteHost)
          Configures the Host property, this will require activateOptions to be called for this to take effect.
 void setPort(int p)
          Set the remote port to connect to for logging events.
 void setPort(java.lang.String remoteHost)
          Set the remote host to connect to for logging events.
 void setReconnectionDelay(int delay)
          The ReconnectionDelay option takes a positive integer representing the number of milliseconds to wait between each failed connection attempt to the server.
 void shutdown()
          Called when the receiver should be stopped.
 void socketClosedEvent(java.lang.Exception e)
          Listen for a socketClosedEvent from the SocketNode.
 void socketOpened(java.lang.String remoteInfo)
          This method does nothing.
 
クラス org.apache.log4j.plugins.Receiver から継承されたメソッド
doPost, getThreshold, isAsSevereAsThreshold, setThreshold
 
クラス org.apache.log4j.plugins.PluginSkeleton から継承されたメソッド
addPropertyChangeListener, addPropertyChangeListener, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getLoggerRepository, getName, isActive, removePropertyChangeListener, removePropertyChangeListener, setLoggerRepository, setName
 
クラス org.apache.log4j.spi.ComponentBase から継承されたメソッド
getLogger, getNonFloodingLogger, resetErrorCount
 
クラス java.lang.Object から継承されたメソッド
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
インタフェース org.apache.log4j.net.NetworkBased から継承されたメソッド
getName, isActive
 

フィールドの詳細

host

protected java.lang.String host
Host.


port

protected int port
Port.


reconnectionDelay

protected int reconnectionDelay
Reconnection delay.


ZONE

public static final java.lang.String ZONE
The MulticastDNS zone advertised by a SocketHubReceiver

関連項目:
定数フィールド値

active

protected boolean active
Active.


connector

protected org.apache.log4j.net.SocketHubReceiver.Connector connector
Connector.


socketNode

protected SocketNode13 socketNode
Socket.

コンストラクタの詳細

SocketHubReceiver

public SocketHubReceiver()
Create new instance.


SocketHubReceiver

public SocketHubReceiver(java.lang.String h,
                         int p)
Create new instance.

パラメータ:
h - host
p - port

SocketHubReceiver

public SocketHubReceiver(java.lang.String h,
                         int p,
                         org.apache.log4j.spi.LoggerRepository repo)
Create new instance.

パラメータ:
h - host
p - port
repo - logger repository
メソッドの詳細

addSocketNodeEventListener

public void addSocketNodeEventListener(SocketNodeEventListener l)
Adds a SocketNodeEventListener to this receiver to be notified of SocketNode events.

パラメータ:
l - listener

removeSocketNodeEventListener

public void removeSocketNodeEventListener(SocketNodeEventListener l)
Removes a specific SocketNodeEventListener from this instance so that it will no longer be notified of SocketNode events.

パラメータ:
l - listener

getHost

public java.lang.String getHost()
Get the remote host to connect to for logging events.

戻り値:
host

setHost

public void setHost(java.lang.String remoteHost)
Configures the Host property, this will require activateOptions to be called for this to take effect.

パラメータ:
remoteHost - address of remote host.

setPort

public void setPort(java.lang.String remoteHost)
Set the remote host to connect to for logging events. Equivalent to setHost.

パラメータ:
remoteHost - address of remote host.

getPort

public int getPort()
Get the remote port to connect to for logging events.

定義:
インタフェース PortBased 内の getPort
戻り値:
port

setPort

public void setPort(int p)
Set the remote port to connect to for logging events.

パラメータ:
p - port

setReconnectionDelay

public void setReconnectionDelay(int delay)
The ReconnectionDelay option takes a positive integer representing the number of milliseconds to wait between each failed connection attempt to the server. The default value of this option is 30000 which corresponds to 30 seconds.

Setting this option to zero turns off reconnection capability.

パラメータ:
delay - milliseconds to wait or zero to not reconnect.

getReconnectionDelay

public int getReconnectionDelay()
Returns value of the ReconnectionDelay option.

戻り値:
value of reconnection delay option.

isEquivalent

public boolean isEquivalent(org.apache.log4j.plugins.Plugin testPlugin)
Returns true if the receiver is the same class and they are configured for the same properties, and super class also considers them to be equivalent. This is used by PluginRegistry when determining if the a similarly configured receiver is being started.

定義:
インタフェース org.apache.log4j.plugins.Plugin 内の isEquivalent
オーバーライド:
クラス org.apache.log4j.plugins.PluginSkeleton 内の isEquivalent
パラメータ:
testPlugin - The plugin to test equivalency against.
戻り値:
boolean True if the testPlugin is equivalent to this plugin.

setActive

protected void setActive(boolean b)
Sets the flag to indicate if receiver is active or not.

パラメータ:
b - new value

activateOptions

public void activateOptions()
Starts the SocketReceiver with the current options.

定義:
インタフェース org.apache.log4j.spi.OptionHandler 内の activateOptions

shutdown

public void shutdown()
Called when the receiver should be stopped. Closes the socket

定義:
インタフェース org.apache.log4j.plugins.Plugin 内の shutdown

socketClosedEvent

public void socketClosedEvent(java.lang.Exception e)
Listen for a socketClosedEvent from the SocketNode. Reopen the socket if this receiver is still active.

定義:
インタフェース SocketNodeEventListener 内の socketClosedEvent
パラメータ:
e - exception not used.

setAdvertiseViaMulticastDNS

public void setAdvertiseViaMulticastDNS(boolean advertiseViaMulticastDNS)

isAdvertiseViaMulticastDNS

public boolean isAdvertiseViaMulticastDNS()

socketOpened

public void socketOpened(java.lang.String remoteInfo)
This method does nothing.

定義:
インタフェース SocketNodeEventListener 内の socketOpened
パラメータ:
remoteInfo - remote info.


Copyright © 2010 Apache Software Foundation. All Rights Reserved.