javax.management.MBeanRegistration Java Examples

The following examples show how to use javax.management.MBeanRegistration. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DefaultMBeanServerInterceptor.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
private static ObjectName preRegister(
        DynamicMBean mbean, MBeanServer mbs, ObjectName name)
        throws InstanceAlreadyExistsException, MBeanRegistrationException {

    ObjectName newName = null;

    try {
        if (mbean instanceof MBeanRegistration)
            newName = ((MBeanRegistration) mbean).preRegister(mbs, name);
    } catch (Throwable t) {
        throwMBeanRegistrationException(t, "in preRegister method");
    }

    if (newName != null) return newName;
    else return name;
}
 
Example #2
Source File: DefaultMBeanServerInterceptor.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
private static ObjectName preRegister(
        DynamicMBean mbean, MBeanServer mbs, ObjectName name)
        throws InstanceAlreadyExistsException, MBeanRegistrationException {

    ObjectName newName = null;

    try {
        if (mbean instanceof MBeanRegistration)
            newName = ((MBeanRegistration) mbean).preRegister(mbs, name);
    } catch (Throwable t) {
        throwMBeanRegistrationException(t, "in preRegister method");
    }

    if (newName != null) return newName;
    else return name;
}
 
Example #3
Source File: DefaultMBeanServerInterceptor.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
private static void postRegister(
        ObjectName logicalName, DynamicMBean mbean,
        boolean registrationDone, boolean registerFailed) {

    if (registerFailed && mbean instanceof DynamicMBean2)
        ((DynamicMBean2) mbean).registerFailed();
    try {
        if (mbean instanceof MBeanRegistration)
            ((MBeanRegistration) mbean).postRegister(registrationDone);
    } catch (RuntimeException e) {
        MBEANSERVER_LOGGER.fine("While registering MBean ["+logicalName+
                "]: " + "Exception thrown by postRegister: " +
                "rethrowing <"+e+">, but keeping the MBean registered");
        throw new RuntimeMBeanException(e,
                  "RuntimeException thrown in postRegister method: "+
                  "rethrowing <"+e+">, but keeping the MBean registered");
    } catch (Error er) {
        MBEANSERVER_LOGGER.fine("While registering MBean ["+logicalName+
                "]: " + "Error thrown by postRegister: " +
                "rethrowing <"+er+">, but keeping the MBean registered");
        throw new RuntimeErrorException(er,
                  "Error thrown in postRegister method: "+
                  "rethrowing <"+er+">, but keeping the MBean registered");
    }
}
 
Example #4
Source File: DefaultMBeanServerInterceptor.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
private static void postDeregisterInvoke(ObjectName mbean,
        MBeanRegistration moi) {
    try {
        moi.postDeregister();
    } catch (RuntimeException e) {
        MBEANSERVER_LOGGER.fine("While unregistering MBean ["+mbean+
                "]: " + "Exception thrown by postDeregister: " +
                "rethrowing <"+e+">, although the MBean is succesfully " +
                "unregistered");
        throw new RuntimeMBeanException(e,
                  "RuntimeException thrown in postDeregister method: "+
                  "rethrowing <"+e+
                  ">, although the MBean is sucessfully unregistered");
    } catch (Error er) {
        MBEANSERVER_LOGGER.fine("While unregistering MBean ["+mbean+
                "]: " + "Error thrown by postDeregister: " +
                "rethrowing <"+er+">, although the MBean is succesfully " +
                "unregistered");
        throw new RuntimeErrorException(er,
                  "Error thrown in postDeregister method: "+
                  "rethrowing <"+er+
                  ">, although the MBean is sucessfully unregistered");
    }
}
 
Example #5
Source File: DefaultMBeanServerInterceptor.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
private static void postRegister(
        ObjectName logicalName, DynamicMBean mbean,
        boolean registrationDone, boolean registerFailed) {

    if (registerFailed && mbean instanceof DynamicMBean2)
        ((DynamicMBean2) mbean).registerFailed();
    try {
        if (mbean instanceof MBeanRegistration)
            ((MBeanRegistration) mbean).postRegister(registrationDone);
    } catch (RuntimeException e) {
        MBEANSERVER_LOGGER.fine("While registering MBean ["+logicalName+
                "]: " + "Exception thrown by postRegister: " +
                "rethrowing <"+e+">, but keeping the MBean registered");
        throw new RuntimeMBeanException(e,
                  "RuntimeException thrown in postRegister method: "+
                  "rethrowing <"+e+">, but keeping the MBean registered");
    } catch (Error er) {
        MBEANSERVER_LOGGER.fine("While registering MBean ["+logicalName+
                "]: " + "Error thrown by postRegister: " +
                "rethrowing <"+er+">, but keeping the MBean registered");
        throw new RuntimeErrorException(er,
                  "Error thrown in postRegister method: "+
                  "rethrowing <"+er+">, but keeping the MBean registered");
    }
}
 
