cvs commit: jakarta-log4j/src/java/org/apache/log4j/plugins Receiver.java PluginSkeleton.java PluginRegistry.java Plugin.java
mwomack 2003/02/19 23:18:32 Modified:src/java/org/apache/log4j/plugins Receiver.java PluginSkeleton.java PluginRegistry.java Plugin.java Log: Jalopy-ized and checkstyle-d versions of the plugin files. Revision ChangesPath 1.3 +24 -23jakarta-log4j/src/java/org/apache/log4j/plugins/Receiver.java Index: Receiver.java === RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/plugins/Receiver.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- Receiver.java 3 Feb 2003 07:50:08 - 1.2 +++ Receiver.java 20 Feb 2003 07:18:32 - 1.3 @@ -4,41 +4,41 @@ * This software is published under the terms of the Apache Software * License version 1.1, a copy of which has been included with this * distribution in the LICENSE.txt file. */ - package org.apache.log4j.plugins; import org.apache.log4j.Logger; import org.apache.log4j.spi.LoggingEvent; + /** Defines the base class for Receiver plugins. - + Just as Appenders send logging events outside of the log4j environment (to files, to smtp, to sockets, etc), Receivers bring logging events inside the log4j environment. - + Receivers are meant to support the receiving of - remote logging events from another process. For example, - SocketAppender "appends" a logging event to a socket, configured - for a specific host and port number. On the receiving side of - the socket can be a SocketReceiver object. The SocketReceiver + remote logging events from another process. For example, + SocketAppender "appends" a logging event to a socket, configured + for a specific host and port number. On the receiving side of + the socket can be a SocketReceiver object. The SocketReceiver object receives the logging event, and then "posts" it to the - log4j environment (LoggerRepository) on the receiving machine, to - be handled by the configured appenders, etc. The various - settings in this environment (Logger levels, Appender filters & + log4j environment (LoggerRepository) on the receiving machine, to + be handled by the configured appenders, etc. The various + settings in this environment (Logger levels, Appender filters & thresholds) are applied to the received logging event. - + Receivers can also be used to "import" log messages from other logging packages into the log4j environment. - + Receivers can be configured to post events to a given LoggerRepository. - + Subclasses of Receiver must implement the isActive(), activateOptions(), and shutdown() methods. The doPost() method is provided to standardize the "import" of remote events into the repository. - + @author Mark Womack @author Ceki Gülcü @since 1.3 @@ -46,19 +46,20 @@ public abstract class Receiver extends PluginSkeleton { /** Posts the logging event to a logger in the configured logger -repository. */ +repository. + +@param event the log event to post to the local log4j environment. */ public void doPost(LoggingEvent event) { // get the "local" logger for this event from the // configured repository. - Logger localLogger = +Logger localLogger = 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())) { + +// 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())) { // call the loggers appenders to process the event - localLogger.callAppenders(event); - } + localLogger.callAppenders(event); +} } } - 1.4 +26 -17 jakarta-log4j/src/java/org/apache/log4j/plugins/PluginSkeleton.java Index: PluginSkeleton.java === RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/plugins/PluginSkeleton.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- PluginSkeleton.java 3 Feb 2003 07:50:08 - 1.3 +++ PluginSkeleton.java 20 Feb 2003 07:18:32 - 1.4 @@ -4,55 +4,64 @@ * This software is published under the terms of the Apache Software * License version 1.1, a copy of which has been included with this * distribution in the LICENSE.txt file. */ - package org.apache.log4j.plugins; -import org.apache.log4j.LogManager; import org.apache.log4j.spi.LoggerRepository; +
cvs commit: jakarta-log4j/src/java/org/apache/log4j/plugins Receiver.java PluginSkeleton.java PluginRegistry.java Plugin.java
mwomack 2003/02/02 23:50:09 Modified:src/java/org/apache/log4j/plugins Receiver.java PluginSkeleton.java PluginRegistry.java Plugin.java Log: Cleanup. Revision ChangesPath 1.2 +3 -7 jakarta-log4j/src/java/org/apache/log4j/plugins/Receiver.java Index: Receiver.java === RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/plugins/Receiver.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- Receiver.java 11 Dec 2002 07:25:14 - 1.1 +++ Receiver.java 3 Feb 2003 07:50:08 - 1.2 @@ -17,7 +17,7 @@ environment (to files, to smtp, to sockets, etc), Receivers bring logging events inside the log4j environment. - Receivers are primarily meant to support the receiving of + Receivers are meant to support the receiving of remote logging events from another process. For example, SocketAppender "appends" a logging event to a socket, configured for a specific host and port number. On the receiving side of @@ -32,9 +32,7 @@ logging packages into the log4j environment. Receivers can be configured to post events to a given - LoggerRepository. If a repository is not specified, then the - default repository value returned by - LogManager.getLoggerRepository() should be used. + LoggerRepository. Subclasses of Receiver must implement the isActive(), activateOptions(), and shutdown() methods. The doPost() method @@ -42,6 +40,7 @@ the repository. @author Mark Womack + @author Ceki Gülcü @since 1.3 */ public abstract class Receiver extends PluginSkeleton { @@ -57,9 +56,6 @@ // 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())) { - // set the logger for the event - // event.logger = localLogger; - // call the loggers appenders to process the event localLogger.callAppenders(event); } 1.3 +2 -4 jakarta-log4j/src/java/org/apache/log4j/plugins/PluginSkeleton.java Index: PluginSkeleton.java === RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/plugins/PluginSkeleton.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- PluginSkeleton.java 12 Dec 2002 07:50:05 - 1.2 +++ PluginSkeleton.java 3 Feb 2003 07:50:08 - 1.3 @@ -11,7 +11,7 @@ import org.apache.log4j.spi.LoggerRepository; /** - A convienent abstract class for receiver classes that implements + A convienent abstract class for plugin subclasses that implements the basic methods of the Plugin interface. Subclasses are required to implement the isActive(), activateOptions(), and shutdown() methods. @@ -43,9 +43,7 @@ } /** -Gets the logger repository for this plugin. If not -explicity set, returns the value of -LogManager.getLoggerRepository(). */ +Gets the logger repository for this plugin. */ public LoggerRepository getLoggerRepository() { return repository; } 1.3 +68 -29 jakarta-log4j/src/java/org/apache/log4j/plugins/PluginRegistry.java Index: PluginRegistry.java === RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/plugins/PluginRegistry.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- PluginRegistry.java 12 Dec 2002 07:52:41 - 1.2 +++ PluginRegistry.java 3 Feb 2003 07:50:08 - 1.3 @@ -22,11 +22,18 @@ @since 1.3 */ public class PluginRegistry { + /** stores the map of plugins for each repository. */ private static HashMap repositoryMap = new HashMap(); + + /** the listener used to listen for repository events. */ private static RepositoryListener listener = new RepositoryListener(); /** -Starts a Plugin with default logger repository. */ +Starts a Plugin with default logger repository. + +@param plugin the plugin to start. +@return Plugin the plugin parameter or a plugin that was already + active and was equal to the original plugin. */ public static Plugin startPlugin(Plugin plugin) { // if repository already set in plugin, use it LoggerRepository repository = plugin.getLoggerRepository(); @@ -40,18 +47,25 @@ } /** -Starts a plugin with a given logger repository. */ +Starts a plugin with a given logger repository. + +@param plugin the plugin to start. +@param repository the logger rep
cvs commit: jakarta-log4j/src/java/org/apache/log4j/plugins Receiver.java PluginSkeleton.java PluginRegistry.java Plugin.java
mwomack 2002/12/10 23:25:14 Added: src/java/org/apache/log4j/plugins Receiver.java PluginSkeleton.java PluginRegistry.java Plugin.java Log: Moved from o.a.log4j to o.a.log4j.plugins package. Fixed bug in PluginRegistry where stopped plugin was not removed from plugin map. Revision ChangesPath 1.1 jakarta-log4j/src/java/org/apache/log4j/plugins/Receiver.java Index: Receiver.java === /* * Copyright (C) The Apache Software Foundation. All rights reserved. * * This software is published under the terms of the Apache Software * License version 1.1, a copy of which has been included with this * distribution in the LICENSE.txt file. */ package org.apache.log4j.plugins; import org.apache.log4j.Logger; import org.apache.log4j.spi.LoggingEvent; /** Defines the base class for Receiver plugins. Just as Appenders send logging events outside of the log4j environment (to files, to smtp, to sockets, etc), Receivers bring logging events inside the log4j environment. Receivers are primarily meant to support the receiving of remote logging events from another process. For example, SocketAppender "appends" a logging event to a socket, configured for a specific host and port number. On the receiving side of the socket can be a SocketReceiver object. The SocketReceiver object receives the logging event, and then "posts" it to the log4j environment (LoggerRepository) on the receiving machine, to be handled by the configured appenders, etc. The various settings in this environment (Logger levels, Appender filters & thresholds) are applied to the received logging event. Receivers can also be used to "import" log messages from other logging packages into the log4j environment. Receivers can be configured to post events to a given LoggerRepository. If a repository is not specified, then the default repository value returned by LogManager.getLoggerRepository() should be used. Subclasses of Receiver must implement the isActive(), activateOptions(), and shutdown() methods. The doPost() method is provided to standardize the "import" of remote events into the repository. @author Mark Womack @since 1.3 */ public abstract class Receiver extends PluginSkeleton { /** Posts the logging event to a logger in the configured logger repository. */ public void doPost(LoggingEvent event) { // get the "local" logger for this event from the // configured repository. Logger localLogger = 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())) { // set the logger for the event // event.logger = localLogger; // call the loggers appenders to process the event localLogger.callAppenders(event); } } } 1.1 jakarta-log4j/src/java/org/apache/log4j/plugins/PluginSkeleton.java Index: PluginSkeleton.java === /* * Copyright (C) The Apache Software Foundation. All rights reserved. * * This software is published under the terms of the Apache Software * License version 1.1, a copy of which has been included with this * distribution in the LICENSE.txt file. */ package org.apache.log4j.plugins; import org.apache.log4j.LogManager; import org.apache.log4j.spi.LoggerRepository; /** A convienent abstract class for receiver classes that implements the basic methods of the Plugin interface. Subclasses are required to implement the isActive(), activateOptions(), and shutdown() methods. Developers are not required to subclass PluginSkeleton to develop their own plugins (they are only required to implement the Plugin interface), but it provides a convienent base class to start from. Contributors: Nicko Cadell @author Mark Womack @since 1.3 */ public abstract class PluginSkeleton implements Plugin { protected String name = ""; protected LoggerRepository repository; /** Gets the name of the plugin. */ public String getName() { return name; } /** Sets the name of the plugin. */ public void setName(String _name) { name = _name; } /** Gets the logger repository for this plugin. If not explicity set, returns the value of LogManager.getLoggerRepository(). */ public LoggerRepository getLoggerRepository() { if (repository != null) { return