javax.management.MBeanRegistrationException Java Examples

The following examples show how to use javax.management.MBeanRegistrationException. 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: RMIConnector.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
public void unregisterMBean(ObjectName name)
throws InstanceNotFoundException,
        MBeanRegistrationException,
        IOException {
    if (logger.debugOn())
        logger.debug("unregisterMBean", "name=" + name);

    final ClassLoader old = pushDefaultClassLoader();
    try {
        connection.unregisterMBean(name, delegationSubject);
    } catch (IOException ioe) {
        communicatorAdmin.gotIOException(ioe);

        connection.unregisterMBean(name, delegationSubject);
    } finally {
        popDefaultClassLoader(old);
    }
}
 
Example #2
Source File: ManagementFactory.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * Registers a DynamicMBean.
 */
private static void addDynamicMBean(final MBeanServer mbs,
                                    final DynamicMBean dmbean,
                                    final ObjectName on) {
    try {
        AccessController.doPrivileged(new PrivilegedExceptionAction<Void>() {
            @Override
            public Void run() throws InstanceAlreadyExistsException,
                                     MBeanRegistrationException,
                                     NotCompliantMBeanException {
                mbs.registerMBean(dmbean, on);
                return null;
            }
        });
    } catch (PrivilegedActionException e) {
        throw new RuntimeException(e.getException());
    }
}
 
Example #3
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 #4
Source File: DefaultMBeanServerInterceptor.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
public ObjectInstance registerMBean(Object object, ObjectName name)
    throws InstanceAlreadyExistsException, MBeanRegistrationException,
    NotCompliantMBeanException  {

    // ------------------------------
    // ------------------------------
    Class<?> theClass = object.getClass();

    Introspector.checkCompliance(theClass);

    final String infoClassName = getNewMBeanClassName(object);

    checkMBeanPermission(infoClassName, null, name, "registerMBean");
    checkMBeanTrustPermission(theClass);

    return registerObject(infoClassName, object, name);
}
 
Example #5
Source File: MBeanServerAccessController.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * Call <code>checkCreate(className)</code>, then forward this method to the
 * wrapped object.
 */
public ObjectInstance createMBean(String className,
                                  ObjectName name,
                                  ObjectName loaderName)
    throws
    ReflectionException,
    InstanceAlreadyExistsException,
    MBeanRegistrationException,
    MBeanException,
    NotCompliantMBeanException,
    InstanceNotFoundException {
    checkCreate(className);
    SecurityManager sm = System.getSecurityManager();
    if (sm == null) {
        Object object = getMBeanServer().instantiate(className,
                                                     loaderName);
        checkClassLoader(object);
        return getMBeanServer().registerMBean(object, name);
    } else {
        return getMBeanServer().createMBean(className, name, loaderName);
    }
}
 
Example #6
Source File: ManagementFactory.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Registers a DynamicMBean.
 */
private static void addDynamicMBean(final MBeanServer mbs,
                                    final DynamicMBean dmbean,
                                    final ObjectName on) {
    try {
        AccessController.doPrivileged(new PrivilegedExceptionAction<Void>() {
            @Override
            public Void run() throws InstanceAlreadyExistsException,
                                     MBeanRegistrationException,
                                     NotCompliantMBeanException {
                mbs.registerMBean(dmbean, on);
                return null;
            }
        });
    } catch (PrivilegedActionException e) {
        throw new RuntimeException(e.getException());
    }
}
 
Example #7
Source File: RMIConnector.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
public void unregisterMBean(ObjectName name)
throws InstanceNotFoundException,
        MBeanRegistrationException,
        IOException {
    if (logger.debugOn())
        logger.debug("unregisterMBean", "name=" + name);

    final ClassLoader old = pushDefaultClassLoader();
    try {
        connection.unregisterMBean(name, delegationSubject);
    } catch (IOException ioe) {
        communicatorAdmin.gotIOException(ioe);

        connection.unregisterMBean(name, delegationSubject);
    } finally {
        popDefaultClassLoader(old);
    }
}
 
Example #8
Source File: DefaultMBeanServerInterceptor.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public ObjectInstance registerMBean(Object object, ObjectName name)
    throws InstanceAlreadyExistsException, MBeanRegistrationException,
    NotCompliantMBeanException  {

    // ------------------------------
    // ------------------------------
    Class<?> theClass = object.getClass();

    Introspector.checkCompliance(theClass);

    final String infoClassName = getNewMBeanClassName(object);

    checkMBeanPermission(infoClassName, null, name, "registerMBean");
    checkMBeanTrustPermission(theClass);

    return registerObject(infoClassName, object, name);
}
 