Example #6
Source File: DefaultMBeanServerInterceptor.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
private static ObjectName preRegister(
        DynamicMBean mbean, MBeanServer mbs, ObjectName name)
        throws InstanceAlreadyExistsException, MBeanRegistrationException {

    ObjectName newName = null;

    try {
        if (mbean instanceof MBeanRegistration)
            newName = ((MBeanRegistration) mbean).preRegister(mbs, name);
    } catch (Throwable t) {
        throwMBeanRegistrationException(t, "in preRegister method");
    }

    if (newName != null) return newName;
    else return name;
}
 
Example #7
Source File: DefaultMBeanServerInterceptor.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
private static void postDeregisterInvoke(ObjectName mbean,
        MBeanRegistration moi) {
    try {
        moi.postDeregister();
    } catch (RuntimeException e) {
        MBEANSERVER_LOGGER.fine("While unregistering MBean ["+mbean+
                "]: " + "Exception thrown by postDeregister: " +
                "rethrowing <"+e+">, although the MBean is succesfully " +
                "unregistered");
        throw new RuntimeMBeanException(e,
                  "RuntimeException thrown in postDeregister method: "+
                  "rethrowing <"+e+
                  ">, although the MBean is sucessfully unregistered");
    } catch (Error er) {
        MBEANSERVER_LOGGER.fine("While unregistering MBean ["+mbean+
                "]: " + "Error thrown by postDeregister: " +
                "rethrowing <"+er+">, although the MBean is succesfully " +
                "unregistered");
        throw new RuntimeErrorException(er,
                  "Error thrown in postDeregister method: "+
                  "rethrowing <"+er+
                  ">, although the MBean is sucessfully unregistered");
    }
}
 
Example #8
Source File: DefaultMBeanServerInterceptor.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
private static void postRegister(
        ObjectName logicalName, DynamicMBean mbean,
        boolean registrationDone, boolean registerFailed) {

    if (registerFailed && mbean instanceof DynamicMBean2)
        ((DynamicMBean2) mbean).registerFailed();
    try {
        if (mbean instanceof MBeanRegistration)
            ((MBeanRegistration) mbean).postRegister(registrationDone);
    } catch (RuntimeException e) {
        MBEANSERVER_LOGGER.fine("While registering MBean ["+logicalName+
                "]: " + "Exception thrown by postRegister: " +
                "rethrowing <"+e+">, but keeping the MBean registered");
        throw new RuntimeMBeanException(e,
                  "RuntimeException thrown in postRegister method: "+
                  "rethrowing <"+e+">, but keeping the MBean registered");
    } catch (Error er) {
        MBEANSERVER_LOGGER.fine("While registering MBean ["+logicalName+
                "]: " + "Error thrown by postRegister: " +
                "rethrowing <"+er+">, but keeping the MBean registered");
        throw new RuntimeErrorException(er,
                  "Error thrown in postRegister method: "+
                  "rethrowing <"+er+">, but keeping the MBean registered");
    }
}
 
Example #9
Source File: DefaultMBeanServerInterceptor.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
private static void postDeregisterInvoke(ObjectName mbean,
        MBeanRegistration moi) {
    try {
        moi.postDeregister();
    } catch (RuntimeException e) {
        MBEANSERVER_LOGGER.fine("While unregistering MBean ["+mbean+
                "]: " + "Exception thrown by postDeregister: " +
                "rethrowing <"+e+">, although the MBean is succesfully " +
                "unregistered");
        throw new RuntimeMBeanException(e,
                  "RuntimeException thrown in postDeregister method: "+
                  "rethrowing <"+e+
                  ">, although the MBean is sucessfully unregistered");
    } catch (Error er) {
        MBEANSERVER_LOGGER.fine("While unregistering MBean ["+mbean+
                "]: " + "Error thrown by postDeregister: " +
                "rethrowing <"+er+">, although the MBean is succesfully " +
                "unregistered");
        throw new RuntimeErrorException(er,
                  "Error thrown in postDeregister method: "+
                  "rethrowing <"+er+
                  ">, although the MBean is sucessfully unregistered");
    }
}
 
