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


Java NotificationBroadcaster类代码示例

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


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

示例1: getNotificationBroadcaster

import javax.management.NotificationBroadcaster; //导入依赖的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

示例2: isDefinitelyImmutableInfo

import javax.management.NotificationBroadcaster; //导入依赖的package包/类
static boolean isDefinitelyImmutableInfo(Class<?> implClass) {
    if (!NotificationBroadcaster.class.isAssignableFrom(implClass))
        return true;
    synchronized (definitelyImmutable) {
        Boolean immutable = definitelyImmutable.get(implClass);
        if (immutable == null) {
            final Class<NotificationBroadcasterSupport> nbs =
                    NotificationBroadcasterSupport.class;
            if (nbs.isAssignableFrom(implClass)) {
                try {
                    Method m = implClass.getMethod("getNotificationInfo");
                    immutable = (m.getDeclaringClass() == nbs);
                } catch (Exception e) {
                    // Too bad, we'll say no for now.
                    return false;
                }
            } else
                immutable = false;
            definitelyImmutable.put(implClass, immutable);
        }
        return immutable;
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:24,代码来源:StandardMBeanIntrospector.java

示例3: findNotifications

import javax.management.NotificationBroadcaster; //导入依赖的package包/类
static MBeanNotificationInfo[] findNotifications(Object moi) {
    if (!(moi instanceof NotificationBroadcaster))
        return null;
    MBeanNotificationInfo[] mbn =
            ((NotificationBroadcaster) moi).getNotificationInfo();
    if (mbn == null)
        return null;
    MBeanNotificationInfo[] result =
            new MBeanNotificationInfo[mbn.length];
    for (int i = 0; i < mbn.length; i++) {
        MBeanNotificationInfo ni = mbn[i];
        if (ni.getClass() != MBeanNotificationInfo.class)
            ni = (MBeanNotificationInfo) ni.clone();
        result[i] = ni;
    }
    return result;
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:18,代码来源:MBeanIntrospector.java

示例4: MemoryTileCache

import javax.management.NotificationBroadcaster; //导入依赖的package包/类
public MemoryTileCache() {
	log = Logger.getLogger(this.getClass());
	hashtable = new Hashtable<String, CacheEntry>(cacheSize);
	lruTiles = new CacheLinkedListElement();
	
	cacheSize = 500;
	MemoryMXBean mbean = ManagementFactory.getMemoryMXBean();
	NotificationBroadcaster emitter = (NotificationBroadcaster) mbean;
	emitter.addNotificationListener(this, null, null);
	// Set-up each memory pool to notify if the free memory falls below 10%
	for (MemoryPoolMXBean memPool : ManagementFactory.getMemoryPoolMXBeans()) {
		if (memPool.isUsageThresholdSupported()) {
			MemoryUsage memUsage = memPool.getUsage();
			memPool.setUsageThreshold((long) (memUsage.getMax() * 0.95));
		}
	}
}
 
开发者ID:bh4017,项目名称:mobac,代码行数:18,代码来源:MemoryTileCache.java

示例5: addNotificationListener

import javax.management.NotificationBroadcaster; //导入依赖的package包/类
public void addNotificationListener(ObjectName name,
                                    NotificationListener listener,
                                    NotificationFilter filter,
                                    Object handback)
        throws InstanceNotFoundException {

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

    DynamicMBean instance = getMBean(name);
    checkMBeanPermission(instance, null, name, "addNotificationListener");

    NotificationBroadcaster broadcaster =
            getNotificationBroadcaster(name, instance,
                                       NotificationBroadcaster.class);

    // ------------------
    // Check listener
    // ------------------
    if (listener == null) {
        throw new RuntimeOperationsException(new
            IllegalArgumentException("Null listener"),"Null listener");
    }

    NotificationListener listenerWrapper =
        getListenerWrapper(listener, name, instance, true);
    broadcaster.addNotificationListener(listenerWrapper, filter, handback);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:34,代码来源:DefaultMBeanServerInterceptor.java

示例6: addNotificationListener

import javax.management.NotificationBroadcaster; //导入依赖的package包/类
public void addNotificationListener(
        ObjectName name, NotificationListener listener,
        NotificationFilter filter, Object handback)
        throws InstanceNotFoundException {
    NotificationBroadcaster userMBean =
            (NotificationBroadcaster) getUserMBean(name);
    NotificationListener wrappedListener =
          wrappedListener(name, userMBean, listener);
    userMBean.addNotificationListener(wrappedListener, filter, handback);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:11,代码来源:OldMBeanServerTest.java


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