Example #9
Source File: DefaultMBeanServerInterceptor.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
public ObjectInstance createMBean(String className, ObjectName name,
                                  Object[] params, String[] signature)
    throws ReflectionException, InstanceAlreadyExistsException,
           MBeanRegistrationException, MBeanException,
           NotCompliantMBeanException  {

    try {
        return createMBean(className, name, null, true,
                           params, signature);
    } catch (InstanceNotFoundException e) {
        /* Can only happen if loaderName doesn't exist, but we just
           passed null, so we shouldn't get this exception.  */
        throw EnvHelp.initCause(
            new IllegalArgumentException("Unexpected exception: " + e), e);
    }
}
 
Example #10
Source File: DefaultMBeanServerInterceptor.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
public ObjectInstance registerMBean(Object object, ObjectName name)
    throws InstanceAlreadyExistsException, MBeanRegistrationException,
    NotCompliantMBeanException  {

    // ------------------------------
    // ------------------------------
    Class<?> theClass = object.getClass();

    Introspector.checkCompliance(theClass);

    final String infoClassName = getNewMBeanClassName(object);

    checkMBeanPermission(infoClassName, null, name, "registerMBean");
    checkMBeanTrustPermission(theClass);

    return registerObject(infoClassName, object, name);
}
 
Example #11
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 #12
Source File: MBeanServerAccessController.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Call <code>checkCreate(className)</code>, then forward this method to the
 * wrapped object.
 */
public ObjectInstance createMBean(String className,
                                  ObjectName name,
                                  ObjectName loaderName)
    throws
    ReflectionException,
    InstanceAlreadyExistsException,
    MBeanRegistrationException,
    MBeanException,
    NotCompliantMBeanException,
    InstanceNotFoundException {
    checkCreate(className);
    SecurityManager sm = System.getSecurityManager();
    if (sm == null) {
        Object object = getMBeanServer().instantiate(className,
                                                     loaderName);
        checkClassLoader(object);
        return getMBeanServer().registerMBean(object, name);
    } else {
        return getMBeanServer().createMBean(className, name, loaderName);
    }
}
 
Example #13
Source File: MBeanServerAccessController.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Call <code>checkCreate(className)</code>, then forward this method to the
 * wrapped object.
 */
public ObjectInstance createMBean(String className, ObjectName name)
    throws
    ReflectionException,
    InstanceAlreadyExistsException,
    MBeanRegistrationException,
    MBeanException,
    NotCompliantMBeanException {
    checkCreate(className);
    SecurityManager sm = System.getSecurityManager();
    if (sm == null) {
        Object object = getMBeanServer().instantiate(className);
        checkClassLoader(object);
        return getMBeanServer().registerMBean(object, name);
    } else {
        return getMBeanServer().createMBean(className, name);
    }
}
 
Example #14
Source File: MBeanServerAccessController.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Call <code>checkCreate(className)</code>, then forward this method to the
 * wrapped object.
 */
public ObjectInstance createMBean(String className, ObjectName name,
                                  Object params[], String signature[])
    throws
    ReflectionException,
    InstanceAlreadyExistsException,
    MBeanRegistrationException,
    MBeanException,
    NotCompliantMBeanException {
    checkCreate(className);
    SecurityManager sm = System.getSecurityManager();
    if (sm == null) {
        Object object = getMBeanServer().instantiate(className,
                                                     params,
                                                     signature);
        checkClassLoader(object);
        return getMBeanServer().registerMBean(object, name);
    } else {
        return getMBeanServer().createMBean(className, name,
                                            params, signature);
    }
}
 
Example #15
Source File: MBeanServerAccessController.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Call <code>checkCreate(className)</code>, then forward this method to the
 * wrapped object.
 */
public ObjectInstance createMBean(String className,
                                  ObjectName name,
                                  ObjectName loaderName)
    throws
    ReflectionException,
    InstanceAlreadyExistsException,
    MBeanRegistrationException,
    MBeanException,
    NotCompliantMBeanException,
    InstanceNotFoundException {
    checkCreate(className);
    SecurityManager sm = System.getSecurityManager();
    if (sm == null) {
        Object object = getMBeanServer().instantiate(className,
                                                     loaderName);
        checkClassLoader(object);
        return getMBeanServer().registerMBean(object, name);
    } else {
        return getMBeanServer().createMBean(className, name, loaderName);
    }
}
 
