org.apache.hivemind.management.log4j
Class LogManagementMBean

java.lang.Object
  extended by org.apache.hivemind.management.mbeans.AbstractDynamicMBean
      extended by org.apache.hivemind.management.log4j.LogManagementMBean
All Implemented Interfaces:
javax.management.DynamicMBean, javax.management.MBeanRegistration, LogManagement

public class LogManagementMBean
extends AbstractDynamicMBean
implements LogManagement

MBean that manages MBeans for Log4j Loggers. New MBeans can be added by specifying the Logger name or a logger pattern. Each MBean allows managing level and appenders of a single logger. Uses the LoggerDynamicMBean from the log4j library. Similar to HierarchyDynamicMBean but implements the hivemind ObjectName scheme by using ObjectNameBuilder service.

Since:
1.1
Author:
Achim Huegen

Constructor Summary
LogManagementMBean(ObjectNameBuilder objectNameBuilder, java.util.List loggerContributions)
           
 
Method Summary
protected  void addConfiguredLoggerMBeans()
          Adds MBeans for all Loggers that are defined in the service configuration
protected  javax.management.ObjectName addLoggerMBean(org.apache.log4j.Logger log)
          Adds a MBean for a logger.
 void addLoggerMBean(java.lang.String loggerPattern)
          Adds a MBean for a logger or a group of loggers that matches a pattern.
protected  void addLoggerMBeansForPattern(java.lang.String loggerPattern)
          Adds MBeans for all existing Loggers, that match the loggerPattern
protected  javax.management.MBeanAttributeInfo[] createMBeanAttributeInfo()
          Provides the info which attributes the MBean has.
protected  javax.management.MBeanOperationInfo[] createMBeanOperationInfo()
          Provides the info which operations can be called on the MBean.
 ObjectNameBuilder getObjectNameBuilder()
           
 java.lang.String getThreshold()
           
protected  boolean isMatch(java.lang.String loggerName, java.lang.String loggerPattern)
          Returns true if loggerName matches a loggerPattern The pattern kann contain '*' as wildcard character.
 void postRegister(java.lang.Boolean registrationDone)
           
 void setThreshold(java.lang.String threshold)
           
 
Methods inherited from class org.apache.hivemind.management.mbeans.AbstractDynamicMBean
createMBeanConstructorInfo, createMBeanNotificationInfo, getAttribute, getAttributes, getMBeanClassName, getMBeanDescription, getMBeanInfo, getMBeanServer, invoke, postDeregister, preDeregister, preRegister, setAttribute, setAttributes, setMBeanInfo
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LogManagementMBean

public LogManagementMBean(ObjectNameBuilder objectNameBuilder,
                          java.util.List loggerContributions)
Method Detail

createMBeanAttributeInfo

protected javax.management.MBeanAttributeInfo[] createMBeanAttributeInfo()
Description copied from class: AbstractDynamicMBean
Provides the info which attributes the MBean has. Should be overwritten by the descendants

Overrides:
createMBeanAttributeInfo in class AbstractDynamicMBean

createMBeanOperationInfo

protected javax.management.MBeanOperationInfo[] createMBeanOperationInfo()
Description copied from class: AbstractDynamicMBean
Provides the info which operations can be called on the MBean. Should be overwritten by the descendants

Overrides:
createMBeanOperationInfo in class AbstractDynamicMBean

postRegister

public void postRegister(java.lang.Boolean registrationDone)
Specified by:
postRegister in interface javax.management.MBeanRegistration
Overrides:
postRegister in class AbstractDynamicMBean

getThreshold

public java.lang.String getThreshold()

setThreshold

public void setThreshold(java.lang.String threshold)

addLoggerMBean

public void addLoggerMBean(java.lang.String loggerPattern)
Description copied from interface: LogManagement
Adds a MBean for a logger or a group of loggers that matches a pattern. The pattern kann contain '*' as wildcard character. If no wildcard is used the logger is created if it doesn't exist. This is useful, since most loggers are not created before the defining class is loaded. And this may be long after this MBean is registered. If a wildcard is used, only loggers that already exist. Example: addLoggerMBean( "hivemind.*" )

Specified by:
addLoggerMBean in interface LogManagement
Parameters:
loggerPattern - Name of the logger
See Also:
LogManagement.addLoggerMBean(java.lang.String)

addLoggerMBean

protected javax.management.ObjectName addLoggerMBean(org.apache.log4j.Logger log)
Adds a MBean for a logger.

Parameters:
log - the logger
Returns:
ObjectName of created MBean

addConfiguredLoggerMBeans

protected void addConfiguredLoggerMBeans()
Adds MBeans for all Loggers that are defined in the service configuration


addLoggerMBeansForPattern

protected void addLoggerMBeansForPattern(java.lang.String loggerPattern)
Adds MBeans for all existing Loggers, that match the loggerPattern

Parameters:
loggerPattern -

getObjectNameBuilder

public ObjectNameBuilder getObjectNameBuilder()
Returns:
Returns the _objectNameBuilder.

isMatch

protected boolean isMatch(java.lang.String loggerName,
                          java.lang.String loggerPattern)
Returns true if loggerName matches a loggerPattern The pattern kann contain '*' as wildcard character. This gets translated to '.*' and is used for a regex match using jakarta oro