org.apache.log4j.net
Class SocketReceiver
java.lang.Object
|
+--org.apache.log4j.spi.ComponentBase
|
+--org.apache.log4j.plugins.PluginSkeleton
|
+--org.apache.log4j.plugins.Receiver
|
+--org.apache.log4j.net.SocketReceiver
- All Implemented Interfaces:
- Component, NetworkBased, OptionHandler, Pauseable, Plugin, PortBased, Runnable, Thresholdable
- public class SocketReceiver
- extends Receiver
- implements Runnable, PortBased, Pauseable
SocketReceiver 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 SocketAppender 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.
- Since:
- 1.3
- Author:
- Mark Womack, Scott Deboy , Paul Smith
Field Summary |
protected int |
port
|
Method Summary |
void |
activateOptions()
Starts the SocketReceiver with the current options. |
void |
addSocketNodeEventListener(SocketNodeEventListener listener)
Adds the listener to the list of listeners to be notified of the
respective event |
void |
doPost(LoggingEvent event)
Posts the logging event to a logger in the configured logger
repository. |
Vector |
getConnectedSocketDetails()
Returns a Vector of SocketDetail representing the IP/Domain name
of the currently connected sockets that this receiver has
been responsible for creating. |
SocketNodeEventListener |
getListener()
Deprecated. This receiver now supports multiple listeners |
int |
getPort()
Get the port to receive logging events on. |
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. |
boolean |
isPaused()
|
void |
removeSocketNodeEventListener(SocketNodeEventListener listener)
Removes the registered Listener from this instances list of
listeners. |
void |
run()
Loop, accepting new socket connections. |
void |
setListener(SocketNodeEventListener listener)
Deprecated. This receiver now supports multiple listeners and
so this method simply removes the listener (if there already)
and readds it to the list.
The passed listener will also be returned via the getListener()
method still, but this is also deprecated |
void |
setPaused(boolean b)
|
void |
setPort(int _port)
Set the port to receive logging events on. |
void |
shutdown()
Called when the receiver should be stopped. |
Methods inherited from class org.apache.log4j.plugins.PluginSkeleton |
addPropertyChangeListener, addPropertyChangeListener, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getLoggerRepository, getName, isActive, removePropertyChangeListener, removePropertyChangeListener, setLoggerRepository, setName |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
port
protected int port
SocketReceiver
public SocketReceiver()
SocketReceiver
public SocketReceiver(int _port)
SocketReceiver
public SocketReceiver(int _port,
LoggerRepository _repository)
getPort
public int getPort()
- Get the port to receive logging events on.
- Specified by:
getPort
in interface PortBased
- Following copied from interface:
org.apache.log4j.net.PortBased
- Returns:
- int port number
setPort
public void setPort(int _port)
- Set the port to receive logging events on.
isEquivalent
public 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. This is used by PluginRegistry when determining
if the a similarly configured receiver is being started.
- Overrides:
isEquivalent
in class PluginSkeleton
- Parameters:
testPlugin
- The plugin to test equivalency against.- Returns:
- boolean True if the testPlugin is equivalent to this plugin.
activateOptions
public void activateOptions()
- Starts the SocketReceiver with the current options.
shutdown
public void shutdown()
- Called when the receiver should be stopped. Closes the
server socket and all of the open sockets.
run
public void run()
- Loop, accepting new socket connections.
- Specified by:
run
in interface Runnable
getConnectedSocketDetails
public Vector getConnectedSocketDetails()
- Returns a Vector of SocketDetail representing the IP/Domain name
of the currently connected sockets that this receiver has
been responsible for creating.
- Returns:
- Vector of SocketDetails
getListener
public SocketNodeEventListener getListener()
- Deprecated. This receiver now supports multiple listeners
- Returns the currently configured SocketNodeEventListener that
will be automatically set for each SocketNode created
- Returns:
- SocketNodeEventListener currently configured
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
setListener
public void setListener(SocketNodeEventListener listener)
- Deprecated. This receiver now supports multiple listeners and
so this method simply removes the listener (if there already)
and readds it to the list.
The passed listener will also be returned via the getListener()
method still, but this is also deprecated
- Sets the SocketNodeEventListener that will be used for each
created SocketNode
- Parameters:
listener
- the listener to set on each creation of a SocketNode
isPaused
public boolean isPaused()
- Specified by:
isPaused
in interface Pauseable
setPaused
public void setPaused(boolean b)
- Specified by:
setPaused
in interface Pauseable
doPost
public void doPost(LoggingEvent event)
- Description copied from class:
Receiver
- Posts the logging event to a logger in the configured logger
repository.
- Overrides:
doPost
in class Receiver
- Following copied from class:
org.apache.log4j.plugins.Receiver
- Parameters:
event
- the log event to post to the local log4j environment.
Copyright © 2000-2006 Apache Software Foundation.
Licensed under the Apache License, Version 2.0.