public class SocketHubReceiver extends Receiver implements SocketNodeEventListener, PortBased
Once the event has been "posted", it will be handled by the appenders currently configured in the LoggerRespository.
Modifier and Type | Field and Description |
---|---|
protected boolean |
active
Active.
|
protected org.apache.log4j.net.SocketHubReceiver.Connector |
connector
Connector.
|
protected String |
host
Host.
|
protected int |
port
Port.
|
protected int |
reconnectionDelay
Reconnection delay.
|
protected SocketNode13 |
socketNode
Socket.
|
static String |
ZONE
The MulticastDNS zone advertised by a SocketHubReceiver
|
thresholdLevel
name
repository
Constructor and Description |
---|
SocketHubReceiver()
Create new instance.
|
SocketHubReceiver(String h,
int p)
Create new instance.
|
SocketHubReceiver(String h,
int p,
org.apache.log4j.spi.LoggerRepository repo)
Create new instance.
|
Modifier and Type | Method and Description |
---|---|
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.
|
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(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(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(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(Exception e)
Listen for a socketClosedEvent from the SocketNode.
|
void |
socketOpened(String remoteInfo)
This method does nothing.
|
doPost, getThreshold, isAsSevereAsThreshold, setThreshold
addPropertyChangeListener, addPropertyChangeListener, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getLoggerRepository, getName, isActive, removePropertyChangeListener, removePropertyChangeListener, setLoggerRepository, setName
getLogger, getNonFloodingLogger, resetErrorCount
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getName, isActive
protected String host
protected int port
protected int reconnectionDelay
public static final String ZONE
protected boolean active
protected org.apache.log4j.net.SocketHubReceiver.Connector connector
protected SocketNode13 socketNode
public SocketHubReceiver()
public SocketHubReceiver(String h, int p)
h
- hostp
- portpublic SocketHubReceiver(String h, int p, org.apache.log4j.spi.LoggerRepository repo)
h
- hostp
- portrepo
- logger repositorypublic void addSocketNodeEventListener(SocketNodeEventListener l)
l
- listenerpublic void removeSocketNodeEventListener(SocketNodeEventListener l)
l
- listenerpublic String getHost()
public void setHost(String remoteHost)
remoteHost
- address of remote host.public void setPort(String remoteHost)
remoteHost
- address of remote host.public int getPort()
public void setPort(int p)
p
- portpublic void setReconnectionDelay(int delay)
Setting this option to zero turns off reconnection capability.
delay
- milliseconds to wait or zero to not reconnect.public int getReconnectionDelay()
public boolean isEquivalent(Plugin testPlugin)
isEquivalent
in interface Plugin
isEquivalent
in class PluginSkeleton
testPlugin
- The plugin to test equivalency against.protected void setActive(boolean b)
b
- new valuepublic void activateOptions()
activateOptions
in interface org.apache.log4j.spi.OptionHandler
public void shutdown()
public void socketClosedEvent(Exception e)
socketClosedEvent
in interface SocketNodeEventListener
e
- exception not used.public void setAdvertiseViaMulticastDNS(boolean advertiseViaMulticastDNS)
public boolean isAdvertiseViaMulticastDNS()
public void socketOpened(String remoteInfo)
socketOpened
in interface SocketNodeEventListener
remoteInfo
- remote info.Copyright © 2002-2017 Apache Software Foundation. All Rights Reserved.
Apache Logging, Apache Log4j, Log4j, Apache Chainsaw, Chainsaw, Apache, the Apache feather logo, the Apache Logging project logo, and the Apache Log4j logo are trademarks of The Apache Software Foundation.