Example #10
Source File: DefaultMBeanServerInterceptor.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private static ObjectName preRegister(
        DynamicMBean mbean, MBeanServer mbs, ObjectName name)
        throws InstanceAlreadyExistsException, MBeanRegistrationException {

    ObjectName newName = null;

    try {
        if (mbean instanceof MBeanRegistration)
            newName = ((MBeanRegistration) mbean).preRegister(mbs, name);
    } catch (Throwable t) {
        throwMBeanRegistrationException(t, "in preRegister method");
    }

    if (newName != null) return newName;
    else return name;
}
 
Example #11
Source File: DefaultMBeanServerInterceptor.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
private static void postRegister(
        ObjectName logicalName, DynamicMBean mbean,
        boolean registrationDone, boolean registerFailed) {

    if (registerFailed && mbean instanceof DynamicMBean2)
        ((DynamicMBean2) mbean).registerFailed();
    try {
        if (mbean instanceof MBeanRegistration)
            ((MBeanRegistration) mbean).postRegister(registrationDone);
    } catch (RuntimeException e) {
        MBEANSERVER_LOGGER.fine("While registering MBean ["+logicalName+
                "]: " + "Exception thrown by postRegister: " +
                "rethrowing <"+e+">, but keeping the MBean registered");
        throw new RuntimeMBeanException(e,
                  "RuntimeException thrown in postRegister method: "+
                  "rethrowing <"+e+">, but keeping the MBean registered");
    } catch (Error er) {
        MBEANSERVER_LOGGER.fine("While registering MBean ["+logicalName+
                "]: " + "Error thrown by postRegister: " +
                "rethrowing <"+er+">, but keeping the MBean registered");
        throw new RuntimeErrorException(er,
                  "Error thrown in postRegister method: "+
                  "rethrowing <"+er+">, but keeping the MBean registered");
    }
}
 
Example #12
Source File: DefaultMBeanServerInterceptor.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
private static ObjectName preRegister(
        DynamicMBean mbean, MBeanServer mbs, ObjectName name)
        throws InstanceAlreadyExistsException, MBeanRegistrationException {

    ObjectName newName = null;

    try {
        if (mbean instanceof MBeanRegistration)
            newName = ((MBeanRegistration) mbean).preRegister(mbs, name);
    } catch (Throwable t) {
        throwMBeanRegistrationException(t, "in preRegister method");
    }

    if (newName != null) return newName;
    else return name;
}
 
Example #13
Source File: DefaultMBeanServerInterceptor.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
private static void postRegister(
        ObjectName logicalName, DynamicMBean mbean,
        boolean registrationDone, boolean registerFailed) {

    if (registerFailed && mbean instanceof DynamicMBean2)
        ((DynamicMBean2) mbean).registerFailed();
    try {
        if (mbean instanceof MBeanRegistration)
            ((MBeanRegistration) mbean).postRegister(registrationDone);
    } catch (RuntimeException e) {
        MBEANSERVER_LOGGER.fine("While registering MBean ["+logicalName+
                "]: " + "Exception thrown by postRegister: " +
                "rethrowing <"+e+">, but keeping the MBean registered");
        throw new RuntimeMBeanException(e,
                  "RuntimeException thrown in postRegister method: "+
                  "rethrowing <"+e+">, but keeping the MBean registered");
    } catch (Error er) {
        MBEANSERVER_LOGGER.fine("While registering MBean ["+logicalName+
                "]: " + "Error thrown by postRegister: " +
                "rethrowing <"+er+">, but keeping the MBean registered");
        throw new RuntimeErrorException(er,
                  "Error thrown in postRegister method: "+
                  "rethrowing <"+er+">, but keeping the MBean registered");
    }
}
 
Example #14
Source File: DefaultMBeanServerInterceptor.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
private static ObjectName preRegister(
        DynamicMBean mbean, MBeanServer mbs, ObjectName name)
        throws InstanceAlreadyExistsException, MBeanRegistrationException {

    ObjectName newName = null;

    try {
        if (mbean instanceof MBeanRegistration)
            newName = ((MBeanRegistration) mbean).preRegister(mbs, name);
    } catch (Throwable t) {
        throwMBeanRegistrationException(t, "in preRegister method");
    }

    if (newName != null) return newName;
    else return name;
}
 
