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

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

public class JMXLogCategories
extends Object
implements ILogCategories, JMXLogCategoriesMBean

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

Author:
Jimmy

Field Summary
protected  ILogCategories logCategories
          Wrapped categories we're decorating.
protected  MBeanServer mBeanServer
          MBean server for the log categories.
protected  ObjectName objectName
          Id of the MBean.
 
Constructor Summary
JMXLogCategories(ILogCategories logCategories, MBeanServer mBeanServer, ObjectName parent)
          JMXLogCategories differs from LogCategories by implicit handler with JMXLogPublisher in every log category it produces.
 
Method Summary
 void addLogCategory(String name, LogCategory category)
          Adds log category from outside of the object.
 Map<String,LogCategory> getCategories()
          Returns IMMUTABLE mapping of categories names to instances of those log categories.
 LogCategory getCategory(String name)
          Returns existing category by the name or adds new one.
 String[] getCategoryNames()
          Returns names of all existing log categories.
 String[] getCategoryNamesSorted()
          Returns names of all existing log categories sorted alphabetically.
 ObjectName getJMXLogCategoriesName()
          Returns actual JMX object name for this object.
static ObjectName getJMXLogCategoriesName(ObjectName parent)
          Gets LogCategories's object name given parent's name.
static ObjectName getJMXLogCategoryName(ObjectName parent, String categoryName)
           
 ObjectName getJMXLogCategoryName(String categoryName)
          Returns jmx name for the specified category name (obtained from getCategoryNames()).
 boolean hasCategory(String name)
          Whether some category with specified name exists.
 void setLevel(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 MBeanServer mBeanServer
MBean server for the log categories.


objectName

protected ObjectName objectName
Id of the MBean.

Constructor Detail

JMXLogCategories

public JMXLogCategories(ILogCategories logCategories,
                        MBeanServer mBeanServer,
                        ObjectName parent)
                 throws InstanceAlreadyExistsException,
                        MBeanRegistrationException,
                        NotCompliantMBeanException,
                        MalformedObjectNameException,
                        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:
InstanceAlreadyExistsException - raised if instantiated twice for one jmx domain
MBeanRegistrationException
NotCompliantMBeanException
MalformedObjectNameException
NullPointerException
Method Detail

getCategory

public LogCategory getCategory(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 Map<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 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 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(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(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(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 ObjectName getJMXLogCategoryName(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 ObjectName getJMXLogCategoryName(ObjectName parent,
                                               String categoryName)
                                        throws PogamutJMXNameException
Throws:
PogamutJMXNameException

getJMXLogCategoriesName

public 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 ObjectName getJMXLogCategoriesName(ObjectName parent)
                                          throws PogamutJMXNameException
Gets LogCategories's object name given parent's name.

Parameters:
parent -
Returns:
Throws:
PogamutJMXNameException


Copyright © 2013 AMIS research group, Faculty of Mathematics and Physics, Charles University in Prague, Czech Republic. All Rights Reserved.