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


Java NotificationBroadcaster.addNotificationListener方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: addNotificationListener

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

    // ------------------------------
    // ------------------------------
    if (MBEANSERVER_LOGGER.isLoggable(Level.TRACE)) {
        MBEANSERVER_LOGGER.log(Level.TRACE, "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:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:32,代码来源:DefaultMBeanServerInterceptor.java

示例5: addNotificationListener

import javax.management.NotificationBroadcaster; //导入方法依赖的package包/类
/**
 * Registers the supplied listener with the specified management
 * bean.  Notifications emitted by the management bean are forwarded
 * to the listener via the server, which will convert an MBean
 * references in the source to a portable {@link ObjectName}
 * instance.  The notification is otherwise unchanged.
 *
 * @param name the name of the management bean with which the listener
 *             should be registered.
 * @param listener the listener which will handle notifications from
 *                 the bean.
 * @param filter the filter to apply to incoming notifications, or
 *               <code>null</code> if no filtering should be applied.
 * @param passback an object to be passed to the listener when a
 *                 notification is emitted.
 * @throws InstanceNotFoundException if the name of the management bean
 *                                   could not be resolved.
 * @throws SecurityException if a security manager exists and the
 *                           caller's permissions don't imply {@link
 *                           MBeanPermission(String,String,ObjectName,String)
 *                           <code>MBeanPermission(className, null, name,
 *                           "addNotificationListener")</code>}.
 * @see #removeNotificationListener(ObjectName, NotificationListener)
 * @see #removeNotificationListener(ObjectName, NotificationListener,
 *                                  NotificationFilter, Object)
 * @see NotificationBroadcaster#addNotificationListener(NotificationListener,
 *                                                      NotificationFilter,
 *                                                      Object)
 */
public void addNotificationListener(ObjectName name, NotificationListener listener,
                                    NotificationFilter filter, Object passback)
  throws InstanceNotFoundException
{
  Object bean = getBean(name);
  checkSecurity(name, null, "addNotificationListener");
  if (bean instanceof NotificationBroadcaster)
    {
      NotificationBroadcaster bbean = (NotificationBroadcaster) bean;
      NotificationListener indirection = new ServerNotificationListener(bean, name,
                                                                        listener);
      bbean.addNotificationListener(indirection, filter, passback);
      LazyListenersHolder.listeners.put(listener, indirection);
    }
}
 
开发者ID:vilie,项目名称:javify,代码行数:45,代码来源:Server.java

示例6: addNotificationListener

import javax.management.NotificationBroadcaster; //导入方法依赖的package包/类
/**
  * Registers the supplied listener with the specified management
  * bean.  Notifications emitted by the management bean are forwarded
  * to the listener via the server, which will convert an MBean
  * references in the source to a portable {@link ObjectName}
  * instance.  The notification is otherwise unchanged.
  *
  * @param name the name of the management bean with which the listener
  *             should be registered.
  * @param listener the listener which will handle notifications from
  *                 the bean.
  * @param filter the filter to apply to incoming notifications, or
  *               <code>null</code> if no filtering should be applied.
  * @param passback an object to be passed to the listener when a
  *                 notification is emitted.
  * @throws InstanceNotFoundException if the name of the management bean
  *                                   could not be resolved.
  * @throws SecurityException if a security manager exists and the
  *                           caller's permissions don't imply {@link
  *                           MBeanPermission(String,String,ObjectName,String)
  *                           <code>MBeanPermission(className, null, name,
  *                           "addNotificationListener")</code>}.
  * @see #removeNotificationListener(ObjectName, NotificationListener)
  * @see #removeNotificationListener(ObjectName, NotificationListener,
  *                                  NotificationFilter, Object)
  * @see NotificationBroadcaster#addNotificationListener(NotificationListener,
  *                                                      NotificationFilter,
  *                                                      Object)
  */
 public void addNotificationListener(ObjectName name, NotificationListener listener,
			      NotificationFilter filter, Object passback)
   throws InstanceNotFoundException
 {
   Object bean = getBean(name);
   checkSecurity(name, null, "addNotificationListener");
   if (bean instanceof NotificationBroadcaster)
     {
NotificationBroadcaster bbean = (NotificationBroadcaster) bean;
NotificationListener indirection = new ServerNotificationListener(bean, name,
								  listener);
bbean.addNotificationListener(indirection, filter, passback);
LazyListenersHolder.listeners.put(listener, indirection);
     }
 }
 
开发者ID:nmldiegues,项目名称:jvm-stm,代码行数:45,代码来源:Server.java


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