Example #16
Source File: DefaultMBeanServerInterceptor.java    From dragonwell8_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 #17
Source File: PoolableConnection.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
/**
 *
 * @param conn
 *            my underlying connection
 * @param pool
 *            the pool to which I should return when closed
 * @param jmxObjectName
 *            JMX name
 * @param disconnectSqlCodes
 *            SQL_STATE codes considered fatal disconnection errors
 * @param fastFailValidation
 *            true means fatal disconnection errors cause subsequent validations to fail immediately (no attempt to
 *            run query or isValid)
 */
public PoolableConnection(final Connection conn, final ObjectPool<PoolableConnection> pool,
        final ObjectName jmxObjectName, final Collection<String> disconnectSqlCodes,
        final boolean fastFailValidation) {
    super(conn);
    this.pool = pool;
    this.jmxObjectName = ObjectNameWrapper.wrap(jmxObjectName);
    this.disconnectionSqlCodes = disconnectSqlCodes;
    this.fastFailValidation = fastFailValidation;

    if (jmxObjectName != null) {
        try {
            MBEAN_SERVER.registerMBean(this, jmxObjectName);
        } catch (InstanceAlreadyExistsException | MBeanRegistrationException | NotCompliantMBeanException e) {
            // For now, simply skip registration
        }
    }
}
 
Example #18
Source File: MBeanServerAccessController.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Call <code>checkCreate(className)</code>, then forward this method to the
 * wrapped object.
 */
public ObjectInstance createMBean(String className, ObjectName name,
                                  Object params[], String signature[])
    throws
    ReflectionException,
    InstanceAlreadyExistsException,
    MBeanRegistrationException,
    MBeanException,
    NotCompliantMBeanException {
    checkCreate(className);
    SecurityManager sm = System.getSecurityManager();
    if (sm == null) {
        Object object = getMBeanServer().instantiate(className,
                                                     params,
                                                     signature);
        checkClassLoader(object);
        return getMBeanServer().registerMBean(object, name);
    } else {
        return getMBeanServer().createMBean(className, name,
                                            params, signature);
    }
}
 
Example #19
Source File: DefaultMBeanServerInterceptor.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public ObjectInstance createMBean(String className, ObjectName name,
                                  Object[] params, String[] signature)
    throws ReflectionException, InstanceAlreadyExistsException,
           MBeanRegistrationException, MBeanException,
           NotCompliantMBeanException  {

    try {
        return createMBean(className, name, null, true,
                           params, signature);
    } catch (InstanceNotFoundException e) {
        /* Can only happen if loaderName doesn't exist, but we just
           passed null, so we shouldn't get this exception.  */
        throw EnvHelp.initCause(
            new IllegalArgumentException("Unexpected exception: " + e), e);
    }
}
 
Example #20
Source File: DefaultMBeanServerInterceptor.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public ObjectInstance createMBean(String className, ObjectName name)
    throws ReflectionException, InstanceAlreadyExistsException,
           MBeanRegistrationException, MBeanException,
           NotCompliantMBeanException {

    return createMBean(className, name, (Object[]) null, (String[]) null);

}
 
Example #21
Source File: RMIConnector.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public ObjectInstance createMBean(String className,
        ObjectName name,
        ObjectName loaderName,
        Object params[],
        String signature[])
        throws ReflectionException,
        InstanceAlreadyExistsException,
        MBeanRegistrationException,
        MBeanException,
        NotCompliantMBeanException,
        InstanceNotFoundException,
        IOException {
    if (logger.debugOn()) logger.debug(
            "createMBean(String,ObjectName,ObjectName,Object[],String[])",
            "className=" + className + ", name=" + name + ", loaderName="
            + loaderName + ", signature=" + strings(signature));

    final MarshalledObject<Object[]> sParams =
            new MarshalledObject<Object[]>(params);
    final ClassLoader old = pushDefaultClassLoader();
    try {
        return connection.createMBean(className,
                name,
                loaderName,
                sParams,
                signature,
                delegationSubject);
    } catch (IOException ioe) {
        communicatorAdmin.gotIOException(ioe);

        return connection.createMBean(className,
                name,
                loaderName,
                sParams,
                signature,
                delegationSubject);
    } finally {
        popDefaultClassLoader(old);
    }
}
 
