当前位置: 首页>>代码示例>>Java>>正文


Java DynamicMBean2类代码示例

本文整理汇总了Java中com.sun.jmx.mbeanserver.DynamicMBean2的典型用法代码示例。如果您正苦于以下问题:Java DynamicMBean2类的具体用法?Java DynamicMBean2怎么用?Java DynamicMBean2使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


DynamicMBean2类属于com.sun.jmx.mbeanserver包,在下文中一共展示了DynamicMBean2类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: postRegister

import com.sun.jmx.mbeanserver.DynamicMBean2; //导入依赖的package包/类
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");
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:26,代码来源:DefaultMBeanServerInterceptor.java

示例2: getNotificationBroadcaster

import com.sun.jmx.mbeanserver.DynamicMBean2; //导入依赖的package包/类
private static <T extends NotificationBroadcaster>
        T getNotificationBroadcaster(ObjectName name, Object instance,
                                     Class<T> reqClass) {
    if (reqClass.isInstance(instance))
        return reqClass.cast(instance);
    if (instance instanceof DynamicMBean2)
        instance = ((DynamicMBean2) instance).getResource();
    if (reqClass.isInstance(instance))
        return reqClass.cast(instance);
    final RuntimeException exc =
        new IllegalArgumentException(name.getCanonicalName());
    final String msg =
        "MBean " + name.getCanonicalName() + " does not " +
        "implement " + reqClass.getName();
    throw new RuntimeOperationsException(exc, msg);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:17,代码来源:DefaultMBeanServerInterceptor.java

示例3: postRegister

import com.sun.jmx.mbeanserver.DynamicMBean2; //导入依赖的package包/类
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");
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:26,代码来源:DefaultMBeanServerInterceptor.java

示例4: registerDynamicMBean

import com.sun.jmx.mbeanserver.DynamicMBean2; //导入依赖的package包/类
private ObjectInstance registerDynamicMBean(String classname,
                                            DynamicMBean mbean,
                                            ObjectName name)
    throws InstanceAlreadyExistsException,
           MBeanRegistrationException,
           NotCompliantMBeanException {


    name = nonDefaultDomain(name);

    if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) {
        MBEANSERVER_LOGGER.logp(Level.FINER,
                DefaultMBeanServerInterceptor.class.getName(),
                "registerMBean", "ObjectName = " + name);
    }

    ObjectName logicalName = preRegister(mbean, server, name);

    // preRegister returned successfully, so from this point on we
    // must call postRegister(false) if there is any problem.
    boolean registered = false;
    boolean registerFailed = false;
    ResourceContext context = null;

    try {
        if (mbean instanceof DynamicMBean2) {
            try {
                ((DynamicMBean2) mbean).preRegister2(server, logicalName);
                registerFailed = true;  // until we succeed
            } catch (Exception e) {
                if (e instanceof RuntimeException)
                    throw (RuntimeException) e;
                if (e instanceof InstanceAlreadyExistsException)
                    throw (InstanceAlreadyExistsException) e;
                throw new RuntimeException(e);
            }
        }

        if (logicalName != name && logicalName != null) {
            logicalName =
                    ObjectName.getInstance(nonDefaultDomain(logicalName));
        }

        checkMBeanPermission(classname, null, logicalName, "registerMBean");

        if (logicalName == null) {
            final RuntimeException wrapped =
                new IllegalArgumentException("No object name specified");
            throw new RuntimeOperationsException(wrapped,
                        "Exception occurred trying to register the MBean");
        }

        final Object resource = getResource(mbean);

        // Register the MBean with the repository.
        // Returns the resource context that was used.
        // The returned context does nothing for regular MBeans.
        // For ClassLoader MBeans the context makes it possible to register these
        // objects with the appropriate framework artifacts, such as
        // the CLR, from within the repository lock.
        // In case of success, we also need to call context.done() at the
        // end of this method.
        //
        context = registerWithRepository(resource, mbean, logicalName);


        registerFailed = false;
        registered = true;

    } finally {
        try {
            postRegister(logicalName, mbean, registered, registerFailed);
        } finally {
            if (registered && context!=null) context.done();
        }
    }
    return new ObjectInstance(logicalName, classname);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:79,代码来源:DefaultMBeanServerInterceptor.java

示例5: getResource

import com.sun.jmx.mbeanserver.DynamicMBean2; //导入依赖的package包/类
private static Object getResource(DynamicMBean mbean) {
    if (mbean instanceof DynamicMBean2)
        return ((DynamicMBean2) mbean).getResource();
    else
        return mbean;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:7,代码来源:DefaultMBeanServerInterceptor.java

示例6: getClassName

import com.sun.jmx.mbeanserver.DynamicMBean2; //导入依赖的package包/类
private static String getClassName(DynamicMBean mbean) {
    if (mbean instanceof DynamicMBean2)
        return ((DynamicMBean2) mbean).getClassName();
    else
        return mbean.getMBeanInfo().getClassName();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:7,代码来源:DefaultMBeanServerInterceptor.java

示例7: registerDynamicMBean

import com.sun.jmx.mbeanserver.DynamicMBean2; //导入依赖的package包/类
private ObjectInstance registerDynamicMBean(String classname,
                                            DynamicMBean mbean,
                                            ObjectName name)
    throws InstanceAlreadyExistsException,
           MBeanRegistrationException,
           NotCompliantMBeanException {


    name = nonDefaultDomain(name);

    if (MBEANSERVER_LOGGER.isLoggable(Level.TRACE)) {
        MBEANSERVER_LOGGER.log(Level.TRACE,
                "ObjectName = " + name);
    }

    ObjectName logicalName = preRegister(mbean, server, name);

    // preRegister returned successfully, so from this point on we
    // must call postRegister(false) if there is any problem.
    boolean registered = false;
    boolean registerFailed = false;
    ResourceContext context = null;

    try {
        if (mbean instanceof DynamicMBean2) {
            try {
                ((DynamicMBean2) mbean).preRegister2(server, logicalName);
                registerFailed = true;  // until we succeed
            } catch (Exception e) {
                if (e instanceof RuntimeException)
                    throw (RuntimeException) e;
                if (e instanceof InstanceAlreadyExistsException)
                    throw (InstanceAlreadyExistsException) e;
                throw new RuntimeException(e);
            }
        }

        if (logicalName != name && logicalName != null) {
            logicalName =
                    ObjectName.getInstance(nonDefaultDomain(logicalName));
        }

        checkMBeanPermission(classname, null, logicalName, "registerMBean");

        if (logicalName == null) {
            final RuntimeException wrapped =
                new IllegalArgumentException("No object name specified");
            throw new RuntimeOperationsException(wrapped,
                        "Exception occurred trying to register the MBean");
        }

        final Object resource = getResource(mbean);

        // Register the MBean with the repository.
        // Returns the resource context that was used.
        // The returned context does nothing for regular MBeans.
        // For ClassLoader MBeans the context makes it possible to register these
        // objects with the appropriate framework artifacts, such as
        // the CLR, from within the repository lock.
        // In case of success, we also need to call context.done() at the
        // end of this method.
        //
        context = registerWithRepository(resource, mbean, logicalName);


        registerFailed = false;
        registered = true;

    } finally {
        try {
            postRegister(logicalName, mbean, registered, registerFailed);
        } finally {
            if (registered && context!=null) context.done();
        }
    }
    return new ObjectInstance(logicalName, classname);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:78,代码来源:DefaultMBeanServerInterceptor.java


注:本文中的com.sun.jmx.mbeanserver.DynamicMBean2类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。