activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r908987 - in /activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging: LogManager.cpp LogManager.h PropertiesChangeListener.h
Date Thu, 11 Feb 2010 14:23:24 GMT
Author: tabish
Date: Thu Feb 11 14:23:23 2010
New Revision: 908987

URL: http://svn.apache.org/viewvc?rev=908987&view=rev
Log:
Refine the API a bit and implement some more of the functionality.  Update the documentation
as well.

Modified:
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/LogManager.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/LogManager.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/PropertiesChangeListener.h

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/LogManager.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/LogManager.cpp?rev=908987&r1=908986&r2=908987&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/LogManager.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/LogManager.cpp Thu
Feb 11 14:23:23 2010
@@ -22,12 +22,14 @@
 #include <decaf/util/logging/Logger.h>
 #include <decaf/util/concurrent/Concurrent.h>
 #include <decaf/util/Config.h>
+#include <decaf/io/InputStream.h>
 
 #include <string>
 #include <algorithm>
 
 using namespace std;
 using namespace decaf;
+using namespace decaf::io;
 using namespace decaf::lang;
 using namespace decaf::lang::exceptions;
 using namespace decaf::util;
@@ -54,7 +56,6 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 LogManager::LogManager() {
-
     this->internal.reset( new LogManagerInternals() );
 }
 
