Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Logback: the reliable, generic, fast and flexible logging framework. Copyright (C) 1999-2011, QOS.ch. All rights reserved. This program and the accompanying materials are dual-licensed under either the terms of the Eclipse Public License v1.0 as published by the Eclipse Foundation or (per the licensee's choosing) under the terms of the GNU Lesser General Public License version 2.1 as published by the Free Software Foundation.
package ch.qos.logback.classic.jmx;
public class MBeanUtil {
  static final String DOMAIN = "ch.qos.logback.classic";
  static public String getObjectNameFor(String contextNameClass type) {
    return  + ":Name=" + contextName + ",Type="
        + type.getName();
  }
  public static ObjectName string2ObjectName(Context contextObject caller,
      String objectNameAsStr) {
    String msg = "Failed to convert [" + objectNameAsStr + "] to ObjectName";
    try {
      return new ObjectName(objectNameAsStr);
    } catch (MalformedObjectNameException e) {
      StatusUtil.addError(contextcallermsge);
      return null;
    } catch (NullPointerException e) {
      StatusUtil.addError(contextcallermsge);
      return null;
    }
  }
  public static boolean isRegistered(MBeanServer mbsObjectName objectName) {
    return mbs.isRegistered(objectName);
  }
  public static void createAndRegisterJMXConfigurator(
      MBeanServer mbsLoggerContext loggerContext,
      JMXConfigurator jmxConfiguratorObjectName objectNameObject caller) {
    try {
      mbs.registerMBean(jmxConfiguratorobjectName);
    } catch (Exception e) {
      StatusUtil.addError(loggerContextcaller"Failed to create mbean"e);
    }
  }
  public static void unregister(LoggerContext loggerContextMBeanServer mbs,
      ObjectName objectNameObject caller) {
    if (mbs.isRegistered(objectName)) {
      try {
        StatusUtil.addInfo(loggerContextcaller"Unregistering mbean ["
            + objectName + "]");
        mbs.unregisterMBean(objectName);
      } catch (InstanceNotFoundException e) {
        // this is theoretically impossible
        StatusUtil.addError(loggerContextcaller"Failed to unregister mbean"
            + objectNamee);
      } catch (MBeanRegistrationException e) {
        // this is theoretically impossible
        StatusUtil.addError(loggerContextcaller"Failed to unregister mbean"
            + objectNamee);
      }
    } else {
      StatusUtil.addInfo(loggerContextcaller"mbean [" + objectName
          + "] does not seem to be registered");
    }
  }
New to GrepCode? Check out our FAQ X