Framework Professional Edition Package


com.prosyst.util.ref
Class ManagedLog

java.lang.Object
  extended by com.prosyst.util.ref.Log
      extended by com.prosyst.util.ref.ManagedLog
All Implemented Interfaces:
LogInterface, com.prosyst.util.security.PrivilegedRunner.PrivilegedDispatcher, ManagedService, ServiceTrackerCustomizer

public class ManagedLog
extends Log
implements ManagedService

This class represents managed Log utility and should be used when the logging mechanism must be configurable.

Author:
Daniel Janev

Field Summary
static int DEBUG_ALL
          Static constant for DEBUG_ALL level.
static java.lang.String DEBUG_ALL_PROP
          Static constant for DEBUG_ALL property in the CM configuration.
protected  com.prosyst.util.hash.HashIntObjNS mapping
          The mapping between the Log levels and their configuration property names.
protected  int mask
          The integer mask which will be used for different Log levels.
protected  ManagedService parentMS
          Optional Managed Service which updated(Dictionary) method will be invoked when the ConfigAdmin calls updated(Dictionary) method of this Managed Service.
protected  java.lang.String pid
          The PID of the Managed Service which will be registered.
static int PRINT_ON_CONSOLE
          Static constant for PRINT_ON_CONSOLE.
static java.lang.String PRINT_ON_CONSOLE_PROP
          Static constant for DEBUG_ALL property in the CM configuration.
protected  org.osgi.framework.ServiceRegistration serviceReg
          The service registration of this Managed Service.
 
Fields inherited from class com.prosyst.util.ref.Log
autoPrintOnConsole, bc, debug, printOnConsole, securityUtil
 
Constructor Summary
ManagedLog(org.osgi.framework.BundleContext bc, com.prosyst.util.hash.HashIntObjNS mapping, java.lang.String pid, ManagedService parentMS)
          Creates new Managed Log utility instance
ManagedLog(java.lang.String baseName, boolean synch, org.osgi.framework.BundleContext bc, com.prosyst.util.hash.HashIntObjNS mapping, java.lang.String pid, ManagedService parentMS)
           
 
Method Summary
 void close()
          Releases the Log's resources: ungets LogService, removes the ServiceListener from the framework and nulls references.
 boolean getDebug()
          Checks whether the debug level is switched on or not.
protected  java.lang.String getDisplayName(int level)
          This method should return the display name of the specified Log level according to the mapping hashtable.
 boolean getLevel(int level)
          Checks whether the specified Log level is switched on or not.
 boolean getPrintOnConsole()
          Gets the flag, which enables printing log messages on the console.
protected  boolean hasErrors()
           
 void logDebug(java.lang.String header, int level, java.lang.String message, java.lang.Throwable e)
          Logs a debug message according to the specified header, level and message and check whether the log level i switched on.
 void logError(java.lang.String header, int level, java.lang.String message, java.lang.Throwable e)
          Logs an error message according to the specified header, level and message.
 void logInfo(java.lang.String header, int level, java.lang.String message)
          Logs an info message according to the specified header, level and message.
 void setDebug(boolean value)
          enable/diasable loging of debug info
 void setPrintOnConsole(boolean value)
          enable/diasable print on console
 void updated(java.util.Dictionary props)
          Implementation of ManagedService.updated(Dictionary) method.
protected  void updateMappings(java.util.Dictionary props)
           
 
Methods inherited from class com.prosyst.util.ref.Log
addingService, debug, debug, debug, debug, debug, dispatchPrivileged, error, error, fault, fault, finalize, info, info, isAutoPrintOnConsole, isLogErrorLevel, modifiedService, removedService, security, setAutoPrintOnConsole, setMaps, trace, trace, trigger, warning, warning
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEBUG_ALL

public static final int DEBUG_ALL
Static constant for DEBUG_ALL level.

See Also:
Constant Field Values

DEBUG_ALL_PROP

public static final java.lang.String DEBUG_ALL_PROP
Static constant for DEBUG_ALL property in the CM configuration.

See Also:
Constant Field Values

PRINT_ON_CONSOLE

public static final int PRINT_ON_CONSOLE
Static constant for PRINT_ON_CONSOLE.

See Also:
Constant Field Values

PRINT_ON_CONSOLE_PROP

public static final java.lang.String PRINT_ON_CONSOLE_PROP
Static constant for DEBUG_ALL property in the CM configuration.