@@ -93,6 +94,7 @@
     throw( decaf::lang::exceptions::NullPointerException,
            decaf::lang::exceptions::IllegalArgumentException ) {
 
+    return false;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -106,6 +108,11 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
+std::string LogManager::getProperty( const std::string& name ) {
+    return properties.getProperty( name );
+}
+
+////////////////////////////////////////////////////////////////////////////////
 LogManager& LogManager::getLogManager() {
 
     if( theManager == NULL ) {
@@ -129,3 +136,19 @@
     // Destroy the global LogManager
     delete theManager;
 }
+
+////////////////////////////////////////////////////////////////////////////////
+void LogManager::readConfiguration()
+    throw( decaf::io::IOException ) {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void LogManager::readConfiguration( decaf::io::InputStream* stream DECAF_UNUSED )
+    throw( decaf::io::IOException,
+           decaf::lang::exceptions::NullPointerException ) {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void LogManager::reset() {
+
+}

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/LogManager.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/LogManager.h?rev=908987&r1=908986&r2=908987&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/LogManager.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/LogManager.h Thu
Feb 11 14:23:23 2010
@@ -27,6 +27,7 @@
 #include <decaf/util/concurrent/Mutex.h>
 #include <decaf/util/Config.h>
 
+#include <decaf/io/IOException.h>
 #include <decaf/lang/exceptions/NullPointerException.h>
 #include <decaf/lang/exceptions/IllegalArgumentException.h>
 
@@ -34,6 +35,9 @@
 namespace lang{
     class Runtime;
 }
+namespace io{
+    class InputStream;
+}
 namespace util{
 namespace logging{
 
@@ -173,65 +177,117 @@
                    decaf::lang::exceptions::IllegalArgumentException );
 
         /**
+         * Retrieves or creates a new Logger using the name specified
+         * a new logger inherits the configuration of the logger's
+         * parent if there is no configuration data for the logger.
+         * @param name The name of the Logger.
+         */
+        Logger* getLogger( const std::string& name );
+
+        /**
+         * Gets a list of known Logger Names from this Manager, new loggers added
+         * while this method is in progress are not garunteed to be in the list.
+         *
+         * @param names
+         *      STL Vector to hold string logger names.
+         *
+         * @return names count of how many loggers were inserted.
+         */
+        int getLoggerNames( const std::vector<std::string>& names );
+
+        /**
          * Sets the Properties this LogManager should use to configure
          * its loggers.  Once set a properties change event is fired.
          * @param properties Pointer to read the configuration from
          */
-        virtual void setProperties( const util::Properties& properties );
+        void setProperties( const util::Properties& properties );
 
         /**
          * Gets a reference to the Logging Properties used by this
          * logger.
          * @returns The Logger Properties Pointer
          */
-        virtual const util::Properties& getProperties() const {
+        const util::Properties& getProperties() const {
             return properties;
         }
 
         /**
-         * Gets the value of a named property of this LogManager
-         * @param name of the Property to retrieve
+         * Gets the value of a named property of this LogManager.
+         *
+         * @param name
+         *      The name of the Property to retrieve.
+         *
          * @return the value of the property
          */
-        virtual std::string getProperty( const std::string& name ) {
-            return properties.getProperty( name );
-        }
+        std::string getProperty( const std::string& name );
 
         /**
          * Adds a change listener for LogManager Properties, adding the same
          * instance of a change event listener does nothing.
-         * @param listener a PropertyChangeListener
+         *
+         * @param listener
+         *      The PropertyChangeListener to add (can be NULL).
          */
-        virtual void addPropertyChangeListener(
-            PropertyChangeListener* listener );
+        void addPropertyChangeListener( PropertyChangeListener* listener );
 
         /**
-         * Removes a properties change listener from the LogManager.
-         * @param listener a PropertyChangeListener
+         * Removes a properties change listener from the LogManager, if the
+         * listener is not found of the param is NULL this method returns
+         * silently.
+         *
+         * @param listener
+         *      The PropertyChangeListener to remove from the listeners set.
          */
-        virtual void removePropertyChangeListener(
-            PropertyChangeListener* listener );
+        void removePropertyChangeListener( PropertyChangeListener* listener );
 
         /**
-         * Retrieves or creates a new Logger using the name specified
-         * a new logger inherits the configuration of the logger's
-         * parent if there is no configuration data for the logger.
-         * @param name The name of the Logger.
+         * Reinitialize the logging properties and reread the logging configuration.
+         *
+         * The same rules are used for locating the configuration properties as are used
at
+         * startup. So normally the logging properties will be re-read from the same file
+         * that was used at startup.
+         *
+         * Any log level definitions in the new configuration file will be applied using
+         * Logger.setLevel(), if the target Logger exists.
+         *
+         * A PropertyChangeEvent will be fired after the properties are read.
+         *
+         * @throws IOException if an I/O error occurs.
+         */
+        void readConfiguration() throw( decaf::io::IOException );
+
+        /**
+         * Reinitialize the logging properties and reread the logging configuration from
the
+         * given stream, which should be in decaf.util.Properties format. A PropertyChangeEvent
+         * will be fired after the properties are read.
+         *
+         * Any log level definitions in the new configuration file will be applied using
+         * Logger.setLevel(), if the target Logger exists.
+         *
+         * @param stream
+         *      The InputStream to read the Properties from.
+         *
+         * @throws NullPointerException if stream is NULL.
+         * @throws IOException if an I/O error occurs.
          */
-        virtual Logger* getLogger( const std::string& name );
+        void readConfiguration( decaf::io::InputStream* stream )
+            throw( decaf::io::IOException,
+                   decaf::lang::exceptions::NullPointerException );
 
         /**
-         * Gets a list of known Logger Names from this Manager
-         * @param names STL Vector to hold string logger names
-         * @return names count of how many loggers were inserted
+         * Reset the logging configuration.
+         *
+         * For all named loggers, the reset operation removes and closes all Handlers and
+         * (except for the root logger) sets the level to INHERIT. The root logger's level
+         * is set to Level::INFO.
          */
-        virtual int getLoggerNames( const std::vector<std::string>& names );
+        void reset();
 
     public:     // Static Singleton Methods.
 
         /**
          * Get the global {@code LogManager} instance.
-         * @return A reference to the global LogManager instaince.
+         * @return A reference to the global LogManager instance.
          */
         static LogManager& getLogManager();
 

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/PropertiesChangeListener.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/PropertiesChangeListener.h?rev=908987&r1=908986&r2=908987&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/PropertiesChangeListener.h
(original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/PropertiesChangeListener.h
Thu Feb 11 14:23:23 2010
@@ -23,25 +23,38 @@
 namespace util{
 namespace logging{
 
-   /**
-    * Defines the interface that classes can use to listen for change
-    * events on Properties.
-    */
-   class DECAF_API PropertiesChangeListener
-   {
-   public:
-
-      virtual ~PropertiesChangeListener() {}
-
-      /**
-       * Change Event, called when a property is changed
-       * @param name - Name of the Property
-       * @param oldValue - Old Value of the Property
-       * @param newValue - New Value of the Property
-       */
-      virtual void onPropertyChanged( const std::string& name,
-                                      const std::string& oldValue,
-                                      const std::string& newValue ) = 0;
+    /**
+     * Defines the interface that classes can use to listen for change
+     * events on Properties.
+     *
+     * @since 1.0
+     */
+    class DECAF_API PropertiesChangeListener {
+    public:
+
+        virtual ~PropertiesChangeListener() {}
+
+        /**
+         * Indicates that the Properties have all been reset and should be
+         * considered to be back to their default values.
+         */
+        virtual void onPropertiesReset() = 0;
+
+        /**
+         * Change Event, called when a property is changed, includes the
+         * name of the property that was changed along with it old and
+         * new values.
+         *
+         * @param name
+         *      The name of the Property that changed.
+         * @param oldValue
+         *      The old Value of the Property.
+         * @param newValue
+         *      The new Value of the Property.
+         */
+        virtual void onPropertyChanged( const std::string& name,
+                                        const std::string& oldValue,
+                                        const std::string& newValue ) = 0;
 
    };
 



Mime
View raw message