Example #15
Source File: DefaultMBeanServerInterceptor.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
private static void postDeregisterInvoke(ObjectName mbean,
        MBeanRegistration moi) {
    try {
        moi.postDeregister();
    } catch (RuntimeException e) {
        MBEANSERVER_LOGGER.fine("While unregistering MBean ["+mbean+
                "]: " + "Exception thrown by postDeregister: " +
                "rethrowing <"+e+">, although the MBean is succesfully " +
                "unregistered");
        throw new RuntimeMBeanException(e,
                  "RuntimeException thrown in postDeregister method: "+
                  "rethrowing <"+e+
                  ">, although the MBean is sucessfully unregistered");
    } catch (Error er) {
        MBEANSERVER_LOGGER.fine("While unregistering MBean ["+mbean+
                "]: " + "Error thrown by postDeregister: " +
                "rethrowing <"+er+">, although the MBean is succesfully " +
                "unregistered");
        throw new RuntimeErrorException(er,
                  "Error thrown in postDeregister method: "+
                  "rethrowing <"+er+
                  ">, although the MBean is sucessfully unregistered");
    }
}
 
Example #16
Source File: DefaultMBeanServerInterceptor.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
private static void postDeregisterInvoke(ObjectName mbean,
        MBeanRegistration moi) {
    try {
        moi.postDeregister();
    } catch (RuntimeException e) {
        MBEANSERVER_LOGGER.fine("While unregistering MBean ["+mbean+
                "]: " + "Exception thrown by postDeregister: " +
                "rethrowing <"+e+">, although the MBean is succesfully " +
                "unregistered");
        throw new RuntimeMBeanException(e,
                  "RuntimeException thrown in postDeregister method: "+
                  "rethrowing <"+e+
                  ">, although the MBean is sucessfully unregistered");
    } catch (Error er) {
        MBEANSERVER_LOGGER.fine("While unregistering MBean ["+mbean+
                "]: " + "Error thrown by postDeregister: " +
                "rethrowing <"+er+">, although the MBean is succesfully " +
                "unregistered");
        throw new RuntimeErrorException(er,
                  "Error thrown in postDeregister method: "+
                  "rethrowing <"+er+
                  ">, although the MBean is sucessfully unregistered");
    }
}
 
Example #17
Source File: DefaultMBeanServerInterceptor.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
private static ObjectName preRegister(
        DynamicMBean mbean, MBeanServer mbs, ObjectName name)
        throws InstanceAlreadyExistsException, MBeanRegistrationException {

    ObjectName newName = null;

    try {
        if (mbean instanceof MBeanRegistration)
            newName = ((MBeanRegistration) mbean).preRegister(mbs, name);
    } catch (Throwable t) {
        throwMBeanRegistrationException(t, "in preRegister method");
    }

    if (newName != null) return newName;
    else return name;
}
 
Example #18
Source File: DefaultMBeanServerInterceptor.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
private static void postDeregisterInvoke(ObjectName mbean,
        MBeanRegistration moi) {
    try {
        moi.postDeregister();
    } catch (RuntimeException e) {
        MBEANSERVER_LOGGER.fine("While unregistering MBean ["+mbean+
                "]: " + "Exception thrown by postDeregister: " +
                "rethrowing <"+e+">, although the MBean is succesfully " +
                "unregistered");
        throw new RuntimeMBeanException(e,
                  "RuntimeException thrown in postDeregister method: "+
                  "rethrowing <"+e+
                  ">, although the MBean is sucessfully unregistered");
    } catch (Error er) {
        MBEANSERVER_LOGGER.fine("While unregistering MBean ["+mbean+
                "]: " + "Error thrown by postDeregister: " +
                "rethrowing <"+er+">, although the MBean is succesfully " +
                "unregistered");
        throw new RuntimeErrorException(er,
                  "Error thrown in postDeregister method: "+
                  "rethrowing <"+er+
                  ">, although the MBean is sucessfully unregistered");
    }
}
 
