soap tutorial

adriani.jws.template.util
Class WSLogger

java.lang.Object
  extended by adriani.jws.template.util.WSLogger

public class WSLogger
extends java.lang.Object

This class has two different purposes: static factory and logger instance.

All the static attributes and methods written here are used to implement a factory which creates WSLogger single objects, used by all the other classes to write message on the logging system. This section contains:

Using the Factory, any other class can retrieve a WSLogger instance, which is a wrapper for the actual logger being used (JAVA or LOG4J). The logger instance offers:

Class attributes: one of the available logging objects (Java logging or Log4j).
Methods: the standard logging interface (logInfo, logWarning, logSevere, isInfoEnabled).


Field Summary
protected static LoggerManager benchLogger
          Reference to the static benchLogger created at the first service invocation.
protected  java.util.logging.Logger javaLogger
          Instance reference to the logger written using the POJO approach.
protected static java.lang.String leadingName
          Beginning of each logging message produced by this class.
protected static LoggerManager loggerManager
          Reference to the static loggerManager created at the first service invocation.
protected static java.lang.String logPath
          The logger path loaded from the configuration file for the current runtime environment.
protected static WSLogger myLogger
          The logger instance to be used for this class (static).
protected static boolean ready
          The boolean flag depicting if this class has already been initialized.
protected static int rotate
          The logger rotation time suggested loaded from the configuration file.
protected  org.apache.log4j.Logger smartLogger
          Instance reference to the logger object relying on the Log4j mechanism.
protected static boolean verbose
          The boolean flag selecting the level on details message on STDOUT.
 
Constructor Summary
WSLogger(java.lang.String name)
          The input name parameter is used only if the logging mechanism relies on the LOG4J library.
 
Method Summary
static void closeBenchmark()
          Closes the Benchmark logger
 void finalize()
          Method useful for debug and testing, the verify the scope of the various logger instances.
 void flushLogger(java.util.logging.Logger logger)
          Flush the Handler bound to the given Logger.
static LoggerManager getBenchmarkLogger()
          Return current implementation of the LoggerManager object, which is responsible for creating and initializing the benchmark optional feature.
static WSLogger getLogger(java.lang.Class caller)
          The main static factory to be used by all other classes to ask and obtain a WSLogger instance.
static LoggerManager getLoggerManager()
          Return current implementation of the LoggerManager object, which is responsible for creating and initializing the log mechanism.
 java.lang.String getParentDir()
          Return the parentDir path used as base directory to locate the log file.
 java.lang.String getRotationTime()
          Return the rotation time set for this logger, already formatted and ready to print.
static void initBenchmark()
          Initializes the Benchmark logger, allowing to measure execution time of each single SQL statement.
static void initialize()
          Loads the logging parameters from the configuration.properties file, then creates the required logger object, i.e. one subclass of the LoggerManager interface:

If logger.type = LOG4J the logger will be a ExternalLogger instance.
 boolean isInfoEnabled()
          Improves performances by avoiding to evaluate the concatened string message when the log call will not be executed (because not enabled for logger current level).
static boolean isReady()
          Factory accessor method.
 void logInfo(java.lang.String msg)
          Log an INFO message on the default Logger and flush the relative Handler.
 void logSevere(java.lang.String msg)
          Log a SEVERE message on the default Logger and flush the relative Handler.
 void logWarning(java.lang.String msg)
          Log a WARNING message on the default Logger and flush the relative Handler.
static java.lang.String printObject(java.lang.Object object)
          Print the serialize reference number of the input object.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

loggerManager

protected static LoggerManager loggerManager
Reference to the static loggerManager created at the first service invocation. This object MUST BE static to ensure that all the subclasses of the GeneralService class do refer to the same loggerManager object. Depending by the service configuration, the loggerManager can be a SystemLogger (pure Java logger) or an ExternalLogger (Log4j logger).


benchLogger

protected static LoggerManager benchLogger
Reference to the static benchLogger created at the first service invocation. This object MUST BE static for the same reason of the loggerManager object.
The benchLogger logs on file detailed information about the single SQL queries, this is different from the serviceAnalyzer object, which collects global and statistical data.

Remark: this logger is always an instance of the SystemLogger class.


logPath

protected static java.lang.String logPath
The logger path loaded from the configuration file for the current runtime environment.


rotate

protected static int rotate
The logger rotation time suggested loaded from the configuration file.


ready

protected static boolean ready
The boolean flag depicting if this class has already been initialized.


verbose

