javax.management.RuntimeMBeanException Java Examples

The following examples show how to use javax.management.RuntimeMBeanException. 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-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 #2
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 #3
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 #4
Source File: DefaultMBeanServerInterceptor.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
private static void throwMBeanRegistrationException(Throwable t, String where)
throws MBeanRegistrationException {
    if (t instanceof RuntimeException) {
        throw new RuntimeMBeanException((RuntimeException)t,
                "RuntimeException thrown " + where);
    } else if (t instanceof Error) {
        throw new RuntimeErrorException((Error)t,
                "Error thrown " + where);
    } else if (t instanceof MBeanRegistrationException) {
        throw (MBeanRegistrationException)t;
    } else if (t instanceof Exception) {
        throw new MBeanRegistrationException((Exception)t,
                "Exception thrown " + where);
    } else // neither Error nor Exception??
        throw new RuntimeException(t);
}
 
Example #5
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 #6
Source File: DefaultMBeanServerInterceptor.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private static void throwMBeanRegistrationException(Throwable t, String where)
throws MBeanRegistrationException {
    if (t instanceof RuntimeException) {
        throw new RuntimeMBeanException((RuntimeException)t,
                "RuntimeException thrown " + where);
    } else if (t instanceof Error) {
        throw new RuntimeErrorException((Error)t,
                "Error thrown " + where);
    } else if (t instanceof MBeanRegistrationException) {
        throw (MBeanRegistrationException)t;
    } else if (t instanceof Exception) {
        throw new MBeanRegistrationException((Exception)t,
                "Exception thrown " + where);
    } else // neither Error nor Exception??
        throw new RuntimeException(t);
}
 