Example #19
Source File: DefaultMBeanServerInterceptor.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
private static void postRegister(
        ObjectName logicalName, DynamicMBean mbean,
        boolean registrationDone, boolean registerFailed) {

    if (registerFailed && mbean instanceof DynamicMBean2)
        ((DynamicMBean2) mbean).registerFailed();
    try {
        if (mbean instanceof MBeanRegistration)
            ((MBeanRegistration) mbean).postRegister(registrationDone);
    } catch (RuntimeException e) {
        MBEANSERVER_LOGGER.fine("While registering MBean ["+logicalName+
                "]: " + "Exception thrown by postRegister: " +
                "rethrowing <"+e+">, but keeping the MBean registered");
        throw new RuntimeMBeanException(e,
                  "RuntimeException thrown in postRegister method: "+
                  "rethrowing <"+e+">, but keeping the MBean registered");
    } catch (Error er) {
        MBEANSERVER_LOGGER.fine("While registering MBean ["+logicalName+
                "]: " + "Error thrown by postRegister: " +
                "rethrowing <"+er+">, but keeping the MBean registered");
        throw new RuntimeErrorException(er,
                  "Error thrown in postRegister method: "+
                  "rethrowing <"+er+">, but keeping the MBean registered");
    }
}
 
Example #20
Source File: DefaultMBeanServerInterceptor.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private static void postRegister(
        ObjectName logicalName, DynamicMBean mbean,
        boolean registrationDone, boolean registerFailed) {

    if (registerFailed && mbean instanceof DynamicMBean2)
        ((DynamicMBean2) mbean).registerFailed();
    try {
        if (mbean instanceof MBeanRegistration)
            ((MBeanRegistration) mbean).postRegister(registrationDone);
    } catch (RuntimeException e) {
        MBEANSERVER_LOGGER.fine("While registering MBean ["+logicalName+
                "]: " + "Exception thrown by postRegister: " +
                "rethrowing <"+e+">, but keeping the MBean registered");
        throw new RuntimeMBeanException(e,
                  "RuntimeException thrown in postRegister method: "+
                  "rethrowing <"+e+">, but keeping the MBean registered");
    } catch (Error er) {
        MBEANSERVER_LOGGER.fine("While registering MBean ["+logicalName+
                "]: " + "Error thrown by postRegister: " +
                "rethrowing <"+er+">, but keeping the MBean registered");
        throw new RuntimeErrorException(er,
                  "Error thrown in postRegister method: "+
                  "rethrowing <"+er+">, but keeping the MBean registered");
    }
}
 
Example #21
Source File: DefaultMBeanServerInterceptor.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private void exclusiveUnregisterMBean(ObjectName name)
        throws InstanceNotFoundException, MBeanRegistrationException {

    DynamicMBean instance = getMBean(name);
    // may throw InstanceNotFoundException

    checkMBeanPermission(instance, null, name, "unregisterMBean");

    if (instance instanceof MBeanRegistration)
        preDeregisterInvoke((MBeanRegistration) instance);

    final Object resource = getResource(instance);

    // Unregisters the MBean from the repository.
    // Returns the resource context that was used.
    // The returned context does nothing for regular MBeans.
    // For ClassLoader MBeans and JMXNamespace (and JMXDomain)
    // MBeans - the context makes it possible to unregister these
    // objects from the appropriate framework artifacts, such as
    // the CLR or the dispatcher, from within the repository lock.
    // In case of success, we also need to call context.done() at the
    // end of this method.
    //
    final ResourceContext context =
            unregisterFromRepository(resource, instance, name);

    try {
        if (instance instanceof MBeanRegistration)
            postDeregisterInvoke(name,(MBeanRegistration) instance);
    } finally {
        context.done();
    }
}
 
Example #22
Source File: DefaultMBeanServerInterceptor.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private void exclusiveUnregisterMBean(ObjectName name)
        throws InstanceNotFoundException, MBeanRegistrationException {

    DynamicMBean instance = getMBean(name);
    // may throw InstanceNotFoundException

    checkMBeanPermission(instance, null, name, "unregisterMBean");

    if (instance instanceof MBeanRegistration)
        preDeregisterInvoke((MBeanRegistration) instance);

    final Object resource = getResource(instance);

    // Unregisters the MBean from the repository.
    // Returns the resource context that was used.
    // The returned context does nothing for regular MBeans.
    // For ClassLoader MBeans and JMXNamespace (and JMXDomain)
    // MBeans - the context makes it possible to unregister these
    // objects from the appropriate framework artifacts, such as
    // the CLR or the dispatcher, from within the repository lock.
    // In case of success, we also need to call context.done() at the
    // end of this method.
    //
    final ResourceContext context =
            unregisterFromRepository(resource, instance, name);

    try {
        if (instance instanceof MBeanRegistration)
            postDeregisterInvoke(name,(MBeanRegistration) instance);
    } finally {
        context.done();
    }
}
 
