http://git-wip-us.apache.org/repos/asf/logging-chainsaw/blob/96ebd9ad/src/main/java/org/apache/log4j/net/XMLSocketReceiver.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/log4j/net/XMLSocketReceiver.java b/src/main/java/org/apache/log4j/net/XMLSocketReceiver.java index 104b2f7..56f45f5 100644 --- a/src/main/java/org/apache/log4j/net/XMLSocketReceiver.java +++ b/src/main/java/org/apache/log4j/net/XMLSocketReceiver.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,299 +17,304 @@ package org.apache.log4j.net; -import java.net.ServerSocket; -import java.net.Socket; -import java.util.List; -import java.util.Vector; - import org.apache.log4j.plugins.Pauseable; import org.apache.log4j.plugins.Plugin; import org.apache.log4j.plugins.Receiver; import org.apache.log4j.spi.LoggerRepository; import org.apache.log4j.spi.LoggingEvent; +import java.net.ServerSocket; +import java.net.Socket; +import java.util.List; +import java.util.Vector; + /** - XMLSocketReceiver receives a remote logging event via XML on a configured - socket and "posts" it to a LoggerRepository as if the event were - generated locally. This class is designed to receive events from - the XMLSocketAppender class (or classes that send compatible events). - <p> - This receiver supports log files created using log4j's XMLLayout, as well as java.util.logging - XMLFormatter (via the org.apache.log4j.spi.Decoder interface). - <p> - By default, log4j's XMLLayout is supported (no need to specify a decoder in that case). - <p> - To configure this receiver to support java.util.logging's XMLFormatter, specify a 'decoder' param - of org.apache.log4j.xml.UtilLoggingXMLDecoder. - <p> - Once the event has been "posted", it will be handled by the - appenders currently configured in the LoggerRespository. - - @author Mark Womack - @author Scott Deboy <sde...@apache.org> - -*/ + * XMLSocketReceiver receives a remote logging event via XML on a configured + * socket and "posts" it to a LoggerRepository as if the event were + * generated locally. This class is designed to receive events from + * the XMLSocketAppender class (or classes that send compatible events). + * <p> + * This receiver supports log files created using log4j's XMLLayout, as well as java.util.logging + * XMLFormatter (via the org.apache.log4j.spi.Decoder interface). + * <p> + * By default, log4j's XMLLayout is supported (no need to specify a decoder in that case). + * <p> + * To configure this receiver to support java.util.logging's XMLFormatter, specify a 'decoder' param + * of org.apache.log4j.xml.UtilLoggingXMLDecoder. + * <p> + * Once the event has been "posted", it will be handled by the + * appenders currently configured in the LoggerRespository. + * + * @author Mark Womack + * @author Scott Deboy <sde...@apache.org> + */ public class XMLSocketReceiver extends Receiver implements Runnable, PortBased, Pauseable { - private boolean paused; - //default to log4j xml decoder - protected String decoder = "org.apache.log4j.xml.XMLDecoder"; - private ServerSocket serverSocket; - private List<Socket> socketList = new Vector<>(); - private Thread rThread; - public static final int DEFAULT_PORT = 4448; - protected int port = DEFAULT_PORT; - private boolean advertiseViaMulticastDNS; - private ZeroConfSupport zeroConf; - - /** - * The MulticastDNS zone advertised by an XMLSocketReceiver - */ - public static final String ZONE = "_log4j_xml_tcpaccept_receiver.local."; - - /* - * Log4j doesn't provide an XMLSocketAppender, but the MulticastDNS zone that should be advertised by one is: - * _log4j_xml_tcpconnect_appender.local. - */ - - public XMLSocketReceiver() { - } - - public XMLSocketReceiver(int _port) { - port = _port; - } - - public XMLSocketReceiver(int _port, LoggerRepository _repository) { - port = _port; - repository = _repository; - } - - /** - Get the port to receive logging events on. */ - public int getPort() { - return port; - } - - /** - Set the port to receive logging events on. */ - public void setPort(int _port) { - port = _port; - } - - public String getDecoder() { - return decoder; - } - - /** - *Specify the class name implementing org.apache.log4j.spi.Decoder that can process the file. - */ - public void setDecoder(String _decoder) { - decoder = _decoder; - } - - public boolean isPaused() { - return paused; - } - - public void setPaused(boolean b) { - paused = b; - } - - /** - * 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. - * - * @param testPlugin The plugin to test equivalency against. - * @return boolean True if the testPlugin is equivalent to this plugin. - */ - public boolean isEquivalent(Plugin testPlugin) { - if ((testPlugin != null) && testPlugin instanceof XMLSocketReceiver) { - XMLSocketReceiver sReceiver = (XMLSocketReceiver) testPlugin; - - return (port == sReceiver.getPort() && super.isEquivalent(testPlugin)); + private boolean paused; + //default to log4j xml decoder + protected String decoder = "org.apache.log4j.xml.XMLDecoder"; + private ServerSocket serverSocket; + private List<Socket> socketList = new Vector<>(); + private Thread rThread; + public static final int DEFAULT_PORT = 4448; + protected int port = DEFAULT_PORT; + private boolean advertiseViaMulticastDNS; + private ZeroConfSupport zeroConf; + + /** + * The MulticastDNS zone advertised by an XMLSocketReceiver + */ + public static final String ZONE = "_log4j_xml_tcpaccept_receiver.local."; + + /* + * Log4j doesn't provide an XMLSocketAppender, but the MulticastDNS zone that should be advertised by one is: + * _log4j_xml_tcpconnect_appender.local. + */ + + public XMLSocketReceiver() { + } + + public XMLSocketReceiver(int _port) { + port = _port; + } + + public XMLSocketReceiver(int _port, LoggerRepository _repository) { + port = _port; + repository = _repository; + } + + /** + * Get the port to receive logging events on. + */ + public int getPort() { + return port; + } + + /** + * Set the port to receive logging events on. + */ + public void setPort(int _port) { + port = _port; + } + + public String getDecoder() { + return decoder; + } + + /** + * Specify the class name implementing org.apache.log4j.spi.Decoder that can process the file. + */ + public void setDecoder(String _decoder) { + decoder = _decoder; + } + + public boolean isPaused() { + return paused; + } + + public void setPaused(boolean b) { + paused = b; + } + + /** + * 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. + * + * @param testPlugin The plugin to test equivalency against. + * @return boolean True if the testPlugin is equivalent to this plugin. + */ + public boolean isEquivalent(Plugin testPlugin) { + if ((testPlugin != null) && testPlugin instanceof XMLSocketReceiver) { + XMLSocketReceiver sReceiver = (XMLSocketReceiver) testPlugin; + + return (port == sReceiver.getPort() && super.isEquivalent(testPlugin)); + } + + return false; } - return false; - } - - public int hashCode() { - - int result = 37 * (repository != null? repository.hashCode():0); - result = result * 37 + port; - return (result * 37 + (getName() != null? getName().hashCode():0)); - } - - /** - Sets the flag to indicate if receiver is active or not. - @param b new value - */ - protected synchronized void setActive(final boolean b) { - active = b; - } - - /** - Starts the SocketReceiver with the current options. */ - public void activateOptions() { - if (!isActive()) { - rThread = new Thread(this); - rThread.setDaemon(true); - rThread.start(); - - if (advertiseViaMulticastDNS) { - zeroConf = new ZeroConfSupport(ZONE, port, getName()); - zeroConf.advertise(); - } - - active = true; + public int hashCode() { + + int result = 37 * (repository != null ? repository.hashCode() : 0); + result = result * 37 + port; + return (result * 37 + (getName() != null ? getName().hashCode() : 0)); } - } - - public void setAdvertiseViaMulticastDNS(boolean advertiseViaMulticastDNS) { - this.advertiseViaMulticastDNS = advertiseViaMulticastDNS; - } - - public boolean isAdvertiseViaMulticastDNS() { - return advertiseViaMulticastDNS; - } - - /** - Called when the receiver should be stopped. Closes the - server socket and all of the open sockets. */ - public synchronized void shutdown() { - // mark this as no longer running - active = false; - - if (rThread != null) { - rThread.interrupt(); - rThread = null; + + /** + * Sets the flag to indicate if receiver is active or not. + * + * @param b new value + */ + protected synchronized void setActive(final boolean b) { + active = b; + } + + /** + * Starts the SocketReceiver with the current options. + */ + public void activateOptions() { + if (!isActive()) { + rThread = new Thread(this); + rThread.setDaemon(true); + rThread.start(); + + if (advertiseViaMulticastDNS) { + zeroConf = new ZeroConfSupport(ZONE, port, getName()); + zeroConf.advertise(); + } + + active = true; + } + } + + public void setAdvertiseViaMulticastDNS(boolean advertiseViaMulticastDNS) { + this.advertiseViaMulticastDNS = advertiseViaMulticastDNS; + } + + public boolean isAdvertiseViaMulticastDNS() { + return advertiseViaMulticastDNS; + } + + /** + * Called when the receiver should be stopped. Closes the + * server socket and all of the open sockets. + */ + public synchronized void shutdown() { + // mark this as no longer running + active = false; + + if (rThread != null) { + rThread.interrupt(); + rThread = null; + } + doShutdown(); } - doShutdown(); - } /** * Does the actual shutting down by closing the server socket * and any connected sockets that have been created. */ private synchronized void doShutdown() { - active = false; + active = false; - getLogger().debug("{} doShutdown called", getName()); + getLogger().debug("{} doShutdown called", getName()); - // close the server socket - closeServerSocket(); + // close the server socket + closeServerSocket(); - // close all of the accepted sockets - closeAllAcceptedSockets(); + // close all of the accepted sockets + closeAllAcceptedSockets(); - if (advertiseViaMulticastDNS) { - zeroConf.unadvertise(); - } + if (advertiseViaMulticastDNS) { + zeroConf.unadvertise(); + } } /** - * Closes the server socket, if created. - */ - private void closeServerSocket() { - getLogger().debug("{} closing server socket", getName()); - - try { - if (serverSocket != null) { - serverSocket.close(); - } - } catch (Exception e) { - // ignore for now - } - - serverSocket = null; - } + * Closes the server socket, if created. + */ + private void closeServerSocket() { + getLogger().debug("{} closing server socket", getName()); + + try { + if (serverSocket != null) { + serverSocket.close(); + } + } catch (Exception e) { + // ignore for now + } + + serverSocket = null; + } /** - * Closes all the connected sockets in the List. - */ - private synchronized void closeAllAcceptedSockets() { - for (Object aSocketList : socketList) { - try { - ((Socket) aSocketList).close(); - } catch (Exception e) { - // ignore for now - } - } - - // clear member variables - socketList.clear(); - } - - /** - Loop, accepting new socket connections. */ - public void run() { - /** - * Ensure we start fresh. - */ - getLogger().debug("performing socket cleanup prior to entering loop for {}", name); - closeServerSocket(); - closeAllAcceptedSockets(); - getLogger().debug("socket cleanup complete for {}", name); - active = true; - - // start the server socket - try { - serverSocket = new ServerSocket(port); - } catch (Exception e) { - getLogger().error( - "error starting SocketReceiver (" + this.getName() - + "), receiver did not start", e); - active = false; - doShutdown(); - - return; + * Closes all the connected sockets in the List. + */ + private synchronized void closeAllAcceptedSockets() { + for (Object aSocketList : socketList) { + try { + ((Socket) aSocketList).close(); + } catch (Exception e) { + // ignore for now + } + } + + // clear member variables + socketList.clear(); } - Socket socket = null; + /** + * Loop, accepting new socket connections. + */ + public void run() { + /** + * Ensure we start fresh. + */ + getLogger().debug("performing socket cleanup prior to entering loop for {}", name); + closeServerSocket(); + closeAllAcceptedSockets(); + getLogger().debug("socket cleanup complete for {}", name); + active = true; + + // start the server socket + try { + serverSocket = new ServerSocket(port); + } catch (Exception e) { + getLogger().error( + "error starting SocketReceiver (" + this.getName() + + "), receiver did not start", e); + active = false; + doShutdown(); + + return; + } - try { - getLogger().debug("in run-about to enter while isactiveloop"); + Socket socket = null; - active = true; + try { + getLogger().debug("in run-about to enter while isactiveloop"); - while (!rThread.isInterrupted()) { - // if we have a socket, start watching it - if (socket != null) { - getLogger().debug("socket not null - creating and starting socketnode"); - socketList.add(socket); + active = true; - XMLSocketNode node = new XMLSocketNode(decoder, socket, this); - node.setLoggerRepository(this.repository); - new Thread(node).start(); - } + while (!rThread.isInterrupted()) { + // if we have a socket, start watching it + if (socket != null) { + getLogger().debug("socket not null - creating and starting socketnode"); + socketList.add(socket); + + XMLSocketNode node = new XMLSocketNode(decoder, socket, this); + node.setLoggerRepository(this.repository); + new Thread(node).start(); + } + + getLogger().debug("waiting to accept socket"); - getLogger().debug("waiting to accept socket"); - - // wait for a socket to open, then loop to start it - socket = serverSocket.accept(); - getLogger().debug("accepted socket"); - } - - // socket not watched because we a no longer running - // so close it now. - if (socket != null) { - socket.close(); - } - } catch (Exception e) { - getLogger().warn( - "socket server disconnected, stopping"); + // wait for a socket to open, then loop to start it + socket = serverSocket.accept(); + getLogger().debug("accepted socket"); + } + + // socket not watched because we a no longer running + // so close it now. + if (socket != null) { + socket.close(); + } + } catch (Exception e) { + getLogger().warn( + "socket server disconnected, stopping"); + } } - } - - /* (non-Javadoc) - * @see org.apache.log4j.plugins.Receiver#doPost(org.apache.log4j.spi.LoggingEvent) - */ - public void doPost(LoggingEvent event) { - if(!isPaused()){ - super.doPost(event); + + /* (non-Javadoc) + * @see org.apache.log4j.plugins.Receiver#doPost(org.apache.log4j.spi.LoggingEvent) + */ + public void doPost(LoggingEvent event) { + if (!isPaused()) { + super.doPost(event); + } } - } }
http://git-wip-us.apache.org/repos/asf/logging-chainsaw/blob/96ebd9ad/src/main/java/org/apache/log4j/plugins/Pauseable.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/log4j/plugins/Pauseable.java b/src/main/java/org/apache/log4j/plugins/Pauseable.java index 6268ba3..8158e40 100644 --- a/src/main/java/org/apache/log4j/plugins/Pauseable.java +++ b/src/main/java/org/apache/log4j/plugins/Pauseable.java @@ -22,18 +22,19 @@ package org.apache.log4j.plugins; * Instances of this interface can be paused, and resumed. * * @author Paul Smith (psm...@apache.org) - * */ public interface Pauseable { /** * Set paused state. + * * @param paused new value */ - void setPaused(boolean paused); + void setPaused(boolean paused); /** * Get paused state. + * * @return paused state. */ - boolean isPaused(); + boolean isPaused(); } http://git-wip-us.apache.org/repos/asf/logging-chainsaw/blob/96ebd9ad/src/main/java/org/apache/log4j/plugins/Plugin.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/log4j/plugins/Plugin.java b/src/main/java/org/apache/log4j/plugins/Plugin.java index ca54665..90df955 100644 --- a/src/main/java/org/apache/log4j/plugins/Plugin.java +++ b/src/main/java/org/apache/log4j/plugins/Plugin.java @@ -25,12 +25,12 @@ import java.beans.PropertyChangeListener; /** * Defines the required interface for all Plugin objects. - * + * <p> * <p>A plugin implements some specific functionality to extend * the log4j framework. Each plugin is associated with a specific * LoggerRepository, which it then uses/acts upon. The functionality * of the plugin is up to the developer.</p> - * + * <p> * <p>Examples of plugins are Receiver and Watchdog. Receiver plugins * allow for remote logging events to be received and processed by * a repository as if the event was sent locally. Watchdog plugins @@ -75,13 +75,12 @@ public interface Plugin extends OptionHandler { * Adds a PropertyChangeListener to this instance which is * notified only by changes of the property with name propertyName. * - * @param propertyName - * the name of the property in standard JavaBean syntax - * (e.g. for setName(), property="name") - * @param l listener + * @param propertyName the name of the property in standard JavaBean syntax + * (e.g. for setName(), property="name") + * @param l listener */ void addPropertyChangeListener( - String propertyName, PropertyChangeListener l); + String propertyName, PropertyChangeListener l); /** * Adds a PropertyChangeListener that will be notified of all property @@ -106,10 +105,10 @@ public interface Plugin extends OptionHandler { * of only a specific property change. * * @param propertyName property name, may not be null. - * @param l listener to be removed. + * @param l listener to be removed. */ void removePropertyChangeListener( - String propertyName, PropertyChangeListener l); + String propertyName, PropertyChangeListener l); /** * True if the plugin is active and running. @@ -121,14 +120,14 @@ public interface Plugin extends OptionHandler { /** * Returns true if the testPlugin is considered to be "equivalent" to the * this plugin. - * + * <p> * <p>The equivalency test is at the discretion of the plugin * implementation. The PluginRegistry will use this method when starting * new plugins to see if a given plugin is considered equivalent to an * already running plugin with the same name. If they are considered to * be equivalent, the currently running plugin will be left in place, and * the new plugin will not be started.</p> - * + * <p> * <p>It is possible to override the equals() method, however this has * more meaning than is required for this simple test and would also * require the overriding of the hashCode() method as well. All of this http://git-wip-us.apache.org/repos/asf/logging-chainsaw/blob/96ebd9ad/src/main/java/org/apache/log4j/plugins/PluginEvent.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/log4j/plugins/PluginEvent.java b/src/main/java/org/apache/log4j/plugins/PluginEvent.java index 1843034..d1928d6 100644 --- a/src/main/java/org/apache/log4j/plugins/PluginEvent.java +++ b/src/main/java/org/apache/log4j/plugins/PluginEvent.java @@ -43,5 +43,5 @@ public class PluginEvent extends EventObject { */ public Plugin getPlugin() { return (Plugin) getSource(); - } + } } http://git-wip-us.apache.org/repos/asf/logging-chainsaw/blob/96ebd9ad/src/main/java/org/apache/log4j/plugins/PluginListener.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/log4j/plugins/PluginListener.java b/src/main/java/org/apache/log4j/plugins/PluginListener.java index 11f628e..59a6a7e 100644 --- a/src/main/java/org/apache/log4j/plugins/PluginListener.java +++ b/src/main/java/org/apache/log4j/plugins/PluginListener.java @@ -31,13 +31,15 @@ import java.util.EventListener; public interface PluginListener extends EventListener { /** * Notification that plugin has started. + * * @param e event */ - void pluginStarted(PluginEvent e); + void pluginStarted(PluginEvent e); /** * Notification that plugin has stopped. + * * @param e event */ - void pluginStopped(PluginEvent e); + void pluginStopped(PluginEvent e); } http://git-wip-us.apache.org/repos/asf/logging-chainsaw/blob/96ebd9ad/src/main/java/org/apache/log4j/plugins/PluginRegistry.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/log4j/plugins/PluginRegistry.java b/src/main/java/org/apache/log4j/plugins/PluginRegistry.java index 72909c1..feaae6b 100644 --- a/src/main/java/org/apache/log4j/plugins/PluginRegistry.java +++ b/src/main/java/org/apache/log4j/plugins/PluginRegistry.java @@ -16,15 +16,11 @@ */ package org.apache.log4j.plugins; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - import org.apache.log4j.spi.LoggerRepository; -import org.apache.log4j.spi.LoggerRepositoryEx; import org.apache.log4j.spi.LoggerRepositoryEventListener; +import org.apache.log4j.spi.LoggerRepositoryEx; + +import java.util.*; /** @@ -54,10 +50,11 @@ public final class PluginRegistry { * List of listeners. */ private final List listenerList = - Collections.synchronizedList(new ArrayList()); + Collections.synchronizedList(new ArrayList()); /** * Creates a new instance. + * * @param repository logger repository. */ public PluginRegistry(final LoggerRepositoryEx repository) { @@ -69,6 +66,7 @@ public final class PluginRegistry { /** * Get logger repository. + * * @return logger repository. */ public LoggerRepositoryEx getLoggerRepository() { @@ -197,7 +195,7 @@ public final class PluginRegistry { * * @param pluginName the name of the plugin to stop. * @return Plugin the plugin, if stopped, or null if the - * the plugin was not found in the registry. + * the plugin was not found in the registry. */ public Plugin stopPlugin(final String pluginName) { synchronized (pluginMap) { @@ -277,7 +275,7 @@ public final class PluginRegistry { * @param repository the repository that was changed. */ public void configurationChangedEvent( - final LoggerRepository repository) { + final LoggerRepository repository) { // do nothing with this event } http://git-wip-us.apache.org/repos/asf/logging-chainsaw/blob/96ebd9ad/src/main/java/org/apache/log4j/plugins/PluginSkeleton.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/log4j/plugins/PluginSkeleton.java b/src/main/java/org/apache/log4j/plugins/PluginSkeleton.java index b4f49ee..50b0143 100644 --- a/src/main/java/org/apache/log4j/plugins/PluginSkeleton.java +++ b/src/main/java/org/apache/log4j/plugins/PluginSkeleton.java @@ -57,7 +57,7 @@ public abstract class PluginSkeleton extends ComponentBase implements Plugin { * support. */ private PropertyChangeSupport propertySupport = - new PropertyChangeSupport(this); + new PropertyChangeSupport(this); /** * Construct new instance. @@ -127,96 +127,104 @@ public abstract class PluginSkeleton extends ComponentBase implements Plugin { */ public boolean isEquivalent(final Plugin testPlugin) { return (repository == testPlugin.getLoggerRepository()) - && ((this.name == null && testPlugin.getName() == null) - || (this.name != null - && name.equals(testPlugin.getName()))) - && this.getClass().equals(testPlugin.getClass()); + && ((this.name == null && testPlugin.getName() == null) + || (this.name != null + && name.equals(testPlugin.getName()))) + && this.getClass().equals(testPlugin.getClass()); } /** * Add property change listener. + * * @param listener listener. */ public final void addPropertyChangeListener( - final PropertyChangeListener listener) { + final PropertyChangeListener listener) { propertySupport.addPropertyChangeListener(listener); } /** * Add property change listener for one property only. + * * @param propertyName property name. - * @param listener listener. + * @param listener listener. */ public final void addPropertyChangeListener( - final String propertyName, - final PropertyChangeListener listener) { + final String propertyName, + final PropertyChangeListener listener) { propertySupport.addPropertyChangeListener(propertyName, listener); } /** * Remove property change listener. + * * @param listener listener. */ public final void removePropertyChangeListener( - final PropertyChangeListener listener) { + final PropertyChangeListener listener) { propertySupport.removePropertyChangeListener(listener); } /** * Remove property change listener on a specific property. + * * @param propertyName property name. - * @param listener listener. + * @param listener listener. */ public final void removePropertyChangeListener( - final String propertyName, - final PropertyChangeListener listener) { + final String propertyName, + final PropertyChangeListener listener) { propertySupport.removePropertyChangeListener(propertyName, listener); } /** * Fire a property change event to appropriate listeners. + * * @param evt change event. */ protected final void firePropertyChange( - final PropertyChangeEvent evt) { + final PropertyChangeEvent evt) { propertySupport.firePropertyChange(evt); } /** * Fire property change event to appropriate listeners. + * * @param propertyName property name. - * @param oldValue old value. - * @param newValue new value. + * @param oldValue old value. + * @param newValue new value. */ protected final void firePropertyChange( - final String propertyName, - final boolean oldValue, - final boolean newValue) { + final String propertyName, + final boolean oldValue, + final boolean newValue) { propertySupport.firePropertyChange(propertyName, oldValue, newValue); } /** * Fire property change event to appropriate listeners. + * * @param propertyName property name. - * @param oldValue old value. - * @param newValue new value. + * @param oldValue old value. + * @param newValue new value. */ protected final void firePropertyChange( - final String propertyName, - final int oldValue, final int newValue) { + final String propertyName, + final int oldValue, final int newValue) { propertySupport.firePropertyChange(propertyName, oldValue, newValue); } /** * Fire property change event to appropriate listeners. + * * @param propertyName property name. - * @param oldValue old value. - * @param newValue new value. + * @param oldValue old value. + * @param newValue new value. */ protected final void firePropertyChange( - final String propertyName, - final Object oldValue, - final Object newValue) { + final String propertyName, + final Object oldValue, + final Object newValue) { propertySupport.firePropertyChange(propertyName, oldValue, newValue); } } http://git-wip-us.apache.org/repos/asf/logging-chainsaw/blob/96ebd9ad/src/main/java/org/apache/log4j/plugins/Receiver.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/log4j/plugins/Receiver.java b/src/main/java/org/apache/log4j/plugins/Receiver.java index 39c31e0..628e25f 100644 --- a/src/main/java/org/apache/log4j/plugins/Receiver.java +++ b/src/main/java/org/apache/log4j/plugins/Receiver.java @@ -96,11 +96,11 @@ public abstract class Receiver extends PluginSkeleton implements Thresholdable { * * @param level The level to test against the receiver threshold. * @return boolean True if level is equal or greater than the - * receiver threshold. + * receiver threshold. */ public boolean isAsSevereAsThreshold(final Level level) { return ((thresholdLevel == null) - || level.isGreaterOrEqual(thresholdLevel)); + || level.isGreaterOrEqual(thresholdLevel)); } /** @@ -118,14 +118,14 @@ public abstract class Receiver extends PluginSkeleton implements Thresholdable { // get the "local" logger for this event from the // configured repository. Logger localLogger = - getLoggerRepository().getLogger(event.getLoggerName()); + getLoggerRepository().getLogger(event.getLoggerName()); // if the logger level is greater or equal to the level // of the event, use the logger to append the event. if (event.getLevel() - .isGreaterOrEqual(localLogger.getEffectiveLevel())) { + .isGreaterOrEqual(localLogger.getEffectiveLevel())) { // call the loggers appenders to process the event localLogger.callAppenders(event); } - } + } } http://git-wip-us.apache.org/repos/asf/logging-chainsaw/blob/96ebd9ad/src/main/java/org/apache/log4j/rewrite/MapRewritePolicy.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/log4j/rewrite/MapRewritePolicy.java b/src/main/java/org/apache/log4j/rewrite/MapRewritePolicy.java index 415baf4..ad24277 100644 --- a/src/main/java/org/apache/log4j/rewrite/MapRewritePolicy.java +++ b/src/main/java/org/apache/log4j/rewrite/MapRewritePolicy.java @@ -16,12 +16,12 @@ */ package org.apache.log4j.rewrite; -import java.util.HashMap; -import java.util.Map; - import org.apache.log4j.Logger; import org.apache.log4j.spi.LoggingEvent; +import java.util.HashMap; +import java.util.Map; + /** * This policy rewrites events where the message of the * original event implementes java.util.Map. @@ -33,9 +33,9 @@ import org.apache.log4j.spi.LoggingEvent; * If both the original property set and the message map * contain the same entry, the value from the message map * will overwrite the original property set. - * + * <p> * The combination of the RewriteAppender and this policy - * performs the same actions as the MapFilter from log4j 1.3. + * performs the same actions as the MapFilter from log4j 1.3. */ public class MapRewritePolicy implements RewritePolicy { /** @@ -64,16 +64,16 @@ public class MapRewritePolicy implements RewritePolicy { } return new LoggingEvent( - source.getFQNOfLoggerClass(), - source.getLogger() != null ? source.getLogger(): Logger.getLogger(source.getLoggerName()), - source.getTimeStamp(), - source.getLevel(), - newMsg, - source.getThreadName(), - source.getThrowableInformation(), - source.getNDC(), - source.getLocationInformation(), - props); + source.getFQNOfLoggerClass(), + source.getLogger() != null ? source.getLogger() : Logger.getLogger(source.getLoggerName()), + source.getTimeStamp(), + source.getLevel(), + newMsg, + source.getThreadName(), + source.getThrowableInformation(), + source.getNDC(), + source.getLocationInformation(), + props); } else { return source; } http://git-wip-us.apache.org/repos/asf/logging-chainsaw/blob/96ebd9ad/src/main/java/org/apache/log4j/rewrite/PropertyRewritePolicy.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/log4j/rewrite/PropertyRewritePolicy.java b/src/main/java/org/apache/log4j/rewrite/PropertyRewritePolicy.java index 9cff769..065476e 100644 --- a/src/main/java/org/apache/log4j/rewrite/PropertyRewritePolicy.java +++ b/src/main/java/org/apache/log4j/rewrite/PropertyRewritePolicy.java @@ -16,33 +16,34 @@ */ package org.apache.log4j.rewrite; +import org.apache.log4j.Logger; +import org.apache.log4j.spi.LoggingEvent; + import java.util.Collections; import java.util.HashMap; import java.util.Map; import java.util.StringTokenizer; -import org.apache.log4j.Logger; -import org.apache.log4j.spi.LoggingEvent; - /** * This policy rewrites events by adding * a user-specified list of properties to the event. * Existing properties are not modified. - * + * <p> * The combination of the RewriteAppender and this policy * performs the same actions as the PropertyFilter from log4j 1.3. */ public class PropertyRewritePolicy implements RewritePolicy { private Map properties = Collections.EMPTY_MAP; + public PropertyRewritePolicy() { } /** * Set a string representing the property name/value pairs. - * + * <p> * Form: propname1=propvalue1,propname2=propvalue2 - * + * * @param props */ public void setProperties(String props) { @@ -52,7 +53,7 @@ public class PropertyRewritePolicy implements RewritePolicy { StringTokenizer entry = new StringTokenizer(pairs.nextToken(), "="); hashTable.put(entry.nextElement().toString().trim(), entry.nextElement().toString().trim()); } - synchronized(this) { + synchronized (this) { properties = hashTable; } } @@ -71,20 +72,19 @@ public class PropertyRewritePolicy implements RewritePolicy { } return new LoggingEvent( - source.getFQNOfLoggerClass(), - source.getLogger() != null ? source.getLogger(): Logger.getLogger(source.getLoggerName()), - source.getTimeStamp(), - source.getLevel(), - source.getMessage(), - source.getThreadName(), - source.getThrowableInformation(), - source.getNDC(), - source.getLocationInformation(), - rewriteProps); + source.getFQNOfLoggerClass(), + source.getLogger() != null ? source.getLogger() : Logger.getLogger(source.getLoggerName()), + source.getTimeStamp(), + source.getLevel(), + source.getMessage(), + source.getThreadName(), + source.getThrowableInformation(), + source.getNDC(), + source.getLocationInformation(), + rewriteProps); } return source; } - } http://git-wip-us.apache.org/repos/asf/logging-chainsaw/blob/96ebd9ad/src/main/java/org/apache/log4j/rewrite/ReflectionRewritePolicy.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/log4j/rewrite/ReflectionRewritePolicy.java b/src/main/java/org/apache/log4j/rewrite/ReflectionRewritePolicy.java index 57c746a..91d9a4d 100644 --- a/src/main/java/org/apache/log4j/rewrite/ReflectionRewritePolicy.java +++ b/src/main/java/org/apache/log4j/rewrite/ReflectionRewritePolicy.java @@ -16,15 +16,15 @@ */ package org.apache.log4j.rewrite; +import org.apache.log4j.Logger; +import org.apache.log4j.helpers.LogLog; +import org.apache.log4j.spi.LoggingEvent; + import java.beans.Introspector; import java.beans.PropertyDescriptor; import java.util.HashMap; import java.util.Map; -import org.apache.log4j.Logger; -import org.apache.log4j.helpers.LogLog; -import org.apache.log4j.spi.LoggingEvent; - /** * This policy rewrites events by evaluating any * JavaBean properties on the message object and adding them @@ -34,9 +34,9 @@ import org.apache.log4j.spi.LoggingEvent; * not be added to the event properties. Values from the * JavaBean properties will replace any existing property * with the same name. - * + * <p> * The combination of the RewriteAppender and this policy - * performs the same actions as the ReflectionFilter from log4j 1.3. + * performs the same actions as the ReflectionFilter from log4j 1.3. */ public class ReflectionRewritePolicy implements RewritePolicy { /** @@ -50,13 +50,13 @@ public class ReflectionRewritePolicy implements RewritePolicy { try { PropertyDescriptor[] props = Introspector.getBeanInfo( - msg.getClass(), Object.class).getPropertyDescriptors(); + msg.getClass(), Object.class).getPropertyDescriptors(); if (props.length > 0) { for (PropertyDescriptor prop : props) { try { Object propertyValue = - prop.getReadMethod().invoke(msg, - (Object[]) null); + prop.getReadMethod().invoke(msg, + (Object[]) null); if ("message".equalsIgnoreCase(prop.getName())) { newMsg = propertyValue; } else { @@ -64,20 +64,20 @@ public class ReflectionRewritePolicy implements RewritePolicy { } } catch (Exception e) { LogLog.warn("Unable to evaluate property " + - prop.getName(), e); + prop.getName(), e); } } return new LoggingEvent( - source.getFQNOfLoggerClass(), - source.getLogger() != null ? source.getLogger(): Logger.getLogger(source.getLoggerName()), - source.getTimeStamp(), - source.getLevel(), - newMsg, - source.getThreadName(), - source.getThrowableInformation(), - source.getNDC(), - source.getLocationInformation(), - rewriteProps); + source.getFQNOfLoggerClass(), + source.getLogger() != null ? source.getLogger() : Logger.getLogger(source.getLoggerName()), + source.getTimeStamp(), + source.getLevel(), + newMsg, + source.getThreadName(), + source.getThrowableInformation(), + source.getNDC(), + source.getLocationInformation(), + rewriteProps); } } catch (Exception e) { LogLog.warn("Unable to get property descriptors", e); http://git-wip-us.apache.org/repos/asf/logging-chainsaw/blob/96ebd9ad/src/main/java/org/apache/log4j/rewrite/RewriteAppender.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/log4j/rewrite/RewriteAppender.java b/src/main/java/org/apache/log4j/rewrite/RewriteAppender.java index 368ecf9..d09b2fc 100644 --- a/src/main/java/org/apache/log4j/rewrite/RewriteAppender.java +++ b/src/main/java/org/apache/log4j/rewrite/RewriteAppender.java @@ -31,13 +31,13 @@ import java.util.Properties; /** * This appender forwards a logging request to another * appender after possibly rewriting the logging event. - * + * <p> * This appender (with the appropriate policy) * replaces the MapFilter, PropertyFilter and ReflectionFilter * from log4j 1.3. */ public class RewriteAppender extends AppenderSkeleton - implements AppenderAttachable, UnrecognizedElementHandler { + implements AppenderAttachable, UnrecognizedElementHandler { /** * Rewrite policy. */ @@ -61,7 +61,7 @@ public class RewriteAppender extends AppenderSkeleton } if (rewritten != null) { synchronized (appenders) { - appenders.appendLoopOnAppenders(rewritten); + appenders.appendLoopOnAppenders(rewritten); } } } @@ -72,19 +72,20 @@ public class RewriteAppender extends AppenderSkeleton * @param newAppender appender to add, may not be null. */ public void addAppender(final Appender newAppender) { - synchronized (appenders) { - appenders.addAppender(newAppender); - } + synchronized (appenders) { + appenders.addAppender(newAppender); + } } /** * Get iterator over attached appenders. + * * @return iterator or null if no attached appenders. */ public Enumeration getAllAppenders() { - synchronized (appenders) { - return appenders.getAllAppenders(); - } + synchronized (appenders) { + return appenders.getAllAppenders(); + } } /** @@ -94,9 +95,9 @@ public class RewriteAppender extends AppenderSkeleton * @return matching appender or null. */ public Appender getAppender(final String name) { - synchronized (appenders) { - return appenders.getAppender(name); - } + synchronized (appenders) { + return appenders.getAppender(name); + } } @@ -105,76 +106,80 @@ public class RewriteAppender extends AppenderSkeleton * thread which will process all pending events before exiting. */ public void close() { - closed = true; - // - // close all attached appenders. - // - synchronized (appenders) { - Enumeration iter = appenders.getAllAppenders(); - - if (iter != null) { - while (iter.hasMoreElements()) { - Object next = iter.nextElement(); - - if (next instanceof Appender) { - ((Appender) next).close(); + closed = true; + // + // close all attached appenders. + // + synchronized (appenders) { + Enumeration iter = appenders.getAllAppenders(); + + if (iter != null) { + while (iter.hasMoreElements()) { + Object next = iter.nextElement(); + + if (next instanceof Appender) { + ((Appender) next).close(); + } + } } - } } - } } /** * Determines if specified appender is attached. + * * @param appender appender. * @return true if attached. */ public boolean isAttached(final Appender appender) { - synchronized (appenders) { - return appenders.isAttached(appender); - } + synchronized (appenders) { + return appenders.isAttached(appender); + } } /** * {@inheritDoc} */ public boolean requiresLayout() { - return false; + return false; } /** * Removes and closes all attached appenders. */ public void removeAllAppenders() { - synchronized (appenders) { - appenders.removeAllAppenders(); - } + synchronized (appenders) { + appenders.removeAllAppenders(); + } } /** * Removes an appender. + * * @param appender appender to remove. */ public void removeAppender(final Appender appender) { - synchronized (appenders) { - appenders.removeAppender(appender); - } + synchronized (appenders) { + appenders.removeAppender(appender); + } } /** * Remove appender by name. + * * @param name name. */ public void removeAppender(final String name) { - synchronized (appenders) { - appenders.removeAppender(name); - } + synchronized (appenders) { + appenders.removeAppender(name); + } } public void setRewritePolicy(final RewritePolicy rewritePolicy) { policy = rewritePolicy; } + /** * {@inheritDoc} */ @@ -183,8 +188,8 @@ public class RewriteAppender extends AppenderSkeleton final String nodeName = element.getNodeName(); if ("rewritePolicy".equals(nodeName)) { Object rewritePolicy = - org.apache.log4j.xml.DOMConfigurator.parseElement( - element, props, RewritePolicy.class); + org.apache.log4j.xml.DOMConfigurator.parseElement( + element, props, RewritePolicy.class); if (rewritePolicy != null) { if (rewritePolicy instanceof OptionHandler) { ((OptionHandler) rewritePolicy).activateOptions(); http://git-wip-us.apache.org/repos/asf/logging-chainsaw/blob/96ebd9ad/src/main/java/org/apache/log4j/rewrite/RewritePolicy.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/log4j/rewrite/RewritePolicy.java b/src/main/java/org/apache/log4j/rewrite/RewritePolicy.java index bb40507..c2a6dbb 100644 --- a/src/main/java/org/apache/log4j/rewrite/RewritePolicy.java +++ b/src/main/java/org/apache/log4j/rewrite/RewritePolicy.java @@ -3,21 +3,21 @@ package org.apache.log4j.rewrite; import org.apache.log4j.spi.LoggingEvent; /* -* Licensed to the Apache Software Foundation (ASF) under one or more -* contributor license agreements. See the NOTICE file distributed with -* this work for additional information regarding copyright ownership. -* The ASF licenses this file to You under the Apache License, Version 2.0 -* (the "License"); you may not use this file except in compliance with -* the License. You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /** * This interface is implemented to provide a rewrite @@ -29,8 +29,9 @@ import org.apache.log4j.spi.LoggingEvent; public interface RewritePolicy { /** * Rewrite a logging event. + * * @param source a logging event that may be returned or - * used to create a new logging event. + * used to create a new logging event. * @return a logging event or null to suppress processing. */ LoggingEvent rewrite(final LoggingEvent source); http://git-wip-us.apache.org/repos/asf/logging-chainsaw/blob/96ebd9ad/src/main/java/org/apache/log4j/scheduler/Scheduler.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/log4j/scheduler/Scheduler.java b/src/main/java/org/apache/log4j/scheduler/Scheduler.java index 92c5e3e..9a021f4 100644 --- a/src/main/java/org/apache/log4j/scheduler/Scheduler.java +++ b/src/main/java/org/apache/log4j/scheduler/Scheduler.java @@ -51,6 +51,7 @@ public class Scheduler extends Thread { /** * Find the index of a given job. + * * @param job job * @return -1 if the job could not be found. */ @@ -75,6 +76,7 @@ public class Scheduler extends Thread { /** * Delete the given job. + * * @param job job. * @return true if the job could be deleted, and * false if the job could not be found or if the Scheduler is about to @@ -107,7 +109,8 @@ public class Scheduler extends Thread { /** * Schedule a {@link Job} for execution at system time given by * the <code>desiredTime</code> parameter. - * @param job job to schedule. + * + * @param job job to schedule. * @param desiredTime desired time of execution. */ public synchronized void schedule(final Job job, @@ -121,9 +124,10 @@ public class Scheduler extends Thread { * <p></p> * The job will be rescheduled. It will execute with a frequency determined * by the period parameter. - * @param job job to schedule. + * + * @param job job to schedule. * @param desiredTime desired time of execution. - * @param period repeat period. + * @param period repeat period. */ public synchronized void schedule(final Job job, final long desiredTime, @@ -137,7 +141,8 @@ public class Scheduler extends Thread { * <p></p> * The method returns true if the period could be changed, and false * otherwise. - * @param job job. + * + * @param job job. * @param newPeriod new repeat period. * @return true if period could be changed. */ @@ -145,7 +150,7 @@ public class Scheduler extends Thread { final long newPeriod) { if (newPeriod <= 0) { throw new IllegalArgumentException( - "Period must be an integer langer than zero"); + "Period must be an integer langer than zero"); } int i = findIndex(job); @@ -160,6 +165,7 @@ public class Scheduler extends Thread { /** * Schedule a job. + * * @param newSJE new job entry. */ private synchronized void schedule(final ScheduledJobEntry newSJE) { @@ -224,6 +230,7 @@ public class Scheduler extends Thread { /** * We do not want a single failure to affect the whole scheduler. + * * @param job job to execute. */ void executeInABox(final Job job) { @@ -250,6 +257,7 @@ public class Scheduler extends Thread { /** * Wait for notification or time to elapse. + * * @param timeToLinger time to linger. */ void linger(final long timeToLinger) { @@ -279,7 +287,8 @@ public class Scheduler extends Thread { /** * Create new instance. - * @param job job + * + * @param job job * @param desiredTime desired time. */ ScheduledJobEntry(final Job job, final long desiredTime) { @@ -288,9 +297,10 @@ public class Scheduler extends Thread { /** * Create new instance. - * @param job job + * + * @param job job * @param desiredTime desired time - * @param period repeat period + * @param period repeat period */ ScheduledJobEntry(final Job job, final long desiredTime, http://git-wip-us.apache.org/repos/asf/logging-chainsaw/blob/96ebd9ad/src/main/java/org/apache/log4j/spi/ComponentBase.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/log4j/spi/ComponentBase.java b/src/main/java/org/apache/log4j/spi/ComponentBase.java index 77ba7cf..f69b223 100644 --- a/src/main/java/org/apache/log4j/spi/ComponentBase.java +++ b/src/main/java/org/apache/log4j/spi/ComponentBase.java @@ -16,8 +16,8 @@ */ package org.apache.log4j.spi; -import org.apache.log4j.ULogger; import org.apache.log4j.Logger; +import org.apache.log4j.ULogger; /** @@ -88,7 +88,7 @@ public class ComponentBase implements Component { * Return an instance specific logger to be used by the component itself. * This logger is not intended to be accessed by the end-user, hence the * protected keyword. - * + * <p> * <p>In case the repository for this component is not set, * this implementations returns a {@link SimpleULogger} instance. * @@ -121,6 +121,6 @@ public class ComponentBase implements Component { return NOPULogger.NOP_LOGGER; } else { return getLogger(); + } } - } } http://git-wip-us.apache.org/repos/asf/logging-chainsaw/blob/96ebd9ad/src/main/java/org/apache/log4j/spi/Decoder.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/log4j/spi/Decoder.java b/src/main/java/org/apache/log4j/spi/Decoder.java index c1096d0..6965105 100644 --- a/src/main/java/org/apache/log4j/spi/Decoder.java +++ b/src/main/java/org/apache/log4j/spi/Decoder.java @@ -19,45 +19,47 @@ package org.apache.log4j.spi; import java.io.IOException; - import java.net.URL; - import java.util.Map; import java.util.Vector; /** - * Allow LoggingEvents to be reconstructed from a different format + * Allow LoggingEvents to be reconstructed from a different format * (usually XML). * - * @author Scott Deboy (sde...@apache.org) + * @author Scott Deboy (sde...@apache.org) */ public interface Decoder { /** * Decode events from document. + * * @param document document to decode. * @return list of LoggingEvent instances. */ - Vector<LoggingEvent> decodeEvents(String document); + Vector<LoggingEvent> decodeEvents(String document); /** * Decode event from string. + * * @param event string representation of event * @return event */ - LoggingEvent decode(String event); + LoggingEvent decode(String event); /** * Decode event from document retreived from URL. + * * @param url url of document * @return list of LoggingEvent instances. * @throws IOException if IO error resolving document. */ - Vector<LoggingEvent> decode(URL url) throws IOException; + Vector<LoggingEvent> decode(URL url) throws IOException; /** * Sets additional properties. + * * @param additionalProperties map of additional properties. */ - void setAdditionalProperties(Map additionalProperties); + void setAdditionalProperties(Map additionalProperties); } http://git-wip-us.apache.org/repos/asf/logging-chainsaw/blob/96ebd9ad/src/main/java/org/apache/log4j/spi/ErrorItem.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/log4j/spi/ErrorItem.java b/src/main/java/org/apache/log4j/spi/ErrorItem.java index f6f3686..59dbafa 100644 --- a/src/main/java/org/apache/log4j/spi/ErrorItem.java +++ b/src/main/java/org/apache/log4j/spi/ErrorItem.java @@ -31,142 +31,154 @@ public class ErrorItem { /** * Message. */ - String message; + String message; /** * Column. */ - int colNumber = -1; + int colNumber = -1; /** * Line number. */ - int lineNumber = -1; + int lineNumber = -1; /** * Exception. */ - Throwable exception; + Throwable exception; /** * Create new instance. + * * @param message message - * @param e exception + * @param e exception */ - public ErrorItem(final String message, final Exception e) { - super(); - this.message = message; - exception = e; - } + public ErrorItem(final String message, final Exception e) { + super(); + this.message = message; + exception = e; + } /** * Creaet new instance. + * * @param message message. */ - public ErrorItem(final String message) { - this(message, null); - } + public ErrorItem(final String message) { + this(message, null); + } /** * Get column number. + * * @return column number. */ - public int getColNumber() { - return colNumber; - } + public int getColNumber() { + return colNumber; + } /** * Set column number. + * * @param colNumber new column number. */ - public void setColNumber(int colNumber) { - this.colNumber = colNumber; - } + public void setColNumber(int colNumber) { + this.colNumber = colNumber; + } /** * Get exception. + * * @return exception. */ - public Throwable getException() { - return exception; - } + public Throwable getException() { + return exception; + } /** * Set exception. + * * @param exception exception */ - public void setException(final Throwable exception) { - this.exception = exception; - } + public void setException(final Throwable exception) { + this.exception = exception; + } /** * Get line number. + * * @return line number. */ - public int getLineNumber() { - return lineNumber; - } + public int getLineNumber() { + return lineNumber; + } /** * Set line number. + * * @param lineNumber line number. */ - public void setLineNumber(final int lineNumber) { - this.lineNumber = lineNumber; - } + public void setLineNumber(final int lineNumber) { + this.lineNumber = lineNumber; + } /** * Get message. + * * @return message. */ - public String getMessage() { - return message; - } + public String getMessage() { + return message; + } /** * Set message. + * * @param message message. */ - public void setMessage(final String message) { - this.message = message; - } + public void setMessage(final String message) { + this.message = message; + } /** * String representation of ErrorItem. + * * @return string. */ - public String toString() { - String str = - "Reported error: \"" + message + "\""; - - if (lineNumber != -1) { - str += " at line " + lineNumber + " column " + colNumber; + public String toString() { + String str = + "Reported error: \"" + message + "\""; + + if (lineNumber != -1) { + str += " at line " + lineNumber + " column " + colNumber; + } + if (exception != null) { + str += (" with exception " + exception); + } + return str; } - if (exception != null) { - str += (" with exception " + exception); - } - return str; - } - - /** - * Dump the details of this ErrorItem to System.out. - */ - public void dump() { - dump(System.out); - } - - /** - * Dump the details of this ErrorItem on the specified {@link PrintStream}. - * @param ps print stream. - */ - public void dump(final PrintStream ps) { - String str = - "Reported error: \"" + message + "\""; - - if (lineNumber != -1) { - str += " at line " + lineNumber + " column " + colNumber; + + /** + * Dump the details of this ErrorItem to System.out. + */ + public void dump() { + dump(System.out); } - ps.println(str); - if (exception != null) { - exception.printStackTrace(ps); + /** + * Dump the details of this ErrorItem on the specified {@link PrintStream}. + * + * @param ps print stream. + */ + public void dump(final PrintStream ps) { + String str = + "Reported error: \"" + message + "\""; + + if (lineNumber != -1) { + str += " at line " + lineNumber + " column " + colNumber; + } + ps.println(str); + + if (exception != null) { + exception.printStackTrace(ps); + } } - } } http://git-wip-us.apache.org/repos/asf/logging-chainsaw/blob/96ebd9ad/src/main/java/org/apache/log4j/spi/Log4JULogger.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/log4j/spi/Log4JULogger.java b/src/main/java/org/apache/log4j/spi/Log4JULogger.java index 0540445..0a26550 100644 --- a/src/main/java/org/apache/log4j/spi/Log4JULogger.java +++ b/src/main/java/org/apache/log4j/spi/Log4JULogger.java @@ -16,10 +16,10 @@ */ package org.apache.log4j.spi; +import org.apache.log4j.Level; import org.apache.log4j.Logger; import org.apache.log4j.ULogger; import org.apache.log4j.helpers.MessageFormatter; -import org.apache.log4j.Level; /** @@ -66,7 +66,7 @@ public final class Log4JULogger implements ULogger { final Object param1) { if (logger.isDebugEnabled()) { logger.debug(MessageFormatter.format( - parameterizedMsg.toString(), param1)); + parameterizedMsg.toString(), param1)); } } @@ -78,7 +78,7 @@ public final class Log4JULogger implements ULogger { final Object param2) { if (logger.isDebugEnabled()) { logger.debug(MessageFormatter.format( - parameterizedMsg, param1, param2)); + parameterizedMsg, param1, param2)); } } @@ -113,7 +113,7 @@ public final class Log4JULogger implements ULogger { final Object param1) { if (logger.isInfoEnabled()) { logger.info(MessageFormatter.format( - parameterizedMsg.toString(), param1)); + parameterizedMsg.toString(), param1)); } } @@ -125,9 +125,9 @@ public final class Log4JULogger implements ULogger { final Object param2) { if (logger.isInfoEnabled()) { logger.info(MessageFormatter.format( - parameterizedMsg, - param1, - param2)); + parameterizedMsg, + param1, + param2)); } } @@ -159,7 +159,7 @@ public final class Log4JULogger implements ULogger { final Object param1) { if (logger.isEnabledFor(Level.WARN)) { logger.warn(MessageFormatter.format( - parameterizedMsg.toString(), param1)); + parameterizedMsg.toString(), param1)); } } @@ -171,7 +171,7 @@ public final class Log4JULogger implements ULogger { final Object param2) { if (logger.isEnabledFor(Level.WARN)) { logger.warn(MessageFormatter.format( - parameterizedMsg, param1, param2)); + parameterizedMsg, param1, param2)); } } @@ -203,7 +203,7 @@ public final class Log4JULogger implements ULogger { public void error(final Object parameterizedMsg, final Object param1) { if (logger.isEnabledFor(Level.ERROR)) { logger.error(MessageFormatter.format( - parameterizedMsg.toString(), param1)); + parameterizedMsg.toString(), param1)); } } @@ -215,7 +215,7 @@ public final class Log4JULogger implements ULogger { final Object param2) { if (logger.isEnabledFor(Level.ERROR)) { logger.error(MessageFormatter.format( - parameterizedMsg, param1, param2)); + parameterizedMsg, param1, param2)); } } http://git-wip-us.apache.org/repos/asf/logging-chainsaw/blob/96ebd9ad/src/main/java/org/apache/log4j/spi/LoggerEventListener.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/log4j/spi/LoggerEventListener.java b/src/main/java/org/apache/log4j/spi/LoggerEventListener.java index b39f728..0381894 100644 --- a/src/main/java/org/apache/log4j/spi/LoggerEventListener.java +++ b/src/main/java/org/apache/log4j/spi/LoggerEventListener.java @@ -22,38 +22,41 @@ import org.apache.log4j.Logger; /** - Interface used to listen for Logger related events such as - add/remove appender or changing levels. Clients register an instance of - the interface and the instance is called back when the various events occur. - - LoggerRepository provides methods for adding and removing - LoggerEventListener instances. - - When implementing the methods of this interface, it is useful to remember - that the Logger can access the repository using its getRepository() - method. - - @author Ceki Gülcü - @author Mark Womack -*/ + * Interface used to listen for Logger related events such as + * add/remove appender or changing levels. Clients register an instance of + * the interface and the instance is called back when the various events occur. + * <p> + * LoggerRepository provides methods for adding and removing + * LoggerEventListener instances. + * <p> + * When implementing the methods of this interface, it is useful to remember + * that the Logger can access the repository using its getRepository() + * method. + * + * @author Ceki Gülcü + * @author Mark Womack + */ public interface LoggerEventListener { - /** - Called when an appender is added to the logger. - - @param logger The logger to which the appender was added. - @param appender The appender added to the logger. */ - void appenderAddedEvent(Logger logger, Appender appender); - - /** - Called when an appender is removed from the logger. - - @param logger The logger from which the appender was removed. - @param appender The appender removed from the logger. */ - void appenderRemovedEvent(Logger logger, Appender appender); - - /** - Called when level changed on the logger. - - @param logger The logger that changed levels. */ - void levelChangedEvent(Logger logger); + /** + * Called when an appender is added to the logger. + * + * @param logger The logger to which the appender was added. + * @param appender The appender added to the logger. + */ + void appenderAddedEvent(Logger logger, Appender appender); + + /** + * Called when an appender is removed from the logger. + * + * @param logger The logger from which the appender was removed. + * @param appender The appender removed from the logger. + */ + void appenderRemovedEvent(Logger logger, Appender appender); + + /** + * Called when level changed on the logger. + * + * @param logger The logger that changed levels. + */ + void levelChangedEvent(Logger logger); } http://git-wip-us.apache.org/repos/asf/logging-chainsaw/blob/96ebd9ad/src/main/java/org/apache/log4j/spi/LoggerRepositoryEventListener.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/log4j/spi/LoggerRepositoryEventListener.java b/src/main/java/org/apache/log4j/spi/LoggerRepositoryEventListener.java index 773a497..71f528d 100644 --- a/src/main/java/org/apache/log4j/spi/LoggerRepositoryEventListener.java +++ b/src/main/java/org/apache/log4j/spi/LoggerRepositoryEventListener.java @@ -19,35 +19,38 @@ package org.apache.log4j.spi; /** - Interface used to listen for LoggerRepository related - events such as startup, reset, and shutdown. Clients register - an instance of the interface and the instance is called back - when the various events occur. - - LoggerRepository provides methods for adding and removing - LoggerRepositoryEventListener instances. - - @author Ceki Gülcü - @author Mark Womack -*/ + * Interface used to listen for LoggerRepository related + * events such as startup, reset, and shutdown. Clients register + * an instance of the interface and the instance is called back + * when the various events occur. + * <p> + * LoggerRepository provides methods for adding and removing + * LoggerRepositoryEventListener instances. + * + * @author Ceki Gülcü + * @author Mark Womack + */ public interface LoggerRepositoryEventListener { - /** - Called when the repository configuration is reset. - @param repository repository - */ - void configurationResetEvent(LoggerRepository repository); + /** + * Called when the repository configuration is reset. + * + * @param repository repository + */ + void configurationResetEvent(LoggerRepository repository); - /** - Called when the repository configuration is changed. - @param repository repository - */ - void configurationChangedEvent(LoggerRepository repository); + /** + * Called when the repository configuration is changed. + * + * @param repository repository + */ + void configurationChangedEvent(LoggerRepository repository); - /** - Called when the repository is shutdown. When this method is - invoked, the repository is still valid (ie it has not been - shutdown, but will be after this method returns). - @param repository repository. - */ - void shutdownEvent(LoggerRepository repository); + /** + * Called when the repository is shutdown. When this method is + * invoked, the repository is still valid (ie it has not been + * shutdown, but will be after this method returns). + * + * @param repository repository. + */ + void shutdownEvent(LoggerRepository repository); } http://git-wip-us.apache.org/repos/asf/logging-chainsaw/blob/96ebd9ad/src/main/java/org/apache/log4j/spi/LoggerRepositoryEx.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/log4j/spi/LoggerRepositoryEx.java b/src/main/java/org/apache/log4j/spi/LoggerRepositoryEx.java index ae30e4b..5967e21 100644 --- a/src/main/java/org/apache/log4j/spi/LoggerRepositoryEx.java +++ b/src/main/java/org/apache/log4j/spi/LoggerRepositoryEx.java @@ -28,171 +28,186 @@ import java.util.Map; /** - A <code>LoggerRepository</code> is used to create and retrieve - <code>Loggers</code>. The relation between loggers in a repository - depends on the repository but typically loggers are arranged in a - named hierarchy. - - <p>In addition to the creational methods, a - <code>LoggerRepository</code> can be queried for existing loggers, - can act as a point of registry for events related to loggers. - - @author Ceki Gülcü - @author Mark Womack - @author Curt Arnold - */ + * A <code>LoggerRepository</code> is used to create and retrieve + * <code>Loggers</code>. The relation between loggers in a repository + * depends on the repository but typically loggers are arranged in a + * named hierarchy. + * <p> + * <p>In addition to the creational methods, a + * <code>LoggerRepository</code> can be queried for existing loggers, + * can act as a point of registry for events related to loggers. + * + * @author Ceki Gülcü + * @author Mark Womack + * @author Curt Arnold + */ public interface LoggerRepositoryEx extends LoggerRepository { - /** - Add a {@link LoggerRepositoryEventListener} to the repository. The - listener will be called when repository events occur. - @param listener event listener, may not be null. - */ - void addLoggerRepositoryEventListener( - LoggerRepositoryEventListener listener); - - /** - Remove a {@link LoggerRepositoryEventListener} from the repository. - @param listener listener. - */ - void removeLoggerRepositoryEventListener( - LoggerRepositoryEventListener listener); - - /** - Add a {@link LoggerEventListener} to the repository. The listener - will be called when repository events occur. - @param listener listener, may not be null. - */ - void addLoggerEventListener(LoggerEventListener listener); - - /** - Remove a {@link LoggerEventListener} from the repository. - @param listener listener, may not be null. - */ - void removeLoggerEventListener(LoggerEventListener listener); - - /** - * Get the name of this logger repository. - * @return name, may not be null. - */ - String getName(); - - /** - * A logger repository is a named entity. - * @param repoName new name, may not be null. - */ - void setName(String repoName); - - /** - * Is the current configuration of the repository in its original (pristine) - * state? - * @return true if repository is in original state. - * - */ - boolean isPristine(); - - /** - * Set the pristine flag. - * @param state state - * @see #isPristine - */ - void setPristine(boolean state); - - /** - Requests that a appender removed event be sent to any registered - {@link LoggerEventListener}. - @param logger The logger from which the appender was removed. - @param appender The appender removed from the logger. - */ - void fireRemoveAppenderEvent(Category logger, Appender appender); - - /** - Requests that a level changed event be sent to any registered - {@link LoggerEventListener}. - @param logger The logger which changed levels. - */ - void fireLevelChangedEvent(Logger logger); - - /** - Requests that a configuration changed event be sent to any registered - {@link LoggerRepositoryEventListener}. - */ - void fireConfigurationChangedEvent(); - - /** - * Return the PluginRegisty for this LoggerRepository. - * @return plug in registry. - */ - PluginRegistry getPluginRegistry(); - - /** - * Return the {@link Scheduler} for this LoggerRepository. - * @return scheduler. - */ - Scheduler getScheduler(); - - /** - * Get the properties specific for this repository. - * @return property map. - */ - Map<String, String> getProperties(); - - /** - * Get the property of this repository. - * @param key property key. - * @return key value or null if not set. - */ - String getProperty(String key); - - /** - * Set a property of this repository. - * @param key key, may not be null. - * @param value new value, if null, property will be removed. - */ - void setProperty(String key, String value); - - /** - * Errors which cannot be logged, go to the error list. - * - * @return List - */ - List<ErrorItem> getErrorList(); - - /** - * Errors which cannot be logged, go to the error list. - * - * @param errorItem an ErrorItem to add to the error list - */ - void addErrorItem(ErrorItem errorItem); - - /** - * A LoggerRepository can also act as a store for various objects used - * by log4j components. - * - * @param key key, may not be null. - * @return The object stored under 'key'. - */ - Object getObject(String key); - - /** - * Store an object under 'key'. If no object can be found, null is returned. - * - * @param key key, may not be null. - * @param value value, may be null. - */ - void putObject(String key, Object value); - - /** - * Sets the logger factory used by LoggerRepository.getLogger(String). - * @param loggerFactory factory to use, may not be null - */ - void setLoggerFactory(LoggerFactory loggerFactory); - - /** - * Returns the logger factory used by - * LoggerRepository.getLogger(String). - * - * @return non-null factory - */ - LoggerFactory getLoggerFactory(); + /** + * Add a {@link LoggerRepositoryEventListener} to the repository. The + * listener will be called when repository events occur. + * + * @param listener event listener, may not be null. + */ + void addLoggerRepositoryEventListener( + LoggerRepositoryEventListener listener); + + /** + * Remove a {@link LoggerRepositoryEventListener} from the repository. + * + * @param listener listener. + */ + void removeLoggerRepositoryEventListener( + LoggerRepositoryEventListener listener); + + /** + * Add a {@link LoggerEventListener} to the repository. The listener + * will be called when repository events occur. + * + * @param listener listener, may not be null. + */ + void addLoggerEventListener(LoggerEventListener listener); + + /** + * Remove a {@link LoggerEventListener} from the repository. + * + * @param listener listener, may not be null. + */ + void removeLoggerEventListener(LoggerEventListener listener); + + /** + * Get the name of this logger repository. + * + * @return name, may not be null. + */ + String getName(); + + /** + * A logger repository is a named entity. + * + * @param repoName new name, may not be null. + */ + void setName(String repoName); + + /** + * Is the current configuration of the repository in its original (pristine) + * state? + * + * @return true if repository is in original state. + */ + boolean isPristine(); + + /** + * Set the pristine flag. + * + * @param state state + * @see #isPristine + */ + void setPristine(boolean state); + + /** + * Requests that a appender removed event be sent to any registered + * {@link LoggerEventListener}. + * + * @param logger The logger from which the appender was removed. + * @param appender The appender removed from the logger. + */ + void fireRemoveAppenderEvent(Category logger, Appender appender); + + /** + * Requests that a level changed event be sent to any registered + * {@link LoggerEventListener}. + * + * @param logger The logger which changed levels. + */ + void fireLevelChangedEvent(Logger logger); + + /** + * Requests that a configuration changed event be sent to any registered + * {@link LoggerRepositoryEventListener}. + */ + void fireConfigurationChangedEvent(); + + /** + * Return the PluginRegisty for this LoggerRepository. + * + * @return plug in registry. + */ + PluginRegistry getPluginRegistry(); + + /** + * Return the {@link Scheduler} for this LoggerRepository. + * + * @return scheduler. + */ + Scheduler getScheduler(); + + /** + * Get the properties specific for this repository. + * + * @return property map. + */ + Map<String, String> getProperties(); + + /** + * Get the property of this repository. + * + * @param key property key. + * @return key value or null if not set. + */ + String getProperty(String key); + + /** + * Set a property of this repository. + * + * @param key key, may not be null. + * @param value new value, if null, property will be removed. + */ + void setProperty(String key, String value); + + /** + * Errors which cannot be logged, go to the error list. + * + * @return List + */ + List<ErrorItem> getErrorList(); + + /** + * Errors which cannot be logged, go to the error list. + * + * @param errorItem an ErrorItem to add to the error list + */ + void addErrorItem(ErrorItem errorItem); + + /** + * A LoggerRepository can also act as a store for various objects used + * by log4j components. + * + * @param key key, may not be null. + * @return The object stored under 'key'. + */ + Object getObject(String key); + + /** + * Store an object under 'key'. If no object can be found, null is returned. + * + * @param key key, may not be null. + * @param value value, may be null. + */ + void putObject(String key, Object value); + + /** + * Sets the logger factory used by LoggerRepository.getLogger(String). + * + * @param loggerFactory factory to use, may not be null + */ + void setLoggerFactory(LoggerFactory loggerFactory); + + /** + * Returns the logger factory used by + * LoggerRepository.getLogger(String). + * + * @return non-null factory + */ + LoggerFactory getLoggerFactory(); } http://git-wip-us.apache.org/repos/asf/logging-chainsaw/blob/96ebd9ad/src/main/java/org/apache/log4j/spi/NOPULogger.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/log4j/spi/NOPULogger.java b/src/main/java/org/apache/log4j/spi/NOPULogger.java index 98fe537..8845966 100644 --- a/src/main/java/org/apache/log4j/spi/NOPULogger.java +++ b/src/main/java/org/apache/log4j/spi/NOPULogger.java @@ -41,6 +41,7 @@ public final class NOPULogger implements ULogger { /** * Get instance. + * * @param name logger name. * @return logger. */