當前位置: 首頁>>代碼示例>>Java>>正文


Java ObjectName.getCanonicalName方法代碼示例

本文整理匯總了Java中javax.management.ObjectName.getCanonicalName方法的典型用法代碼示例。如果您正苦於以下問題:Java ObjectName.getCanonicalName方法的具體用法?Java ObjectName.getCanonicalName怎麽用?Java ObjectName.getCanonicalName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.management.ObjectName的用法示例。


在下文中一共展示了ObjectName.getCanonicalName方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getListener

import javax.management.ObjectName; //導入方法依賴的package包/類
private NotificationListener getListener(ObjectName listener)
    throws ListenerNotFoundException {
    // ----------------
    // Get listener object
    // ----------------
    DynamicMBean instance;
    try {
        instance = getMBean(listener);
    } catch (InstanceNotFoundException e) {
        throw EnvHelp.initCause(
                      new ListenerNotFoundException(e.getMessage()), e);
    }

    Object resource = getResource(instance);
    if (!(resource instanceof NotificationListener)) {
        final RuntimeException exc =
            new IllegalArgumentException(listener.getCanonicalName());
        final String msg =
            "MBean " + listener.getCanonicalName() + " does not " +
            "implement " + NotificationListener.class.getName();
        throw new RuntimeOperationsException(exc, msg);
    }
    return (NotificationListener) resource;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:25,代碼來源:DefaultMBeanServerInterceptor.java

示例2: getNotificationBroadcaster

import javax.management.ObjectName; //導入方法依賴的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: findObjectName

import javax.management.ObjectName; //導入方法依賴的package包/類
/**
 * Find the first MBean with given canonical name and type.
 * @param mbs MBeanServerConnection to corresponding server
 * @param canonicalNamePart canonical name you are looking for
 * @param type given type for the object
 * @return ObjectName or null (default)
 */
public static ObjectName findObjectName(final MBeanServerConnection mbs, final String canonicalNamePart, final String type){
    try{
        for(final ObjectName on: mbs.queryNames(null,null)){
            final String fullObjectName = on.getCanonicalName();
            if(fullObjectName.contains(canonicalNamePart)){ //check if the canonicalNamePart is ok
                if(fullObjectName.contains(":type")){//make sure its a "valid" objectname
                    if(fullObjectName.split(":type")[1].contains(type)){//found your type
                        return on;
                    }
                }
            }
        }
    } catch (final IOException e) {
        log.log(Level.WARNING, "IO Exception during browse for ObjectNames with canonicalNamePart and given type. \n"
                + "See Stacktrace for more Information",e);
    }
    return null;
}
 
開發者ID:deB4SH,項目名稱:Byter,代碼行數:26,代碼來源:JmxHelper.java

示例4: registerMBean

import javax.management.ObjectName; //導入方法依賴的package包/類
@SuppressWarnings({
		"unchecked", "rawtypes"
})
public static String registerMBean(final Object object) throws JMException {
	final ObjectName objectName = generateMBeanName(object.getClass());
	final MBeanServer context = ManagementFactory.getPlatformMBeanServer();
	final String mbeanName = object.getClass().getName() + "MBean";
	for (final Class c : object.getClass().getInterfaces()) {
		if (mbeanName.equals(c.getName())) {
			context.registerMBean(new AnnotatedStandardMBean(object, c), objectName);
			return objectName.getCanonicalName();
		}
	}
	context.registerMBean(object, objectName);
	return objectName.getCanonicalName();
}
 
開發者ID:ggrandes,項目名稱:metrics-tomcat,代碼行數:17,代碼來源:AnnotatedStandardMBean.java

示例5: addNotificationListener

import javax.management.ObjectName; //導入方法依賴的package包/類
public void addNotificationListener(ObjectName name,
                                    ObjectName listener,
                                    NotificationFilter filter,
                                    Object handback)
        throws InstanceNotFoundException {

    // ------------------------------
    // ------------------------------

    // ----------------
    // Get listener object
    // ----------------
    DynamicMBean instance = getMBean(listener);
    Object resource = getResource(instance);
    if (!(resource instanceof NotificationListener)) {
        throw new RuntimeOperationsException(new
            IllegalArgumentException(listener.getCanonicalName()),
            "The MBean " + listener.getCanonicalName() +
            "does not implement the NotificationListener interface") ;
    }

    // ----------------
    // Add a listener on an MBean
    // ----------------
    if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) {
        MBEANSERVER_LOGGER.logp(Level.FINER,
                DefaultMBeanServerInterceptor.class.getName(),
                "addNotificationListener",
                "ObjectName = " + name + ", Listener = " + listener);
    }
    server.addNotificationListener(name,(NotificationListener) resource,
                                   filter, handback) ;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:34,代碼來源:DefaultMBeanServerInterceptor.java

示例6: addNotificationListener

import javax.management.ObjectName; //導入方法依賴的package包/類
public void addNotificationListener(ObjectName name,
                                    ObjectName listener,
                                    NotificationFilter filter,
                                    Object handback)
        throws InstanceNotFoundException {

    // ------------------------------
    // ------------------------------

    // ----------------
    // Get listener object
    // ----------------
    DynamicMBean instance = getMBean(listener);
    Object resource = getResource(instance);
    if (!(resource instanceof NotificationListener)) {
        throw new RuntimeOperationsException(new
            IllegalArgumentException(listener.getCanonicalName()),
            "The MBean " + listener.getCanonicalName() +
            " does not implement the NotificationListener interface") ;
    }

    // ----------------
    // Add a listener on an MBean
    // ----------------
    if (MBEANSERVER_LOGGER.isLoggable(Level.TRACE)) {
        MBEANSERVER_LOGGER.log(Level.TRACE,
                "ObjectName = " + name + ", Listener = " + listener);
    }
    server.addNotificationListener(name,(NotificationListener) resource,
                                   filter, handback) ;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:32,代碼來源:DefaultMBeanServerInterceptor.java


注:本文中的javax.management.ObjectName.getCanonicalName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。