cz.cuni.amis.pogamut.base.utils.logging.jmx
Class JMXLogCategories

java.lang.Object
  extended by cz.cuni.amis.pogamut.base.utils.logging.jmx.JMXLogCategories
All Implemented Interfaces:
ILogCategories, JMXLogCategoriesMBean

public class JMXLogCategories
extends java.lang.Object
implements ILogCategories, JMXLogCategoriesMBean

JMX decorator for ILogCategories. Every new log category will implicitly have handler with JMXLogPublisher attached.


Field Summary
protected  ILogCategories logCategories
          Wrapped categories we're decorating.
protected  javax.management.MBeanServer mBeanServer
          MBean server for the log categories.
protected  javax.management.ObjectName objectName
          Id of the MBean.
 
Constructor Summary
JMXLogCategories(ILogCategories logCategories, javax.management.MBeanServer mBeanServer, javax.management.ObjectName parent)
          JMXLogCategories differs from LogCategories by implicit handler with JMXLogPublisher in every log category it produces.
 
Method Summary
 void addLogCategory(java.lang.String name, LogCategory category)
          Adds log category from outside of the object.
 java.util.Map<java.lang.String,LogCategory> getCategories()
          Returns IMMUTABLE mapping of categories names to instances of those log categories.
 LogCategory getCategory(java.lang.String name)
          Returns existing category by the name or adds new one.
 java.lang.String[] getCategoryNames()
          Returns names of all existing log categories.
 java.lang.String[] getCategoryNamesSorted()
          Returns names of all existing log categories sorted alphabetically.
 javax.management.ObjectName getJMXLogCategoriesName()
          Returns actual JMX object name for this object.
static javax.management.ObjectName getJMXLogCategoriesName(javax.management.ObjectName parent)
          Gets LogCategories's object name given parent's name.
static javax.management.ObjectName getJMXLogCategoryName(javax.management.ObjectName parent, java.lang.String categoryName)
           
 javax.management.ObjectName getJMXLogCategoryName(java.lang.String categoryName)
          Returns jmx name for the specified category name (obtained from getCategoryNames()).
 boolean hasCategory(java.lang.String name)
          Whether some category with specified name exists.
 void setLevel(java.util.logging.Level newLevel)
          Set level for all handlers of all categories.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logCategories

protected ILogCategories logCategories
Wrapped categories we're decorating.


mBeanServer

protected javax.management.MBeanServer mBeanServer
MBean server for the log categories.


objectName

protected javax.management.ObjectName objectName
Id of the MBean.

Constructor Detail

JMXLogCategories

public JMXLogCategories(ILogCategories logCategories,
                        javax.management.MBeanServer mBeanServer,
                        javax.management.ObjectName parent)
                 throws javax.management.InstanceAlreadyExistsException,
                        javax.management.MBeanRegistrationException,
                        javax.management.NotCompliantMBeanException,
                        javax.management.MalformedObjectNameException,
                        java.lang.NullPointerException
JMXLogCategories differs from LogCategories by implicit handler with JMXLogPublisher in every log category it produces.

Can't be instantiated twice for one (JMX Domain,mBeanServer)!

Parameters:
logCategories -
mBeanServer -
parent -
Throws:
javax.management.InstanceAlreadyExistsException - raised if instantiated twice for one jmx domain
javax.management.MBeanRegistrationException
javax.management.NotCompliantMBeanException
javax.management.MalformedObjectNameException
java.lang.NullPointerException
Method Detail

getCategory

public LogCategory getCategory(java.lang.String name)
Returns existing category by the name or adds new one.

Contains handler with JMXLogPublisher attached.

If you wish to add another handler do: LogCategory myCategory = categories.getCategory("my log"); // create new category myCategory.newHandler(new LogPublisher.ConsolePublisher()); // add new handler with output to the console

Specified by:
getCategory in interface ILogCategories
Parameters:
name -
Returns:

getCategories

public java.util.Map<java.lang.String,LogCategory> getCategories()
Description copied from interface: ILogCategories
Returns IMMUTABLE mapping of categories names to instances of those log categories.

It does not contain instance of IAgentLogger.

Specified by:
getCategories in interface ILogCategories
Returns:

getCategoryNames

public java.lang.String[] getCategoryNames()
Description copied from interface: ILogCategories
Returns names of all existing log categories.

Specified by:
getCategoryNames in interface ILogCategories
Specified by:
getCategoryNames in interface JMXLogCategoriesMBean
Returns:

getCategoryNamesSorted

public java.lang.String[] getCategoryNamesSorted()
Description copied from interface: ILogCategories
Returns names of all existing log categories sorted alphabetically.

Specified by:
getCategoryNamesSorted in interface ILogCategories
Specified by:
getCategoryNamesSorted in interface JMXLogCategoriesMBean
Returns:

hasCategory

public boolean hasCategory(java.lang.String name)
Description copied from interface: ILogCategories
Whether some category with specified name exists.

Specified by:
hasCategory in interface ILogCategories
Returns:

setLevel

public void setLevel(java.util.logging.Level newLevel)
Description copied from interface: ILogCategories
Set level for all handlers of all categories.

Specified by:
setLevel in interface ILogCategories
Specified by:
setLevel in interface JMXLogCategoriesMBean

addLogCategory

public void addLogCategory(java.lang.String name,
                           LogCategory category)
Description copied from interface: ILogCategories
Adds log category from outside of the object.

Specified by:
addLogCategory in interface ILogCategories

getJMXLogCategoryName

public javax.management.ObjectName getJMXLogCategoryName(java.lang.String categoryName)
                                                  throws PogamutJMXNameException
Description copied from interface: JMXLogCategoriesMBean
Returns jmx name for the specified category name (obtained from getCategoryNames()).

Specified by:
getJMXLogCategoryName in interface JMXLogCategoriesMBean
Returns:
Throws:
PogamutJMXNameException

getJMXLogCategoryName

public static javax.management.ObjectName getJMXLogCategoryName(javax.management.ObjectName parent,
                                                                java.lang.String categoryName)
                                                         throws PogamutJMXNameException
Throws:
PogamutJMXNameException

getJMXLogCategoriesName

public javax.management.ObjectName getJMXLogCategoriesName()
Description copied from interface: JMXLogCategoriesMBean
Returns actual JMX object name for this object.

Specified by:
getJMXLogCategoriesName in interface JMXLogCategoriesMBean
Returns:

getJMXLogCategoriesName

public static javax.management.ObjectName getJMXLogCategoriesName(javax.management.ObjectName parent)
                                                           throws PogamutJMXNameException
Gets LogCategories's object name given parent's name.

Parameters:
parent -
Returns:
Throws:
PogamutJMXNameException