org.sblim.cimclient.internal.logging

Class 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
voidaddLogListener(LogListener pListener)
Adds a listener for log messages.
voidaddTraceListener(TraceListener pListener)
Adds a listener for log messages.
voidclearLogListeners()
Removes all listeners.
voidclearTraceListeners()
Removes all listeners.
voidentry()
Forwards a method entry message to the registered trace listeners.
voidexit()
Forwards a method exit message to the registered trace listeners.
static LogAndTraceBrokergetBroker()
Returns the singleton instance of the broker
ListgetLogListeners()
Gets the registered log listeners including the internal console and file loggers.
ListgetTraceListeners()
Gets the registered trace listeners including the internal console and file loggers.
OutputStreamgetXmlTraceStream()
Returns the output stream to which all CIM-XML traffic (outgoing & incoming) will be copied for debugging purposes.
static booleanisLoggingStarted()
Returns if the logging framework has been initialized.
voidmessage(String pKey)
Forwards a log/trace message to the registered log&trace listeners.
voidmessage(String pKey, Object pParameter)
Forwards a log/trace message to the registered log&trace listeners.
voidmessage(String pKey, Object[] pParameters)
Forwards a log/trace message to the registered log&trace listeners.
voidregisterInternalListeners()
Registers the listeners for our internal loggers
voidremoveLogListener(LogListener pListener)
Remove a listener.
voidremoveTraceListener(TraceListener pListener)
Removes a listener.
voidsetXmlTraceStream(OutputStream pStream)
Sets an output stream to which all CIM-XML traffic (outgoing & incoming) will be copied for debugging purposes.
voidtrace(Level pLevel, String pMessage)
Forwards a trace message to the registered trace listeners.
voidtrace(Level pLevel, String pMessage, Throwable pThrown)
Forwards a trace message to the registered trace listeners.

Method Detail

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

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

clearLogListeners

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

clearTraceListeners

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

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.

getBroker

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

Returns: The broker instance

getLogListeners

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

Returns: The list of listeners

getTraceListeners

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

Returns: A list of 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

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

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

registerInternalListeners

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

removeLogListener

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

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

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.

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

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