Example #7
Source File: DefaultMBeanServerInterceptor.java    From openjdk-jdk9 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.log(Level.DEBUG, "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.log(Level.DEBUG, "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 #8
Source File: DefaultMBeanServerInterceptor.java    From openjdk-jdk9 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.log(Level.DEBUG, "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.log(Level.DEBUG, "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 #9
Source File: DefaultMBeanServerInterceptor.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
private static void throwMBeanRegistrationException(Throwable t, String where)
throws MBeanRegistrationException {
    if (t instanceof RuntimeException) {
        throw new RuntimeMBeanException((RuntimeException)t,
                "RuntimeException thrown " + where);
    } else if (t instanceof Error) {
        throw new RuntimeErrorException((Error)t,
                "Error thrown " + where);
    } else if (t instanceof MBeanRegistrationException) {
        throw (MBeanRegistrationException)t;
    } else if (t instanceof Exception) {
        throw new MBeanRegistrationException((Exception)t,
                "Exception thrown " + where);
    } else // neither Error nor Exception??
        throw new RuntimeException(t);
}
 
Example #10
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 #11
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 #12
Source File: DefaultMBeanServerInterceptor.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
private static void throwMBeanRegistrationException(Throwable t, String where)
throws MBeanRegistrationException {
    if (t instanceof RuntimeException) {
        throw new RuntimeMBeanException((RuntimeException)t,
                "RuntimeException thrown " + where);
    } else if (t instanceof Error) {
        throw new RuntimeErrorException((Error)t,
                "Error thrown " + where);
    } else if (t instanceof MBeanRegistrationException) {
        throw (MBeanRegistrationException)t;
    } else if (t instanceof Exception) {
        throw new MBeanRegistrationException((Exception)t,
                "Exception thrown " + where);
    } else // neither Error nor Exception??
        throw new RuntimeException(t);
}
 
Example #13
Source File: DefaultMBeanServerInterceptor.java    From hottub 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 hottub 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 #15
Source File: DefaultMBeanServerInterceptor.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
private static void throwMBeanRegistrationException(Throwable t, String where)
throws MBeanRegistrationException {
    if (t instanceof RuntimeException) {
        throw new RuntimeMBeanException((RuntimeException)t,
                "RuntimeException thrown " + where);
    } else if (t instanceof Error) {
        throw new RuntimeErrorException((Error)t,
                "Error thrown " + where);
    } else if (t instanceof MBeanRegistrationException) {
        throw (MBeanRegistrationException)t;
    } else if (t instanceof Exception) {
        throw new MBeanRegistrationException((Exception)t,
                "Exception thrown " + where);
    } else // neither Error nor Exception??
        throw new RuntimeException(t);
}
 
Example #16
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 #17
Source File: DefaultMBeanServerInterceptor.java    From openjdk-8-source 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 #18
Source File: DefaultMBeanServerInterceptor.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
private static void throwMBeanRegistrationException(Throwable t, String where)
throws MBeanRegistrationException {
    if (t instanceof RuntimeException) {
        throw new RuntimeMBeanException((RuntimeException)t,
                "RuntimeException thrown " + where);
    } else if (t instanceof Error) {
        throw new RuntimeErrorException((Error)t,
                "Error thrown " + where);
    } else if (t instanceof MBeanRegistrationException) {
        throw (MBeanRegistrationException)t;
    } else if (t instanceof Exception) {
        throw new MBeanRegistrationException((Exception)t,
                "Exception thrown " + where);
    } else // neither Error nor Exception??
        throw new RuntimeException(t);
}
 
Example #19
Source File: DefaultMBeanServerInterceptor.java    From openjdk-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 #20
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 #21
Source File: DefaultMBeanServerInterceptor.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
private static void throwMBeanRegistrationException(Throwable t, String where)
throws MBeanRegistrationException {
    if (t instanceof RuntimeException) {
        throw new RuntimeMBeanException((RuntimeException)t,
                "RuntimeException thrown " + where);
    } else if (t instanceof Error) {
        throw new RuntimeErrorException((Error)t,
                "Error thrown " + where);
    } else if (t instanceof MBeanRegistrationException) {
        throw (MBeanRegistrationException)t;
    } else if (t instanceof Exception) {
        throw new MBeanRegistrationException((Exception)t,
                "Exception thrown " + where);
    } else // neither Error nor Exception??
        throw new RuntimeException(t);
}
 
Example #22
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 #23
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 #24
Source File: DefaultMBeanServerInterceptor.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
private static void throwMBeanRegistrationException(Throwable t, String where)
throws MBeanRegistrationException {
    if (t instanceof RuntimeException) {
        throw new RuntimeMBeanException((RuntimeException)t,
                "RuntimeException thrown " + where);
    } else if (t instanceof Error) {
        throw new RuntimeErrorException((Error)t,
                "Error thrown " + where);
    } else if (t instanceof MBeanRegistrationException) {
        throw (MBeanRegistrationException)t;
    } else if (t instanceof Exception) {
        throw new MBeanRegistrationException((Exception)t,
                "Exception thrown " + where);
    } else // neither Error nor Exception??
        throw new RuntimeException(t);
}
 
Example #25
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 #26
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 #27
Source File: DefaultMBeanServerInterceptor.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
private static void throwMBeanRegistrationException(Throwable t, String where)
throws MBeanRegistrationException {
    if (t instanceof RuntimeException) {
        throw new RuntimeMBeanException((RuntimeException)t,
                "RuntimeException thrown " + where);
    } else if (t instanceof Error) {
        throw new RuntimeErrorException((Error)t,
                "Error thrown " + where);
    } else if (t instanceof MBeanRegistrationException) {
        throw (MBeanRegistrationException)t;
    } else if (t instanceof Exception) {
        throw new MBeanRegistrationException((Exception)t,
                "Exception thrown " + where);
    } else // neither Error nor Exception??
        throw new RuntimeException(t);
}
 
Example #28
Source File: DefaultMBeanServerInterceptor.java    From jdk8u-dev-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 #29
Source File: DefaultMBeanServerInterceptor.java    From jdk8u-dev-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 #30
Source File: ManagementExceptionHandlingTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
@Test
@BMRules(
        rules = {@BMRule(
                name = "checking ActiveMQServerControl methods",
                targetClass = "org.apache.activemq.artemis.core.postoffice.impl.PostOfficeImpl",
                targetMethod = "route(org.apache.activemq.artemis.api.core.Message, boolean)",
                targetLocation = "ENTRY",
                action = "throw new org.apache.activemq.artemis.api.core.ActiveMQException(\"gotcha\")")})
public void testAddressControl() throws Exception {
   server.getActiveMQServerControl().createAddress("test.address", "ANYCAST");
   MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
   log.debug("server is " + mbs);
   ObjectName objectName = new ObjectName("org.apache.activemq.artemis:broker=\"localhost\",component=addresses,address=\"test.address\"");
   Object[] params = new Object[] {new HashMap(), 3, "aGVsbG8=", true, null, null};
   String[] signature = new String[] {"java.util.Map", "int", "java.lang.String", "boolean", "java.lang.String", "java.lang.String"};
   try {
      mbs.invoke(objectName, "sendMessage", params, signature);
      fail("test should have gotten an exception!");
   } catch (RuntimeMBeanException ex) {
      assertTrue(ex.getCause() instanceof IllegalStateException);
      IllegalStateException e = (IllegalStateException) ex.getCause();
      assertEquals("gotcha", e.getMessage());
   }
}