Example #22
Source File: DefaultMBeanServerInterceptor.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
public ObjectInstance createMBean(String className, ObjectName name,
                                  ObjectName loaderName)
    throws ReflectionException, InstanceAlreadyExistsException,
           MBeanRegistrationException, MBeanException,
           NotCompliantMBeanException, InstanceNotFoundException {

    return createMBean(className, name, loaderName, (Object[]) null,
                       (String[]) null);
}
 
Example #23
Source File: DefaultMBeanServerInterceptor.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Adds a MBean in the repository,
 * sends MBeanServerNotification.REGISTRATION_NOTIFICATION,
 * returns ResourceContext for special resources such as ClassLoaders
 * or JMXNamespaces. For regular MBean this method returns
 * ResourceContext.NONE.
 * @return a ResourceContext for special resources such as ClassLoaders
 *         or JMXNamespaces.
 */
private ResourceContext registerWithRepository(
        final Object resource,
        final DynamicMBean object,
        final ObjectName logicalName)
        throws InstanceAlreadyExistsException,
        MBeanRegistrationException {

    // Creates a registration context, if needed.
    //
    final ResourceContext context =
            makeResourceContextFor(resource, logicalName);


    repository.addMBean(object, logicalName, context);
    // May throw InstanceAlreadyExistsException

    // ---------------------
    // Send create event
    // ---------------------
    if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) {
        MBEANSERVER_LOGGER.logp(Level.FINER,
                DefaultMBeanServerInterceptor.class.getName(),
                "addObject", "Send create notification of object " +
                logicalName.getCanonicalName());
    }

    sendNotification(
            MBeanServerNotification.REGISTRATION_NOTIFICATION,
            logicalName);

    return context;
}
 
Example #24
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 #25
Source File: RMIConnector.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public ObjectInstance createMBean(String className,
        ObjectName name)
        throws ReflectionException,
        InstanceAlreadyExistsException,
        MBeanRegistrationException,
        MBeanException,
        NotCompliantMBeanException,
        IOException {
    if (logger.debugOn())
        logger.debug("createMBean(String,ObjectName)",
                "className=" + className + ", name=" +
                name);

    final ClassLoader old = pushDefaultClassLoader();
    try {
        return connection.createMBean(className,
                name,
                delegationSubject);
    } catch (IOException ioe) {
        communicatorAdmin.gotIOException(ioe);

        return connection.createMBean(className,
                name,
                delegationSubject);
    } finally {
        popDefaultClassLoader(old);
    }
}
 
Example #26
Source File: DefaultMBeanServerInterceptor.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public ObjectInstance createMBean(String className, ObjectName name,
                                  ObjectName loaderName,
                                  Object[] params, String[] signature)
    throws ReflectionException, InstanceAlreadyExistsException,
           MBeanRegistrationException, MBeanException,
           NotCompliantMBeanException, InstanceNotFoundException  {

    return createMBean(className, name, loaderName, false,
                       params, signature);
}
 
Example #27
Source File: DefaultMBeanServerInterceptor.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public ObjectInstance createMBean(String className, ObjectName name,
                                  ObjectName loaderName)
    throws ReflectionException, InstanceAlreadyExistsException,
           MBeanRegistrationException, MBeanException,
           NotCompliantMBeanException, InstanceNotFoundException {

    return createMBean(className, name, loaderName, (Object[]) null,
                       (String[]) null);
}
 
Example #28
Source File: DefaultMBeanServerInterceptor.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public ObjectInstance createMBean(String className, ObjectName name)
    throws ReflectionException, InstanceAlreadyExistsException,
           MBeanRegistrationException, MBeanException,
           NotCompliantMBeanException {

    return createMBean(className, name, (Object[]) null, (String[]) null);

}
 
Example #29
Source File: DefaultMBeanServerInterceptor.java    From jdk1.8-source-analysis with Apache License 2.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 #30
Source File: DefaultMBeanServerInterceptor.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public ObjectInstance createMBean(String className, ObjectName name,
                                  ObjectName loaderName)
    throws ReflectionException, InstanceAlreadyExistsException,
           MBeanRegistrationException, MBeanException,
           NotCompliantMBeanException, InstanceNotFoundException {

    return createMBean(className, name, loaderName, (Object[]) null,
                       (String[]) null);
}