Example usage for org.springframework.jmx.export MBeanExportException MBeanExportException

List of usage examples for org.springframework.jmx.export MBeanExportException MBeanExportException

Introduction

In this page you can find the example usage for org.springframework.jmx.export MBeanExportException MBeanExportException.

Prototype

public MBeanExportException(String msg, Throwable cause) 

Source Link

Document

Create a new MBeanExportException with the specified error message and root cause.

Usage

From source file:org.springframework.boot.actuate.endpoint.jmx.EndpointMBeanRegistrar.java

/**
 * Register the specified {@link EndpointMBean} and return its {@link ObjectName}.
 * @param endpoint the endpoint to register
 * @return the {@link ObjectName} used to register the {@code endpoint}
 *///w ww  .ja  v a 2s  .  c o m
public ObjectName registerEndpointMBean(EndpointMBean endpoint) {
    Assert.notNull(endpoint, "Endpoint must not be null");
    try {
        if (logger.isDebugEnabled()) {
            logger.debug("Registering endpoint with id '" + endpoint.getEndpointId() + "' to the JMX domain");
        }
        ObjectName objectName = this.objectNameFactory.generate(endpoint);
        this.mBeanServer.registerMBean(endpoint, objectName);
        return objectName;
    } catch (MalformedObjectNameException ex) {
        throw new IllegalStateException(
                "Invalid ObjectName for endpoint with id '" + endpoint.getEndpointId() + "'", ex);
    } catch (Exception ex) {
        throw new MBeanExportException(
                "Failed to register MBean for endpoint with id '" + endpoint.getEndpointId() + "'", ex);
    }
}

From source file:org.springframework.boot.actuate.endpoint.jmx.JmxEndpointExporter.java

private ObjectName register(ExposableJmxEndpoint endpoint) {
    Assert.notNull(endpoint, "Endpoint must not be null");
    try {/*from   w  ww.ja va  2  s .  c  o  m*/
        ObjectName name = this.objectNameFactory.getObjectName(endpoint);
        EndpointMBean mbean = new EndpointMBean(this.responseMapper, this.classLoader, endpoint);
        this.mBeanServer.registerMBean(mbean, name);
        return name;
    } catch (MalformedObjectNameException ex) {
        throw new IllegalStateException("Invalid ObjectName for " + getEndpointDescription(endpoint), ex);
    } catch (Exception ex) {
        throw new MBeanExportException("Failed to register MBean for " + getEndpointDescription(endpoint), ex);
    }
}