org.apache.logging.log4j.core.jmx
Class LoggerContextAdmin

java.lang.Object
  extended by javax.management.NotificationBroadcasterSupport
      extended by org.apache.logging.log4j.core.jmx.LoggerContextAdmin
All Implemented Interfaces:
PropertyChangeListener, EventListener, NotificationBroadcaster, NotificationEmitter, LoggerContextAdminMBean

public class LoggerContextAdmin
extends NotificationBroadcasterSupport
implements LoggerContextAdminMBean, PropertyChangeListener

Implementation of the LoggerContextAdminMBean interface.


Field Summary
 
Fields inherited from interface org.apache.logging.log4j.core.jmx.LoggerContextAdminMBean
NOTIF_TYPE_RECONFIGURED, PATTERN
 
Constructor Summary
LoggerContextAdmin(LoggerContext loggerContext, Executor executor)
          Constructs a new LoggerContextAdmin with the Executor to be used for sending Notification s asynchronously to listeners.
 
Method Summary
 String getConfigClassName()
          Returns the class name of the Configuration of the instrumented LoggerContext.
 String getConfigFilter()
          Returns a string description of all Filters configured in the Configuration of the instrumented LoggerContext.
 String getConfigLocationUri()
          Returns the configuration location URI as a String.
 String getConfigMonitorClassName()
          Returns the class name of the object that is monitoring the configuration file for modifications.
 String getConfigName()
          Returns the name of the Configuration of the instrumented LoggerContext.
 Map<String,String> getConfigProperties()
          Returns a map with configured properties.
 String getConfigText()
          Returns the configuration text, which may be the contents of the configuration file or the text that was last set with a call to setConfigText.
 String getConfigText(String charsetName)
          Returns the configuration text, which may be the contents of the configuration file or the text that was last set with a call to setConfigText.
 String getName()
          Returns the name of the instrumented LoggerContext.
 ObjectName getObjectName()
          Returns the ObjectName of this mbean.
 String getStatus()
          Returns the status of the instrumented LoggerContext.
 void propertyChange(PropertyChangeEvent evt)
           
 void setConfigLocationUri(String configLocation)
          Sets the configuration location to the specified URI.
 void setConfigText(String configText, String charsetName)
          Sets the configuration text.
 
Methods inherited from class javax.management.NotificationBroadcasterSupport
addNotificationListener, getNotificationInfo, handleNotification, removeNotificationListener, removeNotificationListener, sendNotification
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LoggerContextAdmin

public LoggerContextAdmin(LoggerContext loggerContext,
                          Executor executor)
Constructs a new LoggerContextAdmin with the Executor to be used for sending Notification s asynchronously to listeners.

Parameters:
executor - used to send notifications asynchronously
loggerContext - the instrumented object
Method Detail

getStatus

public String getStatus()
Description copied from interface: LoggerContextAdminMBean
Returns the status of the instrumented LoggerContext.

Specified by:
getStatus in interface LoggerContextAdminMBean
Returns:
the LoggerContext status.

getName

public String getName()
Description copied from interface: LoggerContextAdminMBean
Returns the name of the instrumented LoggerContext.

Specified by:
getName in interface LoggerContextAdminMBean
Returns:
the name of the instrumented LoggerContext.

getConfigLocationUri

public String getConfigLocationUri()
Description copied from interface: LoggerContextAdminMBean
Returns the configuration location URI as a String.

Specified by:
getConfigLocationUri in interface LoggerContextAdminMBean
Returns:
the configuration location

setConfigLocationUri

public void setConfigLocationUri(String configLocation)
                          throws URISyntaxException,
                                 IOException
Description copied from interface: LoggerContextAdminMBean
Sets the configuration location to the specified URI. This will cause the instrumented LoggerContext to reconfigure.

Specified by:
setConfigLocationUri in interface LoggerContextAdminMBean
Parameters:
configLocation - location of the configuration file in URI format.
Throws:
URISyntaxException - if the format of the specified configLocationURI is incorrect
IOException - if an error occurred reading the specified location

propertyChange

public void propertyChange(PropertyChangeEvent evt)
Specified by:
propertyChange in interface PropertyChangeListener

getConfigText

public String getConfigText()
                     throws IOException
Description copied from interface: LoggerContextAdminMBean
Returns the configuration text, which may be the contents of the configuration file or the text that was last set with a call to setConfigText. If reading a file, this method assumes the file's character encoding is UTF-8.

Specified by:
getConfigText in interface LoggerContextAdminMBean
Returns:
the configuration text
Throws:
IOException - if a problem occurred reading the contents of the config file.

getConfigText

public String getConfigText(String charsetName)
                     throws IOException
Description copied from interface: LoggerContextAdminMBean
Returns the configuration text, which may be the contents of the configuration file or the text that was last set with a call to setConfigText.

Specified by:
getConfigText in interface LoggerContextAdminMBean
Parameters:
charsetName - the encoding to use to convert the file's bytes into the resulting string.
Returns:
the configuration text
Throws:
IOException - if a problem occurred reading the contents of the config file.

setConfigText

public void setConfigText(String configText,
                          String charsetName)
Description copied from interface: LoggerContextAdminMBean
Sets the configuration text. This does not replace the contents of the configuration file, but does cause the instrumented LoggerContext to be reconfigured with the specified text.

Specified by:
setConfigText in interface LoggerContextAdminMBean
Parameters:
configText - the configuration text in XML or JSON format
charsetName - name of the Charset used to convert the specified configText to bytes

getConfigName

public String getConfigName()
Description copied from interface: LoggerContextAdminMBean
Returns the name of the Configuration of the instrumented LoggerContext.

Specified by:
getConfigName in interface LoggerContextAdminMBean
Returns:
the Configuration name

getConfigClassName

public String getConfigClassName()
Description copied from interface: LoggerContextAdminMBean
Returns the class name of the Configuration of the instrumented LoggerContext.

Specified by:
getConfigClassName in interface LoggerContextAdminMBean
Returns:
the class name of the Configuration.

getConfigFilter

public String getConfigFilter()
Description copied from interface: LoggerContextAdminMBean
Returns a string description of all Filters configured in the Configuration of the instrumented LoggerContext.

Specified by:
getConfigFilter in interface LoggerContextAdminMBean
Returns:
a string description of all Filters configured

getConfigMonitorClassName

public String getConfigMonitorClassName()
Description copied from interface: LoggerContextAdminMBean
Returns the class name of the object that is monitoring the configuration file for modifications.

Specified by:
getConfigMonitorClassName in interface LoggerContextAdminMBean
Returns:
the class name of the object that is monitoring the configuration file for modifications

getConfigProperties

public Map<String,String> getConfigProperties()
Description copied from interface: LoggerContextAdminMBean
Returns a map with configured properties.

Specified by:
getConfigProperties in interface LoggerContextAdminMBean
Returns:
a map with configured properties.

getObjectName

public ObjectName getObjectName()
Returns the ObjectName of this mbean.

Specified by:
getObjectName in interface LoggerContextAdminMBean
Returns:
the ObjectName
See Also:
LoggerContextAdminMBean.PATTERN


Copyright © 1999-2015 Apache Software Foundation. All Rights Reserved.
Apache Logging, Apache Log4j, Log4j, Apache, the Apache feather logo, the Apache Logging project logo, and the Apache Log4j logo are trademarks of The Apache Software Foundation.