Example #23
Source File: DefaultMBeanServerInterceptor.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private static void preDeregisterInvoke(MBeanRegistration moi)
        throws MBeanRegistrationException {
    try {
        moi.preDeregister();
    } catch (Throwable t) {
        throwMBeanRegistrationException(t, "in preDeregister method");
    }
}
 
Example #24
Source File: DefaultMBeanServerInterceptor.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
private static void preDeregisterInvoke(MBeanRegistration moi)
        throws MBeanRegistrationException {
    try {
        moi.preDeregister();
    } catch (Throwable t) {
        throwMBeanRegistrationException(t, "in preDeregister method");
    }
}
 
Example #25
Source File: BaseModelMBean.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
@Override
public ObjectName preRegister(MBeanServer server,
                              ObjectName name)
        throws Exception
{
    if( log.isDebugEnabled())
        log.debug("preRegister " + resource + " " + name );
    oname=name;
    if( resource instanceof MBeanRegistration ) {
        oname = ((MBeanRegistration)resource).preRegister(server, name );
    }
    return oname;
}
 
Example #26
Source File: OldMBeanServerTest.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public void unregisterMBean(ObjectName name)
throws InstanceNotFoundException, MBeanRegistrationException {

    forbidJMImpl(name);

    DynamicMBean mbean = getMBean(name);
    if (mbean == null)
        throw new InstanceNotFoundException(name.toString());

    MBeanRegistration reg = mbeanRegistration(mbean);
    try {
        reg.preDeregister();
    } catch (Exception e) {
        throw new MBeanRegistrationException(e);
    }
    if (!mbeans.remove(name, mbean))
        throw new InstanceNotFoundException(name.toString());
        // This is incorrect because we've invoked preDeregister

    Object userMBean = getUserMBean(mbean);
    if (userMBean instanceof ClassLoader)
        clr.removeLoader((ClassLoader) userMBean);

    Notification n = new MBeanServerNotification(
            MBeanServerNotification.REGISTRATION_NOTIFICATION,
            MBeanServerDelegate.DELEGATE_NAME,
            0,
            name);
    delegate.sendNotification(n);

    reg.postDeregister();
}
 
Example #27
Source File: MBeanSupport.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public final void postDeregister() {
    // Undo any work from registration.  We do this in postDeregister
    // not preDeregister, because if the user preDeregister throws an
    // exception then the MBean is not unregistered.
    try {
        unregister();
    } finally {
        if (resource instanceof MBeanRegistration)
            ((MBeanRegistration) resource).postDeregister();
    }
}
 
Example #28
Source File: DefaultMBeanServerInterceptor.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private static void preDeregisterInvoke(MBeanRegistration moi)
        throws MBeanRegistrationException {
    try {
        moi.preDeregister();
    } catch (Throwable t) {
        throwMBeanRegistrationException(t, "in preDeregister method");
    }
}
 
Example #29
Source File: DefaultMBeanServerInterceptor.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
private static void preDeregisterInvoke(MBeanRegistration moi)
        throws MBeanRegistrationException {
    try {
        moi.preDeregister();
    } catch (Throwable t) {
        throwMBeanRegistrationException(t, "in preDeregister method");
    }
}
 
Example #30
Source File: DefaultMBeanServerInterceptor.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private void exclusiveUnregisterMBean(ObjectName name)
        throws InstanceNotFoundException, MBeanRegistrationException {

    DynamicMBean instance = getMBean(name);
    // may throw InstanceNotFoundException

    checkMBeanPermission(instance, null, name, "unregisterMBean");

    if (instance instanceof MBeanRegistration)
        preDeregisterInvoke((MBeanRegistration) instance);

    final Object resource = getResource(instance);

    // Unregisters the MBean from the repository.
    // Returns the resource context that was used.
    // The returned context does nothing for regular MBeans.
    // For ClassLoader MBeans and JMXNamespace (and JMXDomain)
    // MBeans - the context makes it possible to unregister these
    // objects from the appropriate framework artifacts, such as
    // the CLR or the dispatcher, from within the repository lock.
    // In case of success, we also need to call context.done() at the
    // end of this method.
    //
    final ResourceContext context =
            unregisterFromRepository(resource, instance, name);

    try {
        if (instance instanceof MBeanRegistration)
            postDeregisterInvoke(name,(MBeanRegistration) instance);
    } finally {
        context.done();
    }
}