org.sblim.cimclient.internal.logging
Class LogAndTraceBroker

java.lang.Object
  extended by org.sblim.cimclient.internal.logging.LogAndTraceBroker

public class LogAndTraceBroker
extends java.lang.Object

Class LogAndTraceBroker is the central class that implements the logging and tracing of the CIM Client. It manages the collections of the internal log and trace listeners. It sets up the application independent logging. It provides the API to send log and trace messages and forwards them to the appropriate listeners.


Method Summary
 void addLogListener(LogListener pListener)
          Adds a listener for log messages.
 void addTraceListener(TraceListener pListener)
          Adds a listener for log messages.
 void clearLogListeners()
          Removes all listeners.
 void clearTraceListeners()
          Removes all listeners.
 void entry()
          Forwards a method entry message to the registered trace listeners.
 void exit()
          Forwards a method exit message to the registered trace listeners.
static LogAndTraceBroker getBroker()
          Returns the singleton instance of the broker
 java.util.List getLogListeners()
          Gets the registered log listeners including the internal console and file loggers.
 java.util.List getTraceListeners()
          Gets the registered trace listeners including the internal console and file loggers.
 java.io.OutputStream getXmlTraceStream()
          Returns the output stream to which all CIM-XML traffic (outgoing & incoming) will be copied for debugging purposes.
static boolean isLoggingStarted()
          Returns if the logging framework has been initialized.
 void message(java.lang.String pKey)
          Forwards a log/trace message to the registered log&trace listeners.
 void message(java.lang.String pKey, java.lang.Object pParameter)
          Forwards a log/trace message to the registered log&trace listeners.
 void message(java.lang.String pKey, java.lang.Object[] pParameters)
          Forwards a log/trace message to the registered log&trace listeners.
 void registerInternalListeners()
          Registers the listeners for our internal loggers
 void removeLogListener(LogListener pListener)
          Remove a listener.
 void removeTraceListener(TraceListener pListener)
          Removes a listener.
 void setXmlTraceStream(java.io.OutputStream pStream)
          Sets an output stream to which all CIM-XML traffic (outgoing & incoming) will be copied for debugging purposes.
 void trace(java.util.logging.Level pLevel, java.lang.String pMessage)
          Forwards a trace message to the registered trace listeners.
 void trace(java.util.logging.Level pLevel, java.lang.String pMessage, java.lang.Throwable pThrown)
          Forwards a trace message to the registered trace listeners.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getBroker

public static LogAndTraceBroker getBroker()
Returns the singleton instance of the broker

Returns:
The broker instance

isLoggingStarted

public static boolean isLoggingStarted()
Returns if the logging framework has been initialized. This method is used by the WBEMConfiguration class to determine if the logging is already up. The WBEMConfiguration is initialized before the logging, so methods in this class cannot assume the logging to be up and running.

Returns:
true if the logging is up, false otherwise

registerInternalListeners

public void registerInternalListeners()
Registers the listeners for our internal loggers


addLogListener

public void addLogListener(LogListener pListener)
Adds a listener for log messages. The listener will be notified of any log event. Uses copy on write to ensure concurrent read access.

Parameters:
pListener - The listener

removeLogListener

public void removeLogListener(LogListener pListener)
Remove a listener. This listener will not be notified of log events anymore.

Parameters:
pListener - The listener

clearLogListeners

public void clearLogListeners()
Removes all listeners. Caution this will also remove the internal console and file loggers.


getLogListeners

public java.util.List getLogListeners()
Gets the registered log listeners including the internal console and file loggers.

Returns:
The list of listeners

addTraceListener

public void addTraceListener(TraceListener pListener)
Adds a listener for log messages. The listener will be notified of any trace event.

Parameters:
pListener - The listener

removeTraceListener

public void removeTraceListener(TraceListener pListener)
Removes a listener. This listener will not be notified of trace events anymore.

Parameters:
pListener - The listener

clearTraceListeners

public void clearTraceListeners()
Removes all listeners. Caution this will also remove the internal trace file listener.


getTraceListeners

public java.util.List getTraceListeners()
Gets the registered trace listeners including the internal console and file loggers.

Returns:
A list of listeners

message

public void message(java.lang.String pKey)
Forwards a log/trace message to the registered log&trace listeners.

Parameters:
pKey - The message identifier.

message

public void message(java.lang.String pKey,
                    java.lang.Object pParameter)
Forwards a log/trace message to the registered log&trace listeners.

Parameters:
pKey - The message identifier.
pParameter - The parameter for the message

message

public void message(java.lang.String pKey,
                    java.lang.Object[] pParameters)
Forwards a log/trace message to the registered log&trace listeners.

Parameters:
pKey - The message identifier.
pParameters - The parameters for the message

trace

public void trace(java.util.logging.Level pLevel,
                  java.lang.String pMessage)
Forwards a trace message to the registered trace listeners.

Parameters:
pLevel - One of the three message level identifiers FINE, FINER and FINEST
pMessage - The message text

trace

public void trace(java.util.logging.Level pLevel,
                  java.lang.String pMessage,
                  java.lang.Throwable pThrown)
Forwards a trace message to the registered trace listeners.

Parameters:
pLevel - One of the three message level identifiers FINE, FINER and FINEST
pMessage - The message text
pThrown - The throwable associated with the message

entry

public void entry()
Forwards a method entry message to the registered trace listeners.


exit

public void exit()
Forwards a method exit message to the registered trace listeners.


getXmlTraceStream

public java.io.OutputStream getXmlTraceStream()
Returns the output stream to which all CIM-XML traffic (outgoing & incoming) will be copied for debugging purposes.

Returns:
The output stream. A null value means that CIM-XML debugging is disabled

setXmlTraceStream

public void setXmlTraceStream(java.io.OutputStream pStream)
Sets an output stream to which all CIM-XML traffic (outgoing & incoming) will be copied for debugging purposes.

Parameters:
pStream - The output stream. A null value means that CIM-XML debugging is disabled.


Copyright © 2005, 2009 IBM Corporation. All Rights Reserved.