org.sblim.cimclient.internal.logging
Class LogAndTraceBroker

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

public class LogAndTraceBroker
extends 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 addCIMXMLTraceListener(CIMXMLTraceListener pListener)
          Adds a listener for CIM-XML trace messages.
 void addLogListener(LogListener pListener)
          Adds a listener for log messages.
 void addTraceListener(TraceListener pListener)
          Adds a listener for log messages.
 void clearCIMXMLTraceListeners()
          Removes all CIM-XML trace listeners.
 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
 List<CIMXMLTraceListener> getCIMXMLTraceListeners()
          Gets the registered CIM-XML trace listeners.
 List<LogListener> getLogListeners()
          Gets the registered log listeners including the internal console and file loggers.
 List<TraceListener> getTraceListeners()
          Gets the registered trace listeners including the internal console and file loggers.
 OutputStream getXmlTraceStream()
          Returns the output stream to which all CIM-XML traffic (outgoing & incoming) will be copied for debugging purposes.
 boolean isLoggableCIMXMLTrace(Level pLevel)
          Checks whether there are CIM-XML trace listeners installed that will log a CIM-XML trace message.
 boolean isLoggableMessage(Level pLevel)
          Checks whether there are log listeners installed that will log a message with the specified level.
 boolean isLoggableTrace(Level pLevel)
          Checks whether there are trace listeners installed that will log a trace message with the specified level.
static boolean isLoggingStarted()
          Returns if the logging framework has been initialized.
 void message(String pKey)
          Forwards a log/trace message to the registered log&trace listeners.
 void message(String pKey, Object pParameter)
          Forwards a log/trace message to the registered log&trace listeners.
 void message(String pKey, Object[] pParameters)
          Forwards a log/trace message to the registered log&trace listeners.
 void registerInternalListeners()
          Registers the listeners for our internal loggers
 void removeCIMXMLTraceListener(CIMXMLTraceListener pListener)
          Removes a CIM-XML trace listener.
 void removeLogListener(LogListener pListener)
          Remove a listener.
 void removeTraceListener(TraceListener pListener)
          Removes a listener.
 void setXmlTraceStream(OutputStream pStream)
          Sets an output stream to which all CIM-XML traffic (outgoing & incoming) will be copied for debugging purposes.
 void trace(Level pLevel, String pMessage)
          Forwards a trace message to the registered trace listeners.
 void trace(Level pLevel, String pMessage, Throwable pThrown)
          Forwards a trace message to the registered trace listeners.
 void traceCIMXML(Level pLevel, String pMessage, boolean pOutgoing)
          Forwards a CIM-XML trace message to the registered CIM-XML 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 List<LogListener> 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 List<TraceListener> getTraceListeners()
Gets the registered trace listeners including the internal console and file loggers.

Returns:
A list of listeners

addCIMXMLTraceListener

public void addCIMXMLTraceListener(CIMXMLTraceListener pListener)
Adds a listener for CIM-XML trace messages. The listener will be notified of any CIM-XML trace event.

Parameters:
pListener - The listener

removeCIMXMLTraceListener

public void removeCIMXMLTraceListener(CIMXMLTraceListener pListener)
Removes a CIM-XML trace listener. This listener will not be notified of CIM-XML trace events anymore.

Parameters:
pListener - The listener

clearCIMXMLTraceListeners

public void clearCIMXMLTraceListeners()
Removes all CIM-XML trace listeners.


getCIMXMLTraceListeners

public List<CIMXMLTraceListener> getCIMXMLTraceListeners()
Gets the registered CIM-XML trace listeners.

Returns:
A list of listeners

message

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

Parameters:
pKey - The message identifier.

message

public void message(String pKey,
                    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(String pKey,
                    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(Level pLevel,
                  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(Level pLevel,
                  String pMessage,
                  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

traceCIMXML

public void traceCIMXML(Level pLevel,
                        String pMessage,
                        boolean pOutgoing)
Forwards a CIM-XML trace message to the registered CIM-XML trace listeners.

Parameters:
pLevel - One of the message level identifiers, e.g. FINE
pMessage - The CIM-XML message text
pOutgoing - true if CIM-XML is outgoing (being sent from client to server), false if CIM-XML is incoming (being sent from server to client)

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 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(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.

isLoggableTrace

public boolean isLoggableTrace(Level pLevel)
Checks whether there are trace listeners installed that will log a trace message with the specified level. Use this method to determine if a trace() method call could result in logging before preparing the information to be logged. For example:
     if (logger.isLoggableTrace(Level.WARNING) {
         // Prepare info for logging
         logger.trace(Level.WARNING, ...
 

Parameters:
pLevel - The Level of the trace message.
Returns:
true if trace message could be logged, false otherwise.

isLoggableMessage

public boolean isLoggableMessage(Level pLevel)
Checks whether there are log listeners installed that will log a message with the specified level. Use this method to determine if a message() method call could result in logging before preparing the information to be logged. For example:
     if (logger.isLoggableMessage(Level.WARNING) {
         // Prepare info for logging
         logger.message(Level.WARNING, ...
 

Parameters:
pLevel - The Level of the message.
Returns:
true if message could be logged, false otherwise.

isLoggableCIMXMLTrace

public boolean isLoggableCIMXMLTrace(Level pLevel)
Checks whether there are CIM-XML trace listeners installed that will log a CIM-XML trace message. Use this method to determine if a trace() method call could result in logging before preparing the information to be logged. For example:
     if (logger.isLoggableCIMXMLTrace(Level.FINEST) {
         // Prepare info for logging
         logger.traceCIMXML(Level.FINEST, ...
 

Parameters:
pLevel - The Level of the trace message.
Returns:
true if CIM-XML trace message could be logged, false otherwise.


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