See Also:
Constant Field Values

mapping

protected com.prosyst.util.hash.HashIntObjNS mapping
The mapping between the Log levels and their configuration property names. The keys are numbers which indicated different levels and the values are the names in the configuration.


pid

protected java.lang.String pid
The PID of the Managed Service which will be registered. This PID must be the same as the Config manifest header PID.


parentMS

protected ManagedService parentMS
Optional Managed Service which updated(Dictionary) method will be invoked when the ConfigAdmin calls updated(Dictionary) method of this Managed Service. Note that this Managed Service implementation MUST NOT be registered in the OSGi service registry.


mask

protected int mask
The integer mask which will be used for different Log levels.


serviceReg

protected org.osgi.framework.ServiceRegistration serviceReg
The service registration of this Managed Service.

Constructor Detail

ManagedLog

public ManagedLog(org.osgi.framework.BundleContext bc,
                  com.prosyst.util.hash.HashIntObjNS mapping,
                  java.lang.String pid,
                  ManagedService parentMS)
Creates new Managed Log utility instance

Parameters:
bc - The Bundle Context object of the
mapping -
pid -
parentMS -

ManagedLog

public ManagedLog(java.lang.String baseName,
                  boolean synch,
                  org.osgi.framework.BundleContext bc,
                  com.prosyst.util.hash.HashIntObjNS mapping,
                  java.lang.String pid,
                  ManagedService parentMS)
Method Detail

hasErrors

protected boolean hasErrors()

getDebug

public boolean getDebug()
Checks whether the debug level is switched on or not.

Specified by:
getDebug in interface LogInterface
Overrides:
getDebug in class Log
Returns:
returns true if the debug level is switched on, otherwize returns false.

setDebug

public void setDebug(boolean value)
enable/diasable loging of debug info

Specified by:
setDebug in interface LogInterface
Overrides:
setDebug in class Log
Parameters:
value - boolean if true enables loging of debug info else disables it

getPrintOnConsole

public boolean getPrintOnConsole()
Gets the flag, which enables printing log messages on the console.

Specified by:
getPrintOnConsole in interface LogInterface
Overrides:
getPrintOnConsole in class Log
Returns:
true if printingon console is enabled

setPrintOnConsole

public void setPrintOnConsole(boolean value)
enable/diasable print on console

Specified by:
setPrintOnConsole in interface LogInterface
Overrides:
setPrintOnConsole in class Log
Parameters:
value - boolean if true enables print on console else disables it

getLevel

public boolean getLevel(int level)
Checks whether the specified Log level is switched on or not.

Parameters:
level - the Log level which must be checked.
Returns:
returns true is the specified Log level is swithed on, otherwize returns false.

updated

public void updated(java.util.Dictionary props)
             throws ConfigurationException
Implementation of ManagedService.updated(Dictionary) method. This method is responsible for the

Specified by:
updated in interface ManagedService
Parameters:
props -
Throws:
ConfigurationException

updateMappings

protected void updateMappings(java.util.Dictionary props)

logInfo

public void logInfo(java.lang.String header,
                    int level,
                    java.lang.String message)
Logs an info message according to the specified header, level and message.

Parameters:
header - the header of the log message.
level - the level of the log message.
message - the text of the message.

logDebug

public void logDebug(java.lang.String header,
                     int level,
                     java.lang.String message,
                     java.lang.Throwable e)
Logs a debug message according to the specified header, level and message and check whether the log level i switched on.

Parameters:
header - the header of the log message.
level - the level of the log message.
message - the text of the message.
e - optional throwable object.

logError

public void logError(java.lang.String header,
                     int level,
                     java.lang.String message,
                     java.lang.Throwable e)
Logs an error message according to the specified header, level and message.

Parameters:
header - the header of the log message.
level - the level of the log message.
message - the text of the message.
e - optional throwable object.

getDisplayName

protected java.lang.String getDisplayName(int level)
This method should return the display name of the specified Log level according to the mapping hashtable.

Parameters:
level - the Log level which display name must be returned.
Returns:
the display name of the Log level.

close

public void close()
Releases the Log's resources: ungets LogService, removes the ServiceListener from the framework and nulls references. After invocation of this method, this Log object can be used no longer.

Specified by:
close in interface LogInterface
Overrides:
close in class Log

Framework Professional Edition Package


Copyright © 1999-2007 ProSyst Software GmbH. All Rights Reserved