protected static boolean verbose
The boolean flag selecting the level on details message on STDOUT. We use this flag, and not the Settings.VERBOSE flag because we want to keep separated the verbosity of the business logic from the verbosity of the logger system itself.


smartLogger

protected org.apache.log4j.Logger smartLogger
Instance reference to the logger object relying on the Log4j mechanism.


javaLogger

protected java.util.logging.Logger javaLogger
Instance reference to the logger written using the POJO approach.


leadingName

protected static java.lang.String leadingName
Beginning of each logging message produced by this class.


myLogger

protected static WSLogger myLogger
The logger instance to be used for this class (static).

Constructor Detail

WSLogger

public WSLogger(java.lang.String name)
The input name parameter is used only if the logging mechanism relies on the LOG4J library. Otherwise, if the JAVA logging system is used, all the logger instances will share the same logic name (defined by the Settings.LOGGER field).

Parameters:
name - the logic name to be used for the LOG4J logger object
See Also:
Settings
Method Detail

finalize

public void finalize()
Method useful for debug and testing, the verify the scope of the various logger instances.

Overrides:
finalize in class java.lang.Object

initialize

public static void initialize()
Loads the logging parameters from the configuration.properties file, then creates the required logger object, i.e. one subclass of the LoggerManager interface:

If logger.type = LOG4J the logger will be a ExternalLogger instance.
If logger.type = JAVA the logger will be a SystemLogger instance.


getLogger

public static WSLogger getLogger(java.lang.Class caller)
The main static factory to be used by all other classes to ask and obtain a WSLogger instance. Remember that a WSLogger instance MUST NOT be used to invoke the initialize() and getLogger() methods.
Instead, a single WSLogger instance MUST BE used only for actual logging, calling one of the standard logging interface: logInfo(), logWarning(), logSevere() and isInfoEnabled().

Parameters:
caller - the class reference of the caller, e.g. GeneralService.class
Returns:
an instance of this class, to be used as a wrapper for the log mechanism

isReady

public static boolean isReady()
Factory accessor method.


getLoggerManager

public static LoggerManager getLoggerManager()
Return current implementation of the LoggerManager object, which is responsible for creating and initializing the log mechanism.

Returns:
a reference to the general LoggerManager object

getBenchmarkLogger

public static LoggerManager getBenchmarkLogger()
Return current implementation of the LoggerManager object, which is responsible for creating and initializing the benchmark optional feature.

Returns:
a reference to the benchmark LoggerManager object

getParentDir

public java.lang.String getParentDir()
Return the parentDir path used as base directory to locate the log file.

Returns:
the current parent directory for logging on the file system

getRotationTime

public java.lang.String getRotationTime()
Return the rotation time set for this logger, already formatted and ready to print.

Returns:
a string describing the rotation time set for this logger

initBenchmark

public static void initBenchmark()
Initializes the Benchmark logger, allowing to measure execution time of each single SQL statement. In previous versions this code-block was embedded within the initialize(): we moved it out from that method in order to restore the possibility to activate the benchmark logger at run-time (this feature was broken after the 2012-2013 refactory).


closeBenchmark

public static void closeBenchmark()
Closes the Benchmark logger


logInfo

public void logInfo(java.lang.String msg)
Log an INFO message on the default Logger and flush the relative Handler.

Parameters:
msg - the text message to be logged on the current logger

logWarning

public void logWarning(java.lang.String msg)
Log a WARNING message on the default Logger and flush the relative Handler.

Parameters:
msg - the text message to be logged on the current logger

logSevere

public void logSevere(java.lang.String msg)
Log a SEVERE message on the default Logger and flush the relative Handler.

Parameters:
msg - the text message to be logged on the current logger

flushLogger

public void flushLogger(java.util.logging.Logger logger)
Flush the Handler bound to the given Logger. Used only when the SystemLogger class is used to log messages instead of the Log4j mechanism.

Parameters:
logger - a reference to the logger object to be flushed

isInfoEnabled

public boolean isInfoEnabled()
Improves performances by avoiding to evaluate the concatened string message when the log call will not be executed (because not enabled for logger current level). This method return always false if no logger is found.

Returns:
true if the INFO log level is enabled on the current Logger

printObject

public static java.lang.String printObject(java.lang.Object object)
Print the serialize reference number of the input object.

Parameters:
object - a generic Java object, e.g. MyObject@1bd4722
Returns:
the serial number of the input object, e.g. 1bd4722

Build 19/03/2014

Morpheus Technologies - making the Zion software
Copyright © 2009-2014 Morpheus Technologies